コード例 #1
0
ファイル: dpi.c プロジェクト: andreimironenko/bios
/*
 *  ======== mkSPipe ========
 */
Static SPipeObj *mkSPipe(DEV_Handle dev)
{
    SPipeObj *sPipe = MEM_alloc(0, sizeof (SPipeObj), 0);
    
    if (sPipe != MEM_ILLEGAL) {
        sPipe->dataSem = SEM_create(0, NULL);
        if (sPipe->dataSem == NULL) {
            rmSPipe(sPipe);
            return (MEM_ILLEGAL);
        }

        sPipe->freeSem = SEM_create(0, NULL);
        if (sPipe->freeSem == NULL) {
            rmSPipe(sPipe);
            return(MEM_ILLEGAL);
        }

        sPipe->readySem[DEV_INPUT] = NULL;
        sPipe->readySem[DEV_OUTPUT] = NULL;
        sPipe->device[DEV_INPUT] = NULL;
        sPipe->device[DEV_OUTPUT] = NULL;
        sPipe->id = dev->devid;

        return (sPipe);
    }
    else {
        return (MEM_ILLEGAL);
    }
}
コード例 #2
0
ファイル: app.c プロジェクト: ghslovefanfan/examples
/* ARGSUSED */
Int smain(Int argc, Char * argv[])
{
    TSK_Handle tsk;
    TSK_Attrs attrs = TSK_ATTRS;
    Int i;

    GT_0trace(ti_sdo_fc_rman_examples_hdvicp, GT_ENTER, "_smain> Enter \n");

    done = SEM_create(0, NULL);
    mutex = SEM_create(1, NULL);

    if ((done == NULL) || (mutex == NULL)) {

        SYS_abort("Sem create failed \n");
    }

/*
 * Do I care about this ? 
 */
    attrs.stackseg = EXTMEM_HEAP;

/*
 * Use a bigger stack size when printing out trace 
 */
    attrs.stacksize = 0x1000;

    for (i = 0; i < NUMTASKS; i++) {

        attrs.priority = attrsTable[i].priority;
        tsk = TSK_create((Fxn)rmanTask, &attrs, 
                                (Arg)(attrsTable[i].scratchId),
                                (Arg)(&(attrsTable[i].id)),
                                (Arg)(attrsTable[i].priority),
                (Arg)(i +1),
                (Arg)(attrsTable[i].yieldFlag));
        if (tsk == NULL) {

            GT_1trace(ti_sdo_fc_rman_examples_hdvicp, GT_7CLASS, "_rman> " 
                "Task #%d create failed \n",i);

            SYS_abort("TSK_create() of task %d failed\n",i+1); 
        }
    }

    for (i=0; i < NUMTASKS; i++) {
        SEM_pend(done, SYS_FOREVER);
    }

    GT_0trace(ti_sdo_fc_rman_examples_hdvicp, GT_4CLASS, "_smain> "
    "TEST PASSED \n");

    SEM_delete(mutex);
    SEM_delete(done);

    GT_0trace(ti_sdo_fc_rman_examples_hdvicp, GT_ENTER, "_smain> Exit \n");

    return 0;
}
コード例 #3
0
/**
* \brief   EDMA3 OS Semaphore Create
*
*      This function creates a counting semaphore with specified
*      attributes and initial value. It should be used to create a semaphore
*      with initial value as '1'. The semaphore is then passed by the user
*      to the EDMA3 driver/RM for proper sharing of resources.
* \param   initVal [IN] is initial value for semaphore
* \param   attrs [IN] is the semaphore attributes ex: Fifo type
* \param   hSem [OUT] is location to recieve the handle to just created
*      semaphore
* \return  EDMA3_DRV_SOK if succesful, else a suitable error code.
*/
EDMA3_DRV_Result edma3OsSemCreate(int initVal,
                                  const EDMA3_OS_SemAttrs *attrs,
                                  EDMA3_OS_Sem_Handle *hSem)
{
#if 0 //wj  
  EDMA3_DRV_Result semCreateResult = EDMA3_DRV_SOK;
  
  if(NULL == hSem)
  {
    semCreateResult = EDMA3_DRV_E_INVALID_PARAM;
  }
  else
  {
    *hSem = (EDMA3_OS_Sem_Handle)SEM_create(initVal, (SEM_Attrs*)attrs);
    if ( (*hSem) == NULL )
    {
      semCreateResult = EDMA3_DRV_E_SEMAPHORE;
    }
  }
  
  return semCreateResult;
#else
  *hSem = (EDMA3_OS_Sem_Handle)1;
  return 0;
#endif
  
}
コード例 #4
0
ファイル: dio.c プロジェクト: CheredHerry/ti-bios
/*
 *  ======== tskMkPort ========
 *  Creates a DIO object and binds the controller.
 */
static DIO_Handle tskMkPort(DEV_Handle device, String name)
{
    DIO_Params *params = (DIO_Params *)device->params;
    DIO_Handle dio;
    DEV_Device  *entry;
    Uns         mode;
    Int         status;

    /* params should contain name of mini-driver */
    if (params == NULL) {
        return (NULL);
    }
    
    /*
     * check to see that name of mini-driver matches one in the device table
     * and its type is of DEV_IOMTYPE.
     */
    (void)DEV_match(params->name, &entry);
    if (entry == NULL || entry->type != DEV_IOMTYPE) {
        return (NULL);
    }

    /* allocate 0-initialized dio object */
    if ((dio = MEM_calloc(0, sizeof(DIO_Obj), 0)) == MEM_ILLEGAL) {
        return (NULL);
    }

    /*
     * Tasks will pend on dio->complete if there are no available frames on
     * the fromdevice queue.
     */
    dio->context.sems.complete = SEM_create(0, NULL);

    /* make sure SEM_create() succeeded ... */
    if (dio->context.sems.complete == NULL) {
        MEM_free(0, dio, sizeof(DIO_Obj));     /* free dio object */
        return (NULL);
    }

    dio->fxns = (IOM_Fxns *)entry->fxns;

    mode = (device->mode == DEV_INPUT) ? IOM_INPUT : IOM_OUTPUT;

    /* create a channel from the mini-driver */
    status = dio->fxns->mdCreateChan(&dio->chanp, entry->devp, name, mode,
                params->chanParams, DIO_tskCallback, device); 

    if (status != IOM_COMPLETED) {
        tskRmPort(dio);
        return (NULL);
    }

    return (dio);
}
コード例 #5
0
ファイル: main.c プロジェクト: sherlock/dsplink_notify
Void main(Int argc, Char *argv[]) 
{ 
  // create the semaphore 
  dprint_sema = SEM_create (0, NULL); 
  // connect with gpp: 
  DSPLINK_init (); 
  // register callback from the gpp side: 
  NOTIFY_register (ID_GPP, 0, 6, dprint_callback, 0); 
  // start task: 
  TSK_create(TaskMain, NULL, &0); 
  // task will start as soon as main ends! 
  // don't call dprintf from here! 
} 
コード例 #6
0
ファイル: Sem_BIOS.c プロジェクト: black1tulip/DVSDK
/*
 *  ======== Sem_create ========
 */
Sem_Handle Sem_create(Int key, Int count)
{
    SEM_Handle sem;

    GT_1trace(curTrace, GT_ENTER, "Sem_create> count %d\n", count);

    if ((sem = SEM_create(count, NULL)) == NULL) {
        GT_0trace(curTrace, GT_7CLASS, "Sem_create> SEM_create failed\n");
    }

    GT_1trace(curTrace, GT_ENTER, "Sem_create> sem: 0x%lx\n", sem);

    return ((Sem_Handle)sem);
}
コード例 #7
0
ファイル: dpi.c プロジェクト: andreimironenko/bios
/*
 *  ======== DPI_init ========
 */
Void DPI_init(Void)
{
    /* Make sure the initialization happens only once for the DPI driver.*/
    static __FAR__ Bool curInit = FALSE;

    if ( curInit ) {
        return;
    }
    curInit = TRUE;

    mutex = SEM_create(1, NULL);
    sPipeList = QUE_create(NULL);

    if (mutex == NULL || sPipeList == NULL) {
        SYS_abort("DPI");
    }
}