/* * ======== POOL_init ======== * Open the allocators */ Void POOL_init(Void) { Uint16 i; POOL_Handle poolHandle; static __FAR__ Bool runFlag = FALSE; /* Make sure this does not run more than once */ if (runFlag == TRUE) { return; } runFlag = TRUE; /* Make sure everything is hooked up */ if (POOL == NULL) { SYS_abort("POOL: Failed to define POOL_config properly"); } /* Loop through all the allocators. */ for (i = 0; i < POOL->numAllocators; i++) { poolHandle = &(POOL->allocators[i]); /* Call the allocator's init and open function. */ poolHandle->initFxn(); if (poolHandle->fxns->open(&(poolHandle->object),poolHandle->params) != SYS_OK) { SYS_abort("POOL: Failed to open an allocator"); } } }
/* 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; }
/** * @brief The BIOS main() entry point. * * @remark The purpose of this function is to create a BIOS worker task * to house our example. * * @remark This is called during BIOS_init, but before the scheduler * has begun running. */ Int main(Int argc, String argv[]) { TSK_Attrs attrs = TSK_ATTRS; attrs.stacksize = 6 * 1024; attrs.name = taskName; /* init Codec Engine */ CERuntime_init(); /* init trace */ GT_init(); /* create a mask to allow a trace-print welcome message below */ GT_create(&curMask, MOD_NAME); /* Enable all trace for this module */ GT_set(MOD_NAME "=01234567"); GT_0trace(curMask, GT_2CLASS, "main> " MOD_NAME "\n"); if (TSK_create((Fxn)smain, &attrs, argc, argv) == NULL) { SYS_abort("main: failed to create smain thread."); } return (0); }
/* * ======== MSGQ_init ======== * Initialize some of the config parameters and open the transports. */ Void MSGQ_init(Void) { Uint16 i; static __FAR__ Bool runFlag = FALSE; /* Make sure this does not run more than once */ if (runFlag == TRUE) { return; } runFlag = TRUE; /* Make sure the MSGQ variable is ok */ if (MSGQ == NULL) { SYS_abort("MSGQ: Failed to define MSGQ_config properly"); } /* Initialize for the local message queues from the requested spot. */ for (i = MSGQ->startUninitialized; i < MSGQ->numMsgqQueues; i++) { MSGQ->msgqQueues[i].status = MSGQ_EMPTY; } for (i = 0; i < MSGQ->numProcessors; i++) { /* * For migration purposes, adding this check. An init * function should be specified, but just in case... */ if (MSGQ->transports[i].initFxn == NULL) { continue; } MSGQ->transports[i].initFxn(); } }
/* * ======== MSGQ_startup ======== * */ Void MSGQ_startup(Void) { Uint16 i; MSGQ_TransportHandle mqtHandle; static __FAR__ Bool runFlag = FALSE; /* Make sure this does not run more than once */ if (runFlag == TRUE) { return; } runFlag = TRUE; for (i = 0; i < MSGQ->numProcessors; i++) { mqtHandle = &(MSGQ->transports[i]); /* * Do not try the local processor (which should have * mqtHandle->fxns == NULL!) and any transport that * has no interface functions. */ if (i == GBL_getProcId() || mqtHandle->fxns == NULL) { continue; } /* Call the transport's open function */ if (mqtHandle->fxns->open(mqtHandle) != SYS_OK) { SYS_abort("MSGQ: Failed to open a transport %d", i); } } }
/* * ======== MSGQ_exit ======== * Close the transports. */ Void MSGQ_exit(Void) { Uint16 i; MSGQ_TransportHandle mqtHandle; /* Loop through all the transports. */ for (i = 0; i < MSGQ->numProcessors; i++) { mqtHandle = &(MSGQ->transports[i]); /* * Do not try the local processor (which should have * mqtHandle->fxns == NULL!) and any transport that * has no interface functions. */ if (i == GBL_getProcId() || mqtHandle->fxns == NULL) { continue; } /* Call the transport's close function. */ if (mqtHandle->fxns->close(mqtHandle) != SYS_OK) { SYS_abort("MSGQ: Failed to close a transport"); } } }
/* * ======== 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"); } }
/* * ======== DEV_init ======== * This function is called from DEV_init macro as part of BIOS_init sequence. */ Void DEV_init(Void) { DEV_TableElem *objDevHead; DEV_TableElem *objDev; DEV_Device *dptr; IOM_Fxns *fxns; Int status; Int i; /* Hook up the linked list ... */ for (i = 0; i < _DEV_numStaticDevs; i++) { QUE_put(&DEV_table, &(_DEV_staticDevTable[i])); } /* * For each device driver, call its DXX_init function *before* the * statically created streams are "opened" (calling the device's * open function for each static stream below). */ for (i = (Int) _DEV_numStaticDevs - 1; i >= 0; i--) { if (_DEV_initFxn[i] != NULL) { (_DEV_initFxn[i])(); } } /* * Call IOM bind device function (mdBindDev) if driver is of type IOM */ objDevHead = (DEV_TableElem *)&DEV_table; for(objDev = (DEV_TableElem *) QUE_next((Ptr)objDevHead); objDev != objDevHead; objDev = (DEV_TableElem *) QUE_next((Ptr)objDev)) { dptr = &objDev->device; if (dptr->type == DEV_IOMTYPE ) { fxns = (IOM_Fxns *)dptr->fxns; status = fxns->mdBindDev(&dptr->devp, dptr->devid, dptr->params); if (status != IOM_COMPLETED) { SYS_abort("ERROR - Device %s Config Failed", dptr->name); } } } }