//-------------------------------------------------------------------------------------------------- le_result_t le_mcc_Init ( void ) { // Create a pool for Call objects MccCallPool = le_mem_CreatePool("MccCallPool", sizeof(struct le_mcc_Call)); le_mem_ExpandPool(MccCallPool, MCC_MAX_CALL); le_mem_SetDestructor(MccCallPool, CallDestructor); SessionRefPool = le_mem_CreatePool("SessionRefPool", sizeof(SessionRefNode_t)); le_mem_ExpandPool(SessionRefPool, MCC_MAX_CALL); // Create the Safe Reference Map to use for Call object Safe References. MccCallRefMap = le_ref_CreateMap("MccCallMap", MCC_MAX_CALL); // Initialize call wakeup source - succeeds or terminates caller WakeupSource = le_pm_NewWakeupSource(0, CALL_WAKEUP_SOURCE_NAME); CallStateEventId = le_event_CreateId("CallStateEventId", sizeof(le_mcc_CallRef_t)); // Register a handler function for Call Event indications if(pa_mcc_SetCallEventHandler(NewCallEventHandler) != LE_OK) { LE_CRIT("Add pa_mcc_SetCallEventHandler failed"); return LE_FAULT; } // Add a handler to the close session service le_msg_AddServiceCloseHandler( le_mcc_GetServiceRef(), CloseSessionEventHandler, NULL ); return LE_OK; }
//-------------------------------------------------------------------------------------------------- void thread_Init ( void ) { // Create the thread memory pool. ThreadPool = le_mem_CreatePool("Thread Pool", sizeof(ThreadObj_t)); le_mem_ExpandPool(ThreadPool, THREAD_POOL_SIZE); // Create the Safe Reference Map for Thread References. Lock(); ThreadRefMap = le_ref_CreateMap("ThreadRef", THREAD_POOL_SIZE); Unlock(); // Create the destructor object pool. DestructorObjPool = le_mem_CreatePool("DestructorObjs", sizeof(DestructorObj_t)); // Create the thread-local data key to be used to store a pointer to each thread object. LE_ASSERT(pthread_key_create(&ThreadLocalDataKey, NULL) == 0); // Create a Thread Object for the main thread (the thread running this function). ThreadObj_t* threadPtr = CreateThread("main", NULL, NULL); // Store the Thread Object pointer in thread-local storage so GetCurrentThreadPtr() can // find it later. LE_ASSERT(pthread_setspecific(ThreadLocalDataKey, threadPtr) == 0); }
//-------------------------------------------------------------------------------------------------- void avData_Init ( void ) { SessionStateEvent = le_event_CreateId("Session state", sizeof(le_avdata_SessionState_t)); // Create safe reference map for session request references. The size of the map should be based on // the expected number of simultaneous requests for session. 5 of them seems reasonable. AvSessionRequestRefMap = le_ref_CreateMap("AVSessionRequestRef", 5); FieldEventDataPoolRef = le_mem_CreatePool("Field event data pool", sizeof(FieldEventData_t)); InstanceRefDataPoolRef = le_mem_CreatePool("Instance ref data pool", sizeof(InstanceRefData_t)); // Create safe reference map for instance references. The size of the map should be based on // the expected number of user data instances across all apps. For now, budget for 30 apps // and 10 instances per app. This can always be increased/decreased later, if needed. InstanceRefMap = le_ref_CreateMap("InstRefMap", 300); // Add a handler for client session closes le_msg_AddServiceCloseHandler(le_avdata_GetServiceRef(), ClientCloseSessionHandler, NULL); // Use a timer to delay releasing the session for 2 seconds. le_clk_Time_t timerInterval = { .sec=2, .usec=0 }; SessionReleaseTimerRef = le_timer_Create("Session Release timer"); le_timer_SetInterval(SessionReleaseTimerRef, timerInterval); le_timer_SetHandler(SessionReleaseTimerRef, SessionReleaseTimerHandler); }
//-------------------------------------------------------------------------------------------------- void msgService_Init ( void ) //-------------------------------------------------------------------------------------------------- { // Create and initialize the pool of Service objects. ServicePoolRef = le_mem_CreatePool("MessagingServices", sizeof(Service_t)); le_mem_ExpandPool(ServicePoolRef, MAX_EXPECTED_SERVICES); le_mem_SetDestructor(ServicePoolRef, ServiceDestructor); // Create and initialize the pool of event handlers objects. HandlerEventPoolRef = le_mem_CreatePool("HandlerEventPool", sizeof(SessionEventHandler_t)); le_mem_ExpandPool(HandlerEventPoolRef, MAX_EXPECTED_SERVICES*6); // Create safe reference map for add references. HandlersRefMap = le_ref_CreateMap("HandlersRef", MAX_EXPECTED_SERVICES*6); // Create the Service Map. ServiceMapRef = le_hashmap_Create("MessagingServices", MAX_EXPECTED_SERVICES, ComputeServiceIdHash, AreServiceIdsTheSame); // Create the key to be used to identify thread-local data records containing the Message // Reference when running a Service's message receive handler. int result = pthread_key_create(&ThreadLocalRxMsgKey, NULL); if (result != 0) { LE_FATAL("Failed to create thread local key: result = %d (%s).", result, strerror(result)); } }
//-------------------------------------------------------------------------------------------------- void le_media_Init ( void ) { // Allocate the AMR context pool. AudioAmrContextPool = le_mem_CreatePool("AudioAmrContextPool", sizeof(MediaAmrContext_t)); // Allocate the DTMF thread context pool. DtmfThreadContextPool = le_mem_CreatePool("DtmfThreadContextPool", sizeof(DtmfThreadCtx_t)); }
//-------------------------------------------------------------------------------------------------- void sig_Init ( void ) { // Create the memory pools. MonitorObjPool = le_mem_CreatePool("SigMonitor", sizeof(MonitorObj_t)); HandlerObjPool = le_mem_CreatePool("SigHandler", sizeof(HandlerObj_t)); // Create the pthread local data key. LE_ASSERT(pthread_key_create(&SigMonKey, NULL) == 0); }
void createSubPools ( void ) { // SuperPool contains 10-byte blocks SuperPoolRef = le_mem_CreatePool("SuperPool", 10); // Create N sub-pools long subpoolCnt = 0; while (subpoolCnt < SubpoolNum) { snprintf(SubpoolNameBuffer, SubpoolNameBufferSize, "Subpool%ld", subpoolCnt); // need to store the subpool references in an array SubpoolRefArray[subpoolCnt] = le_mem_CreateSubPool(SuperPoolRef, SubpoolNameBuffer, 1); // Alloc the subpool's free block, just to increase the stat count BlockRefArray[subpoolCnt] = le_mem_TryAlloc(SubpoolRefArray[subpoolCnt]); subpoolCnt++; } LE_INFO("========== Created all subpools ==========="); }
//-------------------------------------------------------------------------------------------------- le_result_t pa_mdc_Init ( void ) { if (atports_GetInterface(ATPORT_COMMAND)==NULL) { LE_WARN("DATA Module is not initialize in this session"); return LE_FAULT; } if (atports_GetInterface(ATPORT_PPP)==false) { LE_WARN("PPP Module is not initialize in this session"); return LE_FAULT; } NewSessionStateEvent = le_event_CreateIdWithRefCounting("NewSessionStateEvent"); UnsolicitedEvent = le_event_CreateId("SessionUnsolicitedEvent",sizeof(atmgr_UnsolResponse_t)); NewSessionStatePool = le_mem_CreatePool("NewSessionStatePool", sizeof(pa_mdc_SessionStateData_t)); InternalEventCall = le_event_CreateId("MDCInternalEventCall",sizeof(atmgr_UnsolResponse_t)); le_event_AddHandler("MDCUnsolHandler",InternalEventCall ,MDCInternalHandler); // set unsolicited +CGEV to Register our own handler. SetIndicationHandler(2); le_event_AddHandler("MDCUnsolHandler",UnsolicitedEvent ,CGEVUnsolHandler); return LE_OK; }
//-------------------------------------------------------------------------------------------------- void AdvertiseService ( void ) { LE_DEBUG("======= Starting Server %s ========", SERVICE_INSTANCE_NAME); le_msg_ProtocolRef_t protocolRef; // Create the server data pool _ServerDataPool = le_mem_CreatePool("ServerData", sizeof(_ServerData_t)); // Create safe reference map for handler references. // The size of the map should be based on the number of handlers defined for the server. // Don't expect that to be more than 2-3, so use 3 as a reasonable guess. _HandlerRefMap = le_ref_CreateMap("ServerHandlers", 3); // Start the server side of the service protocolRef = le_msg_GetProtocolRef(PROTOCOL_ID_STR, sizeof(_Message_t)); _ServerServiceRef = le_msg_CreateService(protocolRef, SERVICE_INSTANCE_NAME); le_msg_SetServiceRecvHandler(_ServerServiceRef, ServerMsgRecvHandler, NULL); le_msg_AdvertiseService(_ServerServiceRef); // Register for client sessions being closed le_msg_AddServiceCloseHandler(_ServerServiceRef, CleanupClientData, NULL); // Need to keep track of the thread that is registered to provide this service. _ServerThreadRef = le_thread_GetCurrent(); }
//-------------------------------------------------------------------------------------------------- void tu_Init ( void ) //-------------------------------------------------------------------------------------------------- { LE_DEBUG("** Initialize Tree User subsystem."); LE_ASSERT(sizeof(uint32_t) >= sizeof(uid_t)); // Startup the internal Legato user API. user_Init(); // Create our memory pools and allocate the info for the root user. UserPoolRef = le_mem_CreatePool(CFG_USER_POOL_NAME, sizeof(User_t)); UserCollectionRef = le_hashmap_Create(CFG_USER_COLLECTION_NAME, 31, le_hashmap_HashUInt32, le_hashmap_EqualsUInt32); le_mem_SetDestructor(UserPoolRef, UserDestructor); // Create our default root user/tree association. CreateUserInfo(0, "root", "system"); }
//-------------------------------------------------------------------------------------------------- le_result_t pa_gnss_Init ( void ) { InitializeDefaultGnssPositionData(&GnssPositionData); InitializeDefaultSatInfo(&GnssPositionData); InitializeDefaultSatUsedInfo(&GnssPositionData); GnssEventId = le_event_CreateIdWithRefCounting("GnssEventId"); NmeaEventId = le_event_CreateIdWithRefCounting("GnssNmeaEventId"); PositionEventDataPool = le_mem_CreatePool("PositionEventDataPool", sizeof(pa_Gnss_Position_t)); NmeaEventDataPool = le_mem_CreatePool("NmeaEventDataPool", NMEA_STR_LEN * sizeof(char)); return LE_OK; }
//-------------------------------------------------------------------------------------------------- void proc_Init ( void ) { ProcessPool = le_mem_CreatePool("Procs", sizeof(Process_t)); }
// ------------------------------------------------------------------------------------------------- void fjm_Start ( void ) // ------------------------------------------------------------------------------------------------- { LE_TEST_INFO("FJM TESTS START"); memset(TestResults, 0, sizeof(TestResults)); Counter = 0; // Compute the expected ending counter value. ExpectedCounterValue = GetExpectedCounterValue(); // Create semaphore to trigger CounterSemRef = le_sem_Create("CounterSem", 0); // Create the mutex. MutexRef = le_mutex_CreateNonRecursive("fork-join-mutex-test"); // Create the Context Pool. if (ContextPoolRef == NULL) { LE_TEST_INFO("Initializing FJM-ContextPool"); ContextPoolRef = le_mem_CreatePool("FJM-ContextPool", sizeof(Context_t)); le_mem_ExpandPool(ContextPoolRef, ExpectedCounterValue); } // Spawn the first child thread. SpawnChildren(1); }
//-------------------------------------------------------------------------------------------------- void properties_Init ( void ) { PropertiesIterPool = le_mem_CreatePool("PropertiesIterPool", sizeof(PropertiesIter_t)); }
//-------------------------------------------------------------------------------------------------- void atmachinestring_Init ( void ) { AtStringPool = le_mem_CreatePool("AtStringPool",sizeof(atmachinestring_t)); le_mem_ExpandPool(AtStringPool,DEFAULT_ATSTRING_POOL_SIZE); }
//-------------------------------------------------------------------------------------------------- static void InitClient(void) { // Allocate the client data pool _ClientDataPool = le_mem_CreatePool("ClientData", sizeof(_ClientData_t)); // Allocate the client thread pool _ClientThreadDataPool = le_mem_CreatePool("ClientThreadData", sizeof(_ClientThreadData_t)); // Create the thread-local data key to be used to store a pointer to each thread object. LE_ASSERT(pthread_key_create(&_ThreadDataKey, NULL) == 0); // Create safe reference map for handler references. // The size of the map should be based on the number of handlers defined multiplied by // the number of client threads. Since this number can't be completely determined at // build time, just make a reasonable guess. _HandlerRefMap = le_ref_CreateMap("ClientHandlers", 5); }
//-------------------------------------------------------------------------------------------------- void fa_event_Init ( void ) { // Create the pool from which Linux-specific thread record objects are allocated. PerThreadPool = le_mem_CreatePool("PerThreadEvent", sizeof(event_LinuxPerThreadRec_t)); le_mem_ExpandPool(PerThreadPool, LE_CONFIG_MAX_THREAD_POOL_SIZE); }
//-------------------------------------------------------------------------------------------------- void le_mrc_Init ( void ) { le_result_t result=LE_OK; pa_mrc_NetworkRegSetting_t setting; // Create an event Id for new Network Registration State notification NewNetRegStateId = le_event_CreateIdWithRefCounting("NewNetRegState"); ScanInformationListPool = le_mem_CreatePool("ScanInformationListPool", sizeof(le_mrc_ScanInformationList_t)); ScanInformationSafeRefPool = le_mem_CreatePool("ScanInformationSafeRefPool", sizeof(le_mrc_ScanInformationSafeRef_t)); // Create the Safe Reference Map to use for Scan Information List object Safe References. ScanInformationListRefMap = le_ref_CreateMap("ScanInformationListMap", MRC_MAX_SCANLIST); // Create the Safe Reference Map to use for Scan Information List object Safe References. ScanInformationRefMap = le_ref_CreateMap("ScanInformationMap", MRC_MAX_SCAN); // Register a handler function for new Registration State indication LE_DEBUG("Add pa_mrc_SetNetworkRegHandler"); LE_FATAL_IF((pa_mrc_AddNetworkRegHandler(NewRegStateHandler) == NULL), "Add pa_mrc_AddNetworkRegHandler failed"); // Get & Set the Network registration state notification LE_DEBUG("Get the Network registration state notification configuration"); result=pa_mrc_GetNetworkRegConfig(&setting); if ((result != LE_OK) || (setting == PA_MRC_DISABLE_REG_NOTIFICATION)) { LE_ERROR_IF((result != LE_OK), "Fails to get the Network registration state notification configuration"); LE_INFO("Enable the Network registration state notification"); LE_FATAL_IF((pa_mrc_ConfigureNetworkReg(PA_MRC_ENABLE_REG_NOTIFICATION) != LE_OK), "Enable the Network registration state notification failure"); } LoadMrcConfigurationFromConfigDB(); }
//-------------------------------------------------------------------------------------------------- void sem_Init ( void ) //-------------------------------------------------------------------------------------------------- { SemaphorePoolRef = le_mem_CreatePool("semaphore", sizeof(Semaphore_t)); le_mem_ExpandPool(SemaphorePoolRef, DEFAULT_POOL_SIZE); // Pass the change counter of list of semaphores to the Inspect tool. spy_SetListOfSemaphoresChgCntRef(&ListOfSemaphoresChgCntRef); }
//-------------------------------------------------------------------------------------------------- void ni_Init ( void ) //-------------------------------------------------------------------------------------------------- { LE_DEBUG("** Initialize Node Iterator subsystem."); IteratorPoolRef = le_mem_CreatePool(ITERATOR_POOL_NAME, sizeof(Iterator_t)); le_mem_ExpandPool(IteratorPoolRef, INITIAL_MAX_ITERATORS); IteratorRefMap = le_ref_CreateMap(ITERATOR_REF_MAP_NAME, INITIAL_MAX_ITERATORS*5); }
/** * MRC Stub initialization. * * @return LE_OK The function succeeded. */ le_result_t mrc_simu_Init ( void ) { LE_INFO("PA MRC Init"); NewRegStateEvent = le_event_CreateIdWithRefCounting("NewRegStateEvent"); RatChangeEvent = le_event_CreateIdWithRefCounting("RatChangeEvent"); ScanInformationPool = le_mem_CreatePool("ScanInformationPool", sizeof(pa_mrc_ScanInformation_t)); return LE_OK; }
//-------------------------------------------------------------------------------------------------- static le_result_t InitializeTimerContainer ( void ) { WatchdogPool = le_mem_CreatePool("WatchdogPool", sizeof(WatchdogObj_t)); WatchdogRefsContainer = le_hashmap_Create( "wdog_watchdogRefsContainer", LE_WDOG_HASTABLE_WIDTH, le_hashmap_HashUInt32, le_hashmap_EqualsUInt32 ); LE_ASSERT(WatchdogRefsContainer != NULL); return LE_OK; }
//-------------------------------------------------------------------------------------------------- le_result_t pa_lptSimu_Init ( void ) { LE_INFO("LPT simulated PA initialization"); // Create event EDrxParamsChangeEventId = le_event_CreateIdWithRefCounting("EDrxParamsChangeEvent"); // Create associated memory pool EDrxParamsChangeIndPool = le_mem_CreatePool("EDrxParamsChangeIndPool", sizeof(pa_lpt_EDrxParamsIndication_t)); return LE_OK; }
//-------------------------------------------------------------------------------------------------- void mem_Init ( void ) { // NOTE: No need to lock the mutex because this function should be called when there is still // only one thread running. // Create a memory for all sub-pools. SubPoolsPool = le_mem_CreatePool("SubPools", sizeof(MemPool_t)); le_mem_ExpandPool(SubPoolsPool, DEFAULT_SUB_POOLS_POOL_SIZE); // Pass the list of mem pools to the Inspect tool. spy_SetListOfPools(&ListOfPools); // Pass the change counter of list of mem pools to the Inspect tool. spy_SetListOfPoolsChgCntRef(&ListOfPoolsChgCntRef); }
//-------------------------------------------------------------------------------------------------- void fdMon_Init ( void ) //-------------------------------------------------------------------------------------------------- { // Create the FD Monitor Pool from which FD Monitor objects are to be allocated. /// @todo Make this configurable. FdMonitorPool = le_mem_CreatePool("FdMonitor", sizeof(FdMonitor_t)); le_mem_ExpandPool(FdMonitorPool, DEFAULT_FD_MONITOR_POOL_SIZE); // Create the Safe Reference Maps. /// @todo Make this configurable. FdMonitorRefMap = le_ref_CreateMap("FdMonitors", DEFAULT_FD_MONITOR_POOL_SIZE); HandlerRefMap = le_ref_CreateMap("FdEventHandlers", DEFAULT_FD_MONITOR_POOL_SIZE * LE_EVENT_NUM_FD_EVENT_TYPES); // Get a reference to the trace keyword that is used to control tracing in this module. TraceRef = le_log_GetTraceRef("fdMonitor"); }
//-------------------------------------------------------------------------------------------------- void fdMon_Init ( void ) //-------------------------------------------------------------------------------------------------- { // Create the FD Monitor Pool from which FD Monitor objects are to be allocated. /// @todo Make this configurable. FdMonitorPool = le_mem_CreatePool("FdMonitor", sizeof(FdMonitor_t)); le_mem_ExpandPool(FdMonitorPool, DEFAULT_FD_MONITOR_POOL_SIZE); // Create the Safe Reference Map. /// @todo Make this configurable. FdMonitorRefMap = le_ref_CreateMap("FdMonitors", DEFAULT_FD_MONITOR_POOL_SIZE); // Get a reference to the trace keyword that is used to control tracing in this module. TraceRef = le_log_GetTraceRef("fdMonitor"); // Create the thread-specific data key for the FD Monitor Ptr of the current running handler. LE_ASSERT(pthread_key_create(&FDMonitorPtrKey, NULL) == 0); }
//-------------------------------------------------------------------------------------------------- le_result_t pa_sim_Init ( void ) { if (atports_GetInterface(ATPORT_COMMAND)==NULL) { LE_DEBUG("SIM Module is not initialize in this session"); return LE_NOT_POSSIBLE; } SimEventPoolRef = le_mem_CreatePool("SimEventPool", sizeof(pa_sim_Event_t)); SimEventPoolRef = le_mem_ExpandPool(SimEventPoolRef,DEFAULT_SIMEVENT_POOL_SIZE); EventUnsolicitedId = le_event_CreateId("SIMEventIdUnsol",sizeof(atmgr_UnsolResponse_t)); EventNewSimStateId = le_event_CreateIdWithRefCounting("SIMEventIdNewState"); le_event_AddHandler("SIMUnsolHandler",EventUnsolicitedId ,SIMUnsolHandler); LE_DEBUG_IF(SetIndicator()!=LE_OK,"cannot set sim +WIND indicator"); return LE_OK; }
//-------------------------------------------------------------------------------------------------- void dstr_Init ( void ) //-------------------------------------------------------------------------------------------------- { LE_DEBUG("** Initialize Dynamic String subsystem."); DynamicStringPoolRef = le_mem_CreatePool(CFG_DSTR_POOL_NAME, sizeof(Dstr_t)); le_mem_SetNumObjsToForce(DynamicStringPoolRef, 100); // Grow in chunks of 100 blocks. // For now (until pool config is added to the framework), set a minimum size. if (le_mem_GetObjectCount(DynamicStringPoolRef) != 0) { LE_WARN("TODO: Remove this code."); } else { le_mem_ExpandPool(DynamicStringPoolRef, 3000); } }
// ------------------------------------------------------------------------------------------------- void fjm_Start ( void* completionObjPtr ///< [in] Pointer to the object whose reference count is used to signal /// the completion of the test. ) // ------------------------------------------------------------------------------------------------- { // Compute the expected ending counter value. ExpectedCounterValue = GetExpectedCounterValue(); // Create the mutex. MutexRef = le_mutex_CreateNonRecursive("fork-join-mutex-test"); LE_INFO("completionObjPtr = %p.", completionObjPtr); // Create the Context Pool. ContextPoolRef = le_mem_CreatePool("FJM-ContextPool", sizeof(Context_t)); le_mem_ExpandPool(ContextPoolRef, ExpectedCounterValue); // Spawn the first child thread. SpawnChildren(1, completionObjPtr); }
//-------------------------------------------------------------------------------------------------- le_result_t pa_mrc_Init ( void ) { if (atports_GetInterface(ATPORT_COMMAND)==NULL) { LE_WARN("radio control Module is not initialize in this session"); return LE_NOT_POSSIBLE; } EventUnsolicitedId = le_event_CreateId("RCEventIdUnsol",sizeof(atmgr_UnsolResponse_t)); EventNewRcStatusId = le_event_CreateIdWithRefCounting("EventNewRcStatus"); le_event_AddHandler("RCUnsolHandler",EventUnsolicitedId ,CREGUnsolHandler); RegStatePoolRef = le_mem_CreatePool("regStatePool",sizeof(le_mrc_NetRegState_t)); RegStatePoolRef = le_mem_ExpandPool(RegStatePoolRef,DEFAULT_REGSTATE_POOL_SIZE); SubscribeUnsolCREG(PA_MRC_ENABLE_REG_LOC_NOTIFICATION); pa_mrc_GetNetworkRegConfig(&ThisMode); return LE_OK; }