示例#1
0
文件: video.c 项目: an0nym0u5/PSL1GHT
void
videoInitialization ( videoData *vdata )
{
  dbgprintf ( "initializing" ) ;

  /* initialize semaphore attributes */
  vdata->sem_attr.key            = 0x01 ;
  vdata->sem_attr.attr_protocol  = SYS_SEM_ATTR_PROTOCOL ;
  vdata->sem_attr.attr_pshared   = SYS_SEM_ATTR_PSHARED ;

  /* initialize mutex attributes */
  vdata->mutex_attr.key              = 0x01 ;
  vdata->mutex_attr.attr_protocol    = SYS_MUTEX_PROTOCOL_FIFO ;
  vdata->mutex_attr.attr_pshared     = SYS_MUTEX_ATTR_PSHARED ;
  vdata->mutex_attr.attr_recursive   = SYS_MUTEX_ATTR_RECURSIVE ;
  vdata->mutex_attr.attr_adaptive    = SYS_MUTEX_ATTR_ADAPTIVE ;

  /* initialize condition attributes */
  vdata->cond_attr.key               = 0x01 ;
  vdata->cond_attr.attr_pshared      = SYS_COND_ATTR_PSHARED ;

  /* create semaphore */
  sysSemCreate ( &vdata->sem, &vdata->sem_attr, 1, SEM_CONSUMERS ) ;

  /* create mutex */
  sysMutexCreate ( &vdata->mutex, &vdata->mutex_attr ) ;

  /* create cond */
  sysCondCreate ( &vdata->cond, vdata->mutex, &vdata->cond_attr ) ;

  /* initialize rsx context and buffers */
  rsxInitialization ( vdata ) ;

  dbgprintf ( "initialized" ) ;
}
示例#2
0
文件: event.c 项目: an0nym0u5/PSL1GHT
/* init event handler */
void
eventInitialization ( eventData *edata )
{
  dbgprintf ( "initializing" ) ;

  /* initialize variables */
  edata->menu = 1 ;
  edata->exitapp = 1 ;
  edata->xmbopen = 0 ;

  /* initialize semaphore attributes */
  edata->sem_attr.key            = 0x03 ;
  edata->sem_attr.attr_protocol  = SYS_SEM_ATTR_PROTOCOL ;
  edata->sem_attr.attr_pshared   = SYS_SEM_ATTR_PSHARED ;

  /* initialize mutex attributes */
  edata->mutex_attr.key              = 0x03 ;
  edata->mutex_attr.attr_protocol    = SYS_MUTEX_PROTOCOL_FIFO ;
  edata->mutex_attr.attr_pshared     = SYS_MUTEX_ATTR_PSHARED ;
  edata->mutex_attr.attr_recursive   = SYS_MUTEX_ATTR_RECURSIVE ;
  edata->mutex_attr.attr_adaptive    = SYS_MUTEX_ATTR_ADAPTIVE ;

  /* initialize condition attributes */
  edata->cond_attr.key               = 0x03 ;
  edata->cond_attr.attr_pshared      = SYS_COND_ATTR_PSHARED ;

  /* create semaphore */
  sysSemCreate ( &edata->sem, &edata->sem_attr, 1, SEM_CONSUMERS ) ;

  /* create mutex */
  sysMutexCreate ( &edata->mutex, &edata->mutex_attr ) ;

  /* create cond */
  sysCondCreate ( &edata->cond, edata->mutex, &edata->cond_attr ) ;

  /* register eventHandler */
  sysUtilRegisterCallback ( SYSUTIL_EVENT_SLOT0, eventHandler, edata ) ;

  dbgprintf ( "initialized" ) ;
}
示例#3
0
文件: pad.c 项目: an0nym0u5/PSL1GHT
/* initialize controller */
void
padInitialization (padBtnData *pdata )
{
  dbgprintf ( "initializing" ) ;

  /* initialize state variables */
  pdata->btn = 0 ;
  pdata->now = 0 ;
  pdata->last = 0 ;

  /* initialize semaphore attributes */
  pdata->sem_attr.key            = PAD_KEY ;
  pdata->sem_attr.attr_protocol  = SYS_SEM_ATTR_PROTOCOL ;
  pdata->sem_attr.attr_pshared   = SYS_SEM_ATTR_PSHARED ;

  /* initialize mutex attributes */
  pdata->mutex_attr.key              = PAD_KEY ;
  pdata->mutex_attr.attr_protocol    = SYS_MUTEX_PROTOCOL_FIFO ;
  pdata->mutex_attr.attr_pshared     = SYS_MUTEX_ATTR_PSHARED ;
  pdata->mutex_attr.attr_recursive   = SYS_MUTEX_ATTR_RECURSIVE ;
  pdata->mutex_attr.attr_adaptive    = SYS_MUTEX_ATTR_ADAPTIVE ;

  /* initialize condition attributes */
  pdata->cond_attr.key               = PAD_KEY ;
  pdata->cond_attr.attr_pshared      = SYS_COND_ATTR_PSHARED ;

  /* create semaphore */
  sysSemCreate ( &pdata->sem, &pdata->sem_attr, 1, SEM_CONSUMERS ) ;

  /* create mutex */
  sysMutexCreate ( &pdata->mutex, &pdata->mutex_attr ) ;

  /* create cond */
  sysCondCreate ( &pdata->cond, pdata->mutex, &pdata->cond_attr ) ;

  ioPadInit ( 7 ) ;

  dbgprintf ( "initialized" ) ;
}
示例#4
0
int create_sac_accessor(void)
{
    sys_cond_attr_t  cond_attr;
    sys_mutex_attr_t mutex_attr;
#ifndef USE_ISOSELF
    uint32_t         entry;
#endif
    int              ret;

    if (sa != NULL)
    {
        return -1;
    }

    sa = calloc(sizeof(sac_accessor_t), 1);
    if (sa == NULL)
    {
        LOG(lm_main, LOG_ERROR, ("sac_accessor_t malloc failed\n"));
        return -1;
    }
    sa->id = -1;

    sa->buffer = (uint8_t *) memalign(128, DMA_BUFFER_SIZE);
    memset(sa->buffer, 0, DMA_BUFFER_SIZE);

    sa->read_buffer = (uint8_t *) malloc(DMA_BUFFER_SIZE);
    sa->write_buffer = (uint8_t *) malloc(DMA_BUFFER_SIZE);

#ifdef USE_ISOSELF
    ret = file_alloc_load(SAC_MODULE_LOCATION, &sa->module_buffer, &sa->module_size);
    if (ret != 0)
    {
        LOG(lm_main, LOG_ERROR, ("cannot load file: " SAC_MODULE_LOCATION "0x%x\n", ret));
        return 0;
    }

    ret = sys_isoself_spu_create(&sa->id, sa->module_buffer);
    if (ret != 0)
    {
        LOG(lm_main, LOG_ERROR, ("sys_isoself_spu_create : 0x%x\n", ret));
        return 0;
    }
#else
    ret = sysSpuRawCreate(&sa->id, NULL);
    if (ret)
    {
        LOG(lm_main, LOG_ERROR, ("sysSpuRawCreate failed %d\n", ret));
        return ret;
    }
    LOG(lm_main, LOG_DEBUG, ("succeeded. raw_spu number is %d\n", sa->id));

    // Reset all pending interrupts before starting.
    sysSpuRawSetIntStat(sa->id, 2, 0xfUL);
    sysSpuRawSetIntStat(sa->id, 0, 0xfUL);

    ret = sysSpuRawLoad(sa->id, SAC_MODULE_LOCATION, &entry);
    if (ret)
    {
        LOG(lm_main, LOG_ERROR, ("sysSpuRawLoad failed [" SAC_MODULE_LOCATION "]%d\n", ret));
        return ret;
    }
    LOG(lm_main, LOG_DEBUG, ("succeeded. entry %x\n", entry));
#endif

#ifdef USE_ISOSELF
    ret = sys_isoself_spu_set_int_mask(sa->id, SPU_INTR_CLASS_2, INTR_PPU_MB_MASK | INTR_STOP_MASK | INTR_HALT_MASK);
    if (ret != 0)
    {
        LOG(lm_main, LOG_ERROR, ("sys_isoself_spu_set_int_mask : 0x%x\n", ret));
        return 0;
    }
#else
    ret = sysSpuRawSetIntMask(sa->id, SPU_INTR_CLASS_2, INTR_PPU_MB_MASK | INTR_STOP_MASK | INTR_HALT_MASK);
    if (ret != 0)
    {
        LOG(lm_main, LOG_ERROR, ("sys_raw_spu_set_int_mask : 0x%x\n", ret));
        return ret;
    }
#endif

    memset(&cond_attr, 0, sizeof(sys_cond_attr_t));
    cond_attr.attr_pshared = SYS_COND_ATTR_PSHARED;

    memset(&mutex_attr, 0, sizeof(sys_mutex_attr_t));
    mutex_attr.attr_protocol  = SYS_MUTEX_PROTOCOL_PRIO;
    mutex_attr.attr_recursive = SYS_MUTEX_ATTR_NOT_RECURSIVE;
    mutex_attr.attr_pshared   = SYS_MUTEX_ATTR_PSHARED;
    mutex_attr.attr_adaptive  = SYS_MUTEX_ATTR_NOT_ADAPTIVE;

    if (sysMutexCreate(&sa->mmio_mutex, &mutex_attr) != 0)
    {
        LOG(lm_main, LOG_ERROR, ("create mmio_mutex failed.\n"));
        return -1;
    }

    if (sysCondCreate(&sa->mmio_cond, sa->mmio_mutex, &cond_attr) != 0)
    {
        LOG(lm_main, LOG_ERROR, ("create mmio_cond failed.\n"));
        return -1;
    }

    if ((ret = sysThreadCreate(&sa->handler, handle_interrupt, 0, PRIMARY_PPU_THREAD_PRIO,
                               PRIMARY_PPU_STACK_SIZE,
                               THREAD_INTERRUPT, (char *) "SEL Interrupt PPU Thread"))
        != 0)
    {
        LOG(lm_main, LOG_ERROR, ("ppu_thread_create returned %d\n", ret));
        return ret;
    }

#ifdef USE_ISOSELF
    ret = sys_isoself_spu_create_interrupt_tag(sa->id, SPU_INTR_CLASS_2, SYS_HW_THREAD_ANY, &sa->intrtag);
    if (ret != 0)
    {
        LOG(lm_main, LOG_ERROR, ("sys_isoself_spu_create_interrupt_tag : 0x%x\n", ret));
        return 0;
    }
#else
    ret = sysSpuRawCreateInterrupTag(sa->id, SPU_INTR_CLASS_2, SYS_HW_THREAD_ANY, &sa->intrtag);
    if (ret != 0)
    {
        LOG(lm_main, LOG_ERROR, ("sys_raw_spu_create_interrupt_tag : 0x%x\n", ret));
        return ret;
    }
#endif

    // Establishing the interrupt tag on the interrupt PPU thread.
    LOG(lm_main, LOG_DEBUG, ("Establishing the interrupt tag on the interrupt PPU thread.\n"));
    if ((ret = sysInterruptThreadEstablish(&sa->ih, sa->intrtag, sa->handler,
                                           sa->id)) != 0)
    {
        LOG(lm_main, LOG_ERROR, ("sys_interrupt_thread_establish returned %d\n", ret));
        return ret;
    }

#ifdef USE_ISOSELF
    ret = sys_isoself_spu_set_int_mask(sa->id, SPU_INTR_CLASS_2, INTR_PPU_MB_MASK);
    if (ret != 0)
    {
        LOG(lm_main, LOG_ERROR, ("sys_isoself_spu_set_int_mask : 0x%x\n", ret));
        return 0;
    }

    ret = sys_isoself_spu_start(sa->id);
    if (ret != 0)
    {
        LOG(lm_main, LOG_ERROR, ("sys_isoself_spu_start : 0x%x\n", ret));
        return 0;
    }
#else
    ret = sysSpuRawSetIntMask(sa->id, SPU_INTR_CLASS_2, INTR_PPU_MB_MASK);
    if (ret != 0)
    {
        LOG(lm_main, LOG_ERROR, ("sys_raw_spu_set_int_mask : 0x%x\n", ret));
        return ret;
    }

    // Run the Raw SPU
    sysSpuRawWriteProblemStorage(sa->id, SPU_NextPC, entry);
    sysSpuRawWriteProblemStorage(sa->id, SPU_RunCtrl, 0x1);
    EIEIO;
#endif

    sysSpuRawWriteProblemStorage(sa->id, SPU_In_MBox, (uint64_t) sa->buffer);
    EIEIO;

    return 0;
}