/* * ======== NullConverter_Instance_init ======== */ Void NullConverter_Instance_init(NullConverter_Object *obj, const NullConverter_Params *params) { List_Handle packetList; packetList = NullConverter_Instance_State_packetList(obj); List_construct(List_struct(packetList), NULL); }
/* * ======== DriverAdapter_Instance_init ======== */ Void DriverAdapter_Instance_init(DriverAdapter_Object *obj, const DriverAdapter_Params *params) { List_Handle fromDriver; fromDriver = DriverAdapter_Instance_State_fromDriver(obj); List_construct(List_struct(fromDriver), NULL); obj->driverHandle = params->driverHandle; }
/* * ======== ti_sdo_ipc_Notify_Instance_init ======== */ Int ti_sdo_ipc_Notify_Instance_init( ti_sdo_ipc_Notify_Object *obj, INotifyDriver_Handle driverHandle, UInt16 remoteProcId, UInt16 lineId, const ti_sdo_ipc_Notify_Params *params, Error_Block *eb) { UInt i; UInt16 clusterId = ti_sdo_utils_MultiProc_getClusterId(remoteProcId); List_Handle eventList; Assert_isTrue(remoteProcId < ti_sdo_utils_MultiProc_numProcessors && lineId < ti_sdo_ipc_Notify_numLines, ti_sdo_ipc_Notify_A_invArgument); Assert_isTrue(Notify_module->notifyHandles[clusterId][lineId] == NULL, ti_sdo_ipc_Notify_A_alreadyRegistered); obj->remoteProcId = remoteProcId; obj->lineId = lineId; obj->nesting = 0; /* Allocate and initialize (to 0 with calloc()) the callbacks array. */ obj->callbacks = Memory_calloc(ti_sdo_ipc_Notify_Object_heap(), (sizeof(ti_sdo_ipc_Notify_EventCallback) * ti_sdo_ipc_Notify_numEvents), 0, eb); if (obj->callbacks == NULL) { return (2); } obj->eventList = Memory_alloc(ti_sdo_ipc_Notify_Object_heap(), sizeof(List_Struct) * ti_sdo_ipc_Notify_numEvents, 0, eb); if (obj->eventList == NULL) { return (1); } for (i = 0; i < ti_sdo_ipc_Notify_numEvents; i++) { eventList = List_Object_get(obj->eventList, i); /* Pass in NULL for eb since construct should never fail */ List_construct(List_struct(eventList), NULL); } /* Used solely for remote driver (NULL if remoteProcId == self) */ obj->driverHandle = driverHandle; if (driverHandle != NULL) { /* Send this handle to the INotifyDriver */ INotifyDriver_setNotifyHandle(driverHandle, obj); } Notify_module->notifyHandles[clusterId][lineId] = obj; return (0); }
/* * ======== SystemCfg_init ======== */ Void SystemCfg_init(Void) { Registry_Result result; GateHwi_Handle gate; if (curInit++ != 0) { return; /* already initialized */ } /* register with xdc.runtime to get a diags mask */ result = Registry_addModule(&Registry_CURDESC, MODULE_NAME); Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL); List_construct(&Mod_objListStruct, NULL); Mod_objList = List_handle(&Mod_objListStruct); GateHwi_construct(&Mod_gateStruct, NULL); gate = GateHwi_handle(&Mod_gateStruct); Mod_gate = GateHwi_Handle_upCast(gate); }
/* * ======== Stream_Instance_init ======== */ Int Stream_Instance_init(Stream_Object *obj, String name, UInt mode, const Stream_Params *params, Error_Block *eb) { List_Handle freeList; obj->name = name; obj->chanParams = params->chanParams; obj->maxIssues = params->maxIssues; obj->ready = 0; obj->issued = 0; obj->mode = mode; obj->packetHeap = params->packetHeap; if (params->sync == NULL) { obj->complete = SyncSemThread_Handle_upCast(SyncSemThread_create(NULL, eb)); obj->userSync = FALSE; if (obj->complete == NULL) { return (1); } } else { obj->complete = params->sync; obj->userSync = TRUE; } freeList = Stream_Instance_State_freeList(obj); List_construct(List_struct(freeList), NULL); /* allocate packets */ obj->packets = Memory_alloc(obj->packetHeap, sizeof(DriverTypes_Packet) * (obj->maxIssues), 0, eb); if (obj->packets == NULL) { return (2); } return (Stream_postInit(obj, eb)); }
/* * ======== MessageQ_Instance_init ======== */ Int ti_sdo_ipc_MessageQ_Instance_init(ti_sdo_ipc_MessageQ_Object *obj, String name, const ti_sdo_ipc_MessageQ_Params *params, Error_Block *eb) { Int i; UInt16 start; UInt16 count; UInt key; Bool found = FALSE; List_Handle listHandle; SyncSem_Handle syncSemHandle; MessageQ_QueueIndex queueIndex; /* lock */ key = IGateProvider_enter(MessageQ_module->gate); start = ti_sdo_ipc_MessageQ_Object_count(); count = MessageQ_module->numQueues; /* Search the dynamic array for any holes */ for (i = start; (i < count) && (found == FALSE); i++) { if (MessageQ_module->queues[i] == NULL) { MessageQ_module->queues[i] = obj; queueIndex = i; found = TRUE; } } /* * If no free slot was found: * - if no growth allowed, raise and error * - if growth is allowed, grow the array */ if (found == FALSE) { if (ti_sdo_ipc_MessageQ_maxRuntimeEntries != NameServer_ALLOWGROWTH) { /* unlock scheduler */ IGateProvider_leave(MessageQ_module->gate, key); Error_raise(eb, ti_sdo_ipc_MessageQ_E_maxReached, ti_sdo_ipc_MessageQ_maxRuntimeEntries, 0); return (1); } else { queueIndex = MessageQ_grow(obj, eb); if (queueIndex == MessageQ_INVALIDMESSAGEQ) { /* unlock scheduler */ IGateProvider_leave(MessageQ_module->gate, key); return (2); } } } /* create default sync if not specified */ if (params->synchronizer == NULL) { /* Create a SyncSem as the synchronizer */ syncSemHandle = SyncSem_create(NULL, eb); if (syncSemHandle == NULL) { /* unlock scheduler */ IGateProvider_leave(MessageQ_module->gate, key); return (3); } /* store handle for use in finalize ... */ obj->syncSemHandle = syncSemHandle; obj->synchronizer = SyncSem_Handle_upCast(syncSemHandle); } else { obj->syncSemHandle = NULL; obj->synchronizer = params->synchronizer; } /* unlock scheduler */ IGateProvider_leave(MessageQ_module->gate, key); /* Fill in the message queue object */ listHandle = ti_sdo_ipc_MessageQ_Instance_State_normalList(obj); List_construct(List_struct(listHandle), NULL); listHandle = ti_sdo_ipc_MessageQ_Instance_State_highList(obj); List_construct(List_struct(listHandle), NULL); obj->queue = ((MessageQ_QueueId)(MultiProc_self()) << 16) | queueIndex; obj->unblocked = FALSE; /* Add into NameServer */ if (name != NULL) { obj->nsKey = NameServer_addUInt32( (NameServer_Handle)MessageQ_module->nameServer, name, obj->queue); if (obj->nsKey == NULL) { Error_raise(eb, ti_sdo_ipc_MessageQ_E_nameFailed, name, 0); return (4); } } return (0); }