Int32 System_ipcListMPCreate(UInt32 regionId, UInt32 linkId, ListMP_Handle *pOutHndl, ListMP_Handle *pInHndl, GateMP_Handle * pOutHndleGate, GateMP_Handle * pInHndleGate) { Int32 status; char listMPOutName[64]; char listMPInName[64]; ListMP_Params listMPParams; GateMP_Params gateMPParams; status = System_ipcGetListMPName(linkId, listMPOutName, listMPInName); UTILS_assert(status==OSA_SOK); GateMP_Params_init(&gateMPParams); gateMPParams.regionId = regionId; gateMPParams.remoteProtect = GateMP_RemoteProtect_CUSTOM1; *pOutHndleGate = GateMP_create(&gateMPParams); UTILS_assert(*pOutHndleGate!=NULL); ListMP_Params_init(&listMPParams); listMPParams.name = listMPOutName; listMPParams.regionId = regionId; listMPParams.gate = *pOutHndleGate; printf(" %u: SYSTEM: Creating ListMP [%s] in region %d ...\n", OSA_getCurTimeInMsec(), listMPParams.name, listMPParams.regionId ); *pOutHndl = ListMP_create(&listMPParams); UTILS_assert(*pOutHndl!=NULL); GateMP_Params_init(&gateMPParams); gateMPParams.regionId = regionId; gateMPParams.remoteProtect = GateMP_RemoteProtect_CUSTOM1; *pInHndleGate = GateMP_create(&gateMPParams); UTILS_assert(*pInHndleGate!=NULL); ListMP_Params_init(&listMPParams); listMPParams.name = listMPInName; listMPParams.regionId = regionId; listMPParams.gate = *pInHndleGate; printf(" %u: SYSTEM: Creating ListMP [%s] in region %d ...\n", OSA_getCurTimeInMsec(), listMPParams.name, listMPParams.regionId ); *pInHndl = ListMP_create(&listMPParams); UTILS_assert(*pInHndl!=NULL); return status; }
/* * ======== Server_create ======== */ Int Server_create() { Int status = 0; MessageQ_Params msgqParams; GateMP_Params gateParams; /* enable some log events */ Diags_setMask(MODULE_NAME"+EXF"); /* create GateMP */ GateMP_Params_init(&gateParams); gateParams.name = GATEMP_SLAVE_NAME; gateParams.localProtect = GateMP_LocalProtect_PROCESS; gateParams.remoteProtect = GateMP_RemoteProtect_SYSTEM; Module.slaveGateMPHandle = GateMP_create (&gateParams); if (Module.slaveGateMPHandle == NULL) { status = GATEMPAPP_E_FAILURE; Log_print0(Diags_INFO, "Server_create: Failed to create GateMP"); goto leave; } /* create local message queue (inbound messages) */ MessageQ_Params_init(&msgqParams); Module.slaveQue = MessageQ_create(GateMPApp_SlaveMsgQueName, &msgqParams); if (Module.slaveQue == NULL) { status = -1; Log_print0(Diags_INFO, "Server_create: Failed to create MessageQ"); GateMP_delete(&Module.slaveGateMPHandle); goto leave; } Log_print0(Diags_INFO,"Server_create: Slave is ready"); leave: Log_print1(Diags_EXIT, "<-- Server_create: %d", (IArg)status); return (status); }
/* * ======== Ipc_start ======== */ Int Ipc_start() { Int i; UInt16 baseId = MultiProc_getBaseIdOfCluster(); SharedRegion_Entry entry; Ptr ipcSharedAddr; Ptr gateMPSharedAddr; GateMP_Params gateMPParams; Int status; /* Check whether Ipc_start has been called. If so, succeed. */ if (Ipc_module->ipcSharedAddr != NULL) { return (Ipc_S_ALREADYSETUP); } if (ti_sdo_ipc_Ipc_generateSlaveDataForHost) { /* get Ipc_sr0MemorySetup out of the cache */ Cache_inv(&Ipc_sr0MemorySetup, sizeof(Ipc_sr0MemorySetup), Cache_Type_ALL, TRUE); /* check Ipc_sr0MemorySetup variable */ if (Ipc_sr0MemorySetup == 0x0) { return (Ipc_E_NOTREADY); } } /* get region 0 information */ SharedRegion_getEntry(0, &entry); /* if entry is not valid then return */ if (entry.isValid == FALSE) { return (Ipc_E_NOTREADY); } /* * Need to reserve memory in region 0 for processor synchronization. * This must done before SharedRegion_start(). */ ipcSharedAddr = ti_sdo_ipc_SharedRegion_reserveMemory( 0, Ipc_getRegion0ReservedSize()); /* must reserve memory for GateMP before SharedRegion_start() */ gateMPSharedAddr = ti_sdo_ipc_SharedRegion_reserveMemory(0, ti_sdo_ipc_GateMP_getRegion0ReservedSize()); /* Init params for default gate (must match those in GateMP_start()) */ GateMP_Params_init(&gateMPParams); gateMPParams.localProtect = GateMP_LocalProtect_TASKLET; if (ti_sdo_utils_MultiProc_numProcessors > 1) { gateMPParams.remoteProtect = GateMP_RemoteProtect_SYSTEM; } else { gateMPParams.remoteProtect = GateMP_RemoteProtect_NONE; } /* reserve memory for default gate before SharedRegion_start() */ ti_sdo_ipc_SharedRegion_reserveMemory(0, GateMP_sharedMemReq(&gateMPParams)); /* clear the reserved memory */ ti_sdo_ipc_SharedRegion_clearReservedMemory(); /* Set shared addresses */ Ipc_module->ipcSharedAddr = ipcSharedAddr; Ipc_module->gateMPSharedAddr = gateMPSharedAddr; /* create default GateMP, must be called before SharedRegion start */ status = ti_sdo_ipc_GateMP_start(Ipc_module->gateMPSharedAddr); if (status < 0) { return (status); } /* create HeapMemMP in each SharedRegion */ status = ti_sdo_ipc_SharedRegion_start(); if (status < 0) { return (status); } /* Call attach for all procs if procSync is ALL */ if (ti_sdo_ipc_Ipc_procSync == ti_sdo_ipc_Ipc_ProcSync_ALL) { /* Must attach to owner first to get default GateMP and HeapMemMP */ if (MultiProc_self() != entry.ownerProcId) { do { status = Ipc_attach(entry.ownerProcId); } while (status == Ipc_E_NOTREADY); if (status < 0) { /* Ipc_attach failed. Get out of Ipc_start */ return (status); } } /* Loop to attach to all other processors in cluster */ for (i = 0; i < ti_sdo_utils_MultiProc_numProcsInCluster; i++, baseId++) { if ((baseId == MultiProc_self()) || (baseId == entry.ownerProcId)) { continue; } /* Skip the processor if there are no interrupt lines to it */ if (Notify_numIntLines(baseId) == 0) { continue; } /* call Ipc_attach for every remote processor */ do { status = Ipc_attach(baseId); } while (status == Ipc_E_NOTREADY); if (status < 0) { /* Ipc_attach failed. Get out of Ipc_start */ return (status); } } } return (status); }