/* * This function processes requests for either websocket connections or * http connections. */ static eEsifError esif_ws_client_process_request(ClientRecordPtr clientPtr) { eEsifError result = ESIF_OK; size_t messageLength = 0; esif_ccb_memset(g_ws_http_buffer, 0, WS_BUFFER_LENGTH); /*Pull the next message from the client socket */ messageLength = (size_t)recv(clientPtr->socket, (char*)g_ws_http_buffer, WS_BUFFER_LENGTH, 0); if (messageLength == 0 || messageLength == SOCKET_ERROR) { ESIF_TRACE_DEBUG("no messages received from the socket\n"); result = ESIF_E_WS_DISC; goto exit; } else { ESIF_TRACE_DEBUG("%d bytes received\n", (int)messageLength); } if (clientPtr->state == STATE_NORMAL) { result = esif_ws_client_process_active_client(clientPtr, (char *)g_ws_http_buffer, WS_BUFFER_LENGTH, messageLength); goto exit; } if (clientPtr->state == STATE_OPENING) { result = esif_ws_client_open_client(clientPtr, (char *)g_ws_http_buffer, WS_BUFFER_LENGTH, messageLength); goto exit; } result = ESIF_E_WS_DISC; exit: return result; }
static eEsifError CreateDomains( EsifAppPtr appPtr, EsifUpPtr upPtr, AppParticipantDataMapPtr participantDataMapPtr ) { eEsifError rc = ESIF_OK; UInt8 i = 0; ESIF_TRACE_DEBUG("Create Domains\n"); for (i = 0; i < upPtr->fDspPtr->get_domain_count(upPtr->fDspPtr); i++) { struct esif_fpc_domain *domain_ptr = upPtr->fDspPtr->get_domain(upPtr->fDspPtr, i + 1); if (NULL == domain_ptr) { continue; } rc = CreateDomain(i, appPtr, participantDataMapPtr, domain_ptr); if (ESIF_OK != rc) { goto exit; } ESIF_TRACE_DEBUG("Create Domain %s\n", domain_ptr->descriptor.name); } exit: return rc; }
static eEsifError DestroyDomain( EsifAppPtr appPtr, AppParticipantDataMapPtr participantDataMapPtr, AppDomainDataMapPtr domainDataMapPtr ) { eEsifError rc = ESIF_OK; rc = appPtr->fInterface.fDomainDestroyFuncPtr( appPtr->fHandle, participantDataMapPtr->fAppParticipantHandle, domainDataMapPtr->fAppDomainHandle); if (ESIF_OK == rc) { ESIF_TRACE_DEBUG("DomainMap(%u) Esif 0x%p UnMapped From Handle 0x%p\n", domainDataMapPtr->fAppDomainId, domainDataMapPtr->fAppDomainDataPtr, domainDataMapPtr->fAppDomainHandle); } else { ESIF_TRACE_DEBUG("DomainMap(%u) Esif UnMapping Error %s(%d)\n", domainDataMapPtr->fAppDomainId, esif_rc_str(rc), rc); } memset(domainDataMapPtr, 0, sizeof(*domainDataMapPtr)); return rc; }
// IPC Execute enum esif_rc ipc_execute (struct esif_ipc *ipc) { enum esif_rc rc = ESIF_OK; struct timeval start = {0}; struct timeval finish = {0}; struct timeval result; if (g_ipc_handle == ESIF_INVALID_HANDLE) { rc = ESIF_E_NO_LOWER_FRAMEWORK; goto exit; } if (g_timestamp) { esif_ccb_get_time(&start); } rc = esif_ipc_execute(g_ipc_handle, ipc); if (g_timestamp) { esif_ccb_get_time(&finish); } if (g_timestamp) { ESIF_TRACE_DEBUG("Start time: %06lu.%06lu\n", start.tv_sec, start.tv_usec); ESIF_TRACE_DEBUG("Finish time: %06lu.%06lu\n", finish.tv_sec, finish.tv_usec); timeval_subtract(&result, &finish, &start); ESIF_TRACE_DEBUG("IPC Exec Time: %06lu.%06lu (%06lu usecs)\n", result.tv_sec, result.tv_usec, result.tv_usec); } exit: return rc; }
/* Start Conjure Library */ eEsifError EsifConjureStart(EsifCnjPtr conjurePtr) { eEsifError rc = ESIF_OK; GetIfaceFuncPtr iface_func_ptr = NULL; EsifString iface_func_name = "GetConjureInterface"; char libPath[ESIF_LIBPATH_LEN]; ESIF_TRACE_DEBUG("%s name=%s\n", ESIF_FUNC, conjurePtr->fLibNamePtr); esif_build_path(libPath, ESIF_LIBPATH_LEN, ESIF_PATHTYPE_DLL, conjurePtr->fLibNamePtr, ESIF_LIB_EXT); conjurePtr->fLibHandle = esif_ccb_library_load(libPath); if (NULL == conjurePtr->fLibHandle) { rc = ESIF_E_UNSPECIFIED; ESIF_TRACE_ERROR("%s esif_ccb_library_load() %s failed.\n", ESIF_FUNC, libPath); goto exit; } ESIF_TRACE_DEBUG("%s esif_ccb_library_load() %s completed.\n", ESIF_FUNC, libPath); iface_func_ptr = (GetIfaceFuncPtr)esif_ccb_library_get_func(conjurePtr->fLibHandle, (EsifString)iface_func_name); if (NULL == iface_func_ptr) { rc = ESIF_E_UNSPECIFIED; ESIF_TRACE_ERROR("%s esif_ccb_library_get_func() %s failed.\n", ESIF_FUNC, iface_func_name); goto exit; } ESIF_TRACE_DEBUG("%s esif_ccb_library_get_func() %s completed.\n", ESIF_FUNC, iface_func_name); rc = ConjureCreate(conjurePtr, iface_func_ptr); ESIF_TRACE_DEBUG("%s ConjureCreate completed.\n", ESIF_FUNC); exit: return rc; }
/* IPC OS Execution */ enum esif_rc esif_os_ipc_execute( esif_handle_t handle, struct esif_ipc *ipc_ptr ) { int rc = 0; ESIF_TRACE_DEBUG("linux_%s: handle = %d, IPC = %p\n", __func__, handle, ipc_ptr); /* use IOCTL or read here */ #ifdef ESIF_ATTR_OS_ANDROID rc = read(handle, ipc_ptr, ipc_ptr->data_len + sizeof(struct esif_ipc)); ESIF_TRACE_DEBUG("linux_%s: READ handle = %d, IPC = %p rc = %d\n", __func__, handle, ipc_ptr, rc); #else rc = ioctl(handle, ESIF_IOCTL_IPC, ipc_ptr); ESIF_TRACE_DEBUG("linux_%s: IOCTL handle = %d, IPC = %p rc = %d\n", __func__, handle, ipc_ptr, rc); if (rc) return ESIF_E_UNSPECIFIED; #endif return ESIF_OK; }
/* Get By Instance From ID */ EsifUpPtr EsifUpManagerGetAvailableParticipantByInstance ( const UInt8 id ) { EsifUpPtr up_ptr = NULL; ESIF_TRACE_DEBUG("%s: instance %d\n", ESIF_FUNC, id); if (id >= MAX_PARTICIPANT_ENTRY) { ESIF_TRACE_ERROR("Instance id %d is out of range\n", id); ESIF_ASSERT(0); goto exit; } /* Lock manager */ esif_ccb_read_lock(&g_uppMgr.fLock); if (g_uppMgr.fEntries[id].fState > ESIF_PM_PARTICIPANT_REMOVED) { up_ptr = g_uppMgr.fEntries[id].fUpPtr; } /* Unlock Manager */ esif_ccb_read_unlock(&g_uppMgr.fLock); exit: if (NULL == up_ptr) { ESIF_TRACE_DEBUG("%s: instance %d NOT found or OUT OF BOUNDS\n", ESIF_FUNC, id); } return up_ptr; }
void ipc_connect () { g_ipc_handle = esif_ipc_connect((char*)SESSION_ID); if (g_ipc_handle != ESIF_INVALID_HANDLE) { char *kern_str = esif_cmd_info(g_out_buf); ESIF_TRACE_DEBUG("ESIF IPC Kernel Device Opened\n"); if (NULL != kern_str) { ESIF_TRACE_DEBUG("%s", kern_str); esif_ccb_sprintf(sizeof(g_esif_kernel_version), g_esif_kernel_version, "%s", kern_str); } } }
eEsifError EsifAppDestroyParticipant( const EsifAppPtr appPtr, const EsifUpPtr upPtr ) { eEsifError rc = ESIF_OK; AppParticipantDataMapPtr participant_data_map_ptr = NULL; if (NULL == appPtr || NULL == upPtr) { rc = ESIF_E_PARAMETER_IS_NULL; goto exit; } participant_data_map_ptr = &appPtr->fParticipantData[upPtr->fInstance]; // If created as NULL no need for callback. if (NULL == participant_data_map_ptr || NULL == participant_data_map_ptr->fAppParticipantHandle) { goto exit; } rc = DestroyDomains(appPtr, participant_data_map_ptr); if (rc != ESIF_OK) { goto exit; } rc = appPtr->fInterface.fParticipantDestroyFuncPtr( appPtr->fHandle, participant_data_map_ptr->fAppParticipantHandle); if (ESIF_OK == rc) { ESIF_TRACE_DEBUG("ParticipantMap(%u) Esif 0x%p UnMapped From Handle 0x%p\n", participant_data_map_ptr->fUpPtr->fInstance, participant_data_map_ptr->fUpPtr, participant_data_map_ptr->fAppParticipantHandle); } else { ESIF_TRACE_DEBUG("ParticipantMap(%u) UnMapping Error %s(%d)\n", participant_data_map_ptr->fUpPtr->fInstance, esif_rc_str(rc), rc); } exit: if (participant_data_map_ptr != NULL) { if (participant_data_map_ptr->fUpPtr != NULL) { /* release reference on participant since we get reference on it in EsifAppCreateParticipant */ EsifUp_PutRef(participant_data_map_ptr->fUpPtr); } memset(participant_data_map_ptr, 0, sizeof(*participant_data_map_ptr)); } return rc; }
/* IPC Disconnect */ void esif_ipc_disconnect( esif_handle_t handle ) { ESIF_TRACE_DEBUG("IPC handle = %d\n", handle); esif_os_ipc_disconnect(handle); }
static eEsifError UnRegisterParticipant(const EsifParticipantIfacePtr pi) { UNREFERENCED_PARAMETER(pi); ESIF_TRACE_DEBUG("%s\n", ESIF_FUNC); return ESIF_E_NOT_IMPLEMENTED; }
/* Unloads a pluggable UPE action by library name */ eEsifError EsifActMgr_StopUpe(EsifString upeName) { eEsifError rc = ESIF_OK; EsifActMgrEntryPtr entryPtr = NULL; struct esif_link_list_node *nodePtr = NULL; if (NULL == upeName) { rc = ESIF_E_PARAMETER_IS_NULL; goto exit; } esif_ccb_write_lock(&g_actMgr.mgrLock); entryPtr = EsifActMgr_GetActEntryByLibname_Locked(upeName); if (NULL == entryPtr) { esif_ccb_write_unlock(&g_actMgr.mgrLock); rc = ESIF_E_ACTION_NOT_IMPLEMENTED; ESIF_TRACE_WARN("Failed To Find Action: %s\n", upeName); goto exit; } nodePtr = EsifActMgr_GetNodeFromEntry_Locked(entryPtr); esif_link_list_node_remove(g_actMgr.actions, nodePtr); g_actMgr.numActions--; esif_ccb_write_unlock(&g_actMgr.mgrLock); EsifActMgr_DestroyEntry(entryPtr); ESIF_TRACE_DEBUG("Stopped Action: %s\n", upeName); exit: return rc; }
// IPC Disconnect void ipc_disconnect () { esif_ipc_disconnect(g_ipc_handle); g_ipc_handle = ESIF_INVALID_HANDLE; ESIF_TRACE_DEBUG("ESIF IPC Kernel Device Closed\n"); }
/* Data For Interface Marshaling */ static AppDomainDataPtr CreateDomainData(const struct esif_fpc_domain *domainPtr) { AppDomainDataPtr dom_data_ptr = (AppDomainDataPtr)esif_ccb_malloc(sizeof(AppDomainData)); ESIF_TRACE_DEBUG("%s\n", domainPtr->descriptor.name); if (NULL == dom_data_ptr) { goto exit; } dom_data_ptr->fName.buf_ptr = (void *)domainPtr->descriptor.name; dom_data_ptr->fName.buf_len = ESIF_NAME_LEN; dom_data_ptr->fName.data_len = (UInt32)esif_ccb_strlen(domainPtr->descriptor.name, ESIF_NAME_LEN); dom_data_ptr->fName.type = ESIF_DATA_STRING; dom_data_ptr->fDescription.buf_ptr = (void *)domainPtr->descriptor.description; dom_data_ptr->fDescription.buf_len = ESIF_DESC_LEN; dom_data_ptr->fDescription.data_len = (UInt32)esif_ccb_strlen(domainPtr->descriptor.description, ESIF_DESC_LEN); dom_data_ptr->fDescription.type = ESIF_DATA_STRING; dom_data_ptr->fGuid.buf_ptr = (void *)domainPtr->descriptor.guid; dom_data_ptr->fGuid.buf_len = ESIF_GUID_LEN; dom_data_ptr->fGuid.data_len = ESIF_GUID_LEN; dom_data_ptr->fGuid.type = ESIF_DATA_GUID; dom_data_ptr->fVersion = APP_DOMAIN_VERSION; dom_data_ptr->fType = (enum esif_domain_type)domainPtr->descriptor.domainType; dom_data_ptr->fCapability = domainPtr->capability_for_domain.capability_flags; esif_ccb_memcpy(dom_data_ptr->fCapabilityBytes, domainPtr->capability_for_domain.capability_mask, 32); exit: return dom_data_ptr; }
/* IPC Connect */ esif_handle_t esif_ipc_connect( esif_string session_id ) { ESIF_TRACE_DEBUG("IPC session_id = %s\n", session_id); return esif_os_ipc_connect(session_id); }
void EsifAppMgrExit() { u8 i = 0; EsifAppPtr a_app_ptr = NULL; ESIF_TRACE_ENTRY_INFO(); EsifEventMgr_UnregisterEventByType(ESIF_EVENT_PARTICIPANT_SUSPEND, EVENT_MGR_MATCH_ANY, EVENT_MGR_DOMAIN_D0, EsifAppMgr_EventCallback, NULL); EsifEventMgr_UnregisterEventByType(ESIF_EVENT_PARTICIPANT_RESUME, EVENT_MGR_MATCH_ANY, EVENT_MGR_DOMAIN_D0, EsifAppMgr_EventCallback, NULL); EsifAppExit(); ESIF_TRACE_DEBUG("Exit Action Manager (APPMGR)"); esif_ccb_read_lock(&g_appMgr.fLock); for (i = 0; i < ESIF_MAX_APPS; i++) { a_app_ptr = &g_appMgr.fEntries[i]; // Attempt to gracefully shutdown App before forcing library unload if (a_app_ptr->fLibNamePtr != NULL) { EsifAppStop(a_app_ptr); } if (a_app_ptr->fLibNamePtr != NULL) { esif_ccb_library_unload(a_app_ptr->fLibHandle); esif_ccb_free(a_app_ptr->fLibNamePtr); esif_ccb_memset(a_app_ptr, 0, sizeof(*a_app_ptr)); } } esif_ccb_read_unlock(&g_appMgr.fLock); esif_ccb_lock_uninit(&g_appMgr.fLock); ESIF_TRACE_EXIT_INFO(); }
static eEsifError EsifSetActionDelegatePat1( const EsifUpDomainPtr domainPtr, const EsifDataPtr requestPtr) { eEsifError rc = ESIF_OK; u32 tempThreshold = ESIF_DOMAIN_TEMP_INVALID; EsifPrimitiveTuple auxTuple = {SET_TEMPERATURE_THRESHOLDS_SUR, 0, (UInt8)ESIF_DOMAIN_AUX1}; ESIF_ASSERT(domainPtr != NULL); ESIF_ASSERT(requestPtr != NULL); if (requestPtr->buf_ptr == NULL) { rc = ESIF_E_PARAMETER_IS_NULL; goto exit; } tempThreshold = *(u32 *) requestPtr->buf_ptr; ESIF_TRACE_DEBUG("Setting AUX1 = %d\n", tempThreshold); EsifUpDomain_SetTempThresh(domainPtr, ESIF_DOMAIN_AUX1, tempThreshold); auxTuple.domain = domainPtr->domain; rc = EsifUp_ExecutePrimitive(domainPtr->upPtr, &auxTuple, requestPtr, NULL); if (rc == ESIF_E_PRIMITIVE_NOT_FOUND_IN_DSP) rc = ESIF_OK; exit: return rc; }
/* Handle each weighted Minterm */ static int compare_and_weight_minterm( esif_string dsp, esif_string qry, enum dspSelectorWeight weight ) { int score = 0; if (0 == *dsp) { /* DSP don't care trumps all */ score = 0; } else if ('*' == *dsp) { /* Wildcard DSP matches all but with lower score than exact match */ score = ((int)weight) / 4; } else if (0 == *qry || '*' == *qry) { /* blank == blank don't care. */ score = 0; } else if (minterm_matches(dsp, qry)) { /* data == exact match or qry in "data|data|...|data" */ score = (int)weight; } else { score = -1; /* no match. */ } ESIF_TRACE_DEBUG("DSP VALUE: %s VERSUS PARTICIPANT VALUE: %s = SCORE: %d \n", dsp, qry, score); return score; }
enum esif_rc EsifActMgrInit () { enum esif_rc rc = ESIF_OK; u8 i = 0; ESIF_TRACE_DEBUG("%s: Init Action Manager (ACTMGR)", ESIF_FUNC); g_actMgr.fActTypes = esif_link_list_create(); if (NULL == g_actMgr.fActTypes) { return ESIF_E_NO_MEMORY; } g_actMgr.GetActType = GetActionType; g_actMgr.GetActFromName = GetActionFromName; g_actMgr.AddActType = AddAction; g_actMgr.RemoveActType = RemoveAction; /* Add static Kernel Entries */ for (i = 0; g_kernelActions[i].fType; i++) g_actMgr.AddActType(&g_actMgr, &g_kernelActions[i]); /* Action manager must be initialized */ EsifActInit(); return rc; }
eEsifError EsifAppStart(EsifAppPtr appPtr) { ESIF_TRACE_ENTRY_INFO(); eEsifError rc = ESIF_OK; GetIfaceFuncPtr iface_func_ptr = NULL; esif_string iface_func_name = GET_APPLICATION_INTERFACE_FUNCTION; char libPath[ESIF_LIBPATH_LEN]; ESIF_TRACE_DEBUG("name=%s\n", appPtr->fLibNamePtr); esif_build_path(libPath, ESIF_LIBPATH_LEN, ESIF_PATHTYPE_DLL, appPtr->fLibNamePtr, ESIF_LIB_EXT); appPtr->fLibHandle = esif_ccb_library_load(libPath); if (NULL == appPtr->fLibHandle || NULL == appPtr->fLibHandle->handle) { rc = esif_ccb_library_error(appPtr->fLibHandle); ESIF_TRACE_DEBUG("esif_ccb_library_load() %s failed [%s (%d)]: %s\n", libPath, esif_rc_str(rc), rc, esif_ccb_library_errormsg(appPtr->fLibHandle)); goto exit; } ESIF_TRACE_DEBUG("esif_ccb_library_load() %s completed.\n", libPath); iface_func_ptr = (GetIfaceFuncPtr)esif_ccb_library_get_func(appPtr->fLibHandle, (char*)iface_func_name); if (NULL == iface_func_ptr) { rc = esif_ccb_library_error(appPtr->fLibHandle); ESIF_TRACE_DEBUG("esif_ccb_library_get_func() %s failed [%s (%d)]: %s\n", iface_func_name, esif_rc_str(rc), rc, esif_ccb_library_errormsg(appPtr->fLibHandle)); goto exit; } ESIF_TRACE_DEBUG("esif_ccb_library_get_func() %s completed.\n", iface_func_name); rc = AppCreate(appPtr, iface_func_ptr); if (ESIF_OK != rc) { ESIF_TRACE_DEBUG("AppCreate failed.\n"); goto exit; } ESIF_TRACE_DEBUG("AppCreate completed.\n"); rc = EsifApp_RegisterParticipantsWithApp(appPtr); if (ESIF_OK != rc) { ESIF_TRACE_DEBUG("EsifApp_RegisterParticipantsWithApp failed.\n"); goto exit; } ESIF_TRACE_DEBUG("EsifApp_RegisterParticipantsWithApp completed.\n"); exit: if (ESIF_OK != rc) { esif_ccb_library_unload(appPtr->fLibHandle); appPtr->fLibHandle = NULL; } ESIF_TRACE_EXIT_INFO_W_STATUS(rc); return rc; }
/* Insert Action Into List */ static eEsifError AddAction( EsifActMgrPtr THIS, EsifActTypePtr actionPtr ) { ESIF_TRACE_DEBUG("Item %p", actionPtr); return esif_link_list_add_at_back(THIS->fActTypes, (void *)actionPtr); }
/* IPC Execute */ enum esif_rc esif_ipc_execute( esif_handle_t handle, struct esif_ipc *ipc_ptr ) { ESIF_TRACE_DEBUG("Handle = %d, IPC = %p\n", handle, ipc_ptr); return esif_os_ipc_execute(handle, ipc_ptr); }
static void EsifDataLogSchedule(const void *ctx) { eEsifError rc = ESIF_OK; UNREFERENCED_PARAMETER(ctx); if (dataLogContextPtr == NULL) { ESIF_TRACE_DEBUG("Data logging schedule fired had no context.\n"); goto exit; } if (dataLogContextPtr->dataLogScheduleTimer == NULL) { ESIF_TRACE_DEBUG("Data logging schedule fired but had no reference to the members.\n"); goto exit; } /* * Serialize access to the datalog state. */ while (atomic_set(&g_dataLogLock, ESIF_TRUE)) { esif_ccb_sleep_msec(ESIF_DATALOG_LOCK_SLEEP_MS); } if (EsifDataIsLogStarted()){ ESIF_TRACE_DEBUG("Data logging schedule fired but was already started.\n"); goto exit; } rc = EsifDataLogValidateParticipantList(dataLogContextPtr->dataLogParticipantList); if (rc != ESIF_OK) { ESIF_TRACE_ERROR("There was a problem with your participant list. You may have selected invalid participants, or too many participants. \n"); goto exit; } rc = EsifDataLogOpenLogFile(); if (rc != ESIF_OK) { ESIF_TRACE_ERROR("Error opening scheduled log file... \n"); goto exit; } ESIF_TRACE_DEBUG("Data logging starting... \n"); g_dataLogInterval = dataLogContextPtr->dataLogInterval; EsifDataLogStart(); exit: EsifDataLogCleanup(); atomic_set(&g_dataLogLock, ESIF_FALSE); }
eEsifError EsifActCallPluginGet( esif_context_t actCtx, EsifUpPtr upPtr, const EsifFpcActionPtr fpcActionPtr, ActExecuteGetFunction actGetFuncPtr, const EsifDataPtr requestPtr, const EsifDataPtr responsePtr ) { eEsifError rc = ESIF_OK; EsifData params[NUMBER_OF_PARAMETERS_FOR_AN_ACTION] = {0}; /* Participant Check */ if (NULL == upPtr) { rc = ESIF_E_PARAMETER_IS_NULL; ESIF_TRACE_WARN("Participant For Participant ID %d NOT FOUND\n", EsifUp_GetInstance(upPtr)); goto exit; } if (NULL == fpcActionPtr) { rc = ESIF_E_PARAMETER_IS_NULL; ESIF_TRACE_WARN("NULL action pointer received\n"); goto exit; } if (NULL == actGetFuncPtr) { ESIF_TRACE_DEBUG("Plugin function pointer is NULL\n"); rc = ESIF_E_PARAMETER_IS_NULL; goto exit; } if (NULL == requestPtr) { rc = ESIF_E_PARAMETER_IS_NULL; ESIF_TRACE_WARN("NULL request pointer\n"); goto exit; } rc = EsifFpcAction_GetParams(fpcActionPtr, params, sizeof(params)/sizeof(*params)); if (ESIF_OK != rc) { goto exit; } rc = actGetFuncPtr(actCtx, (esif_handle_t)(size_t)upPtr->fInstance, upPtr->fMetadata.fDevicePath, ¶ms[0], ¶ms[1], ¶ms[2], ¶ms[3], ¶ms[4], requestPtr, responsePtr); exit: return rc; }
/* Insert Action Into List */ static eEsifError AddAction ( EsifActMgrPtr THIS, EsifActTypePtr actionPtr ) { esif_link_list_node_add(THIS->fActTypes, esif_link_list_create_node(actionPtr)); ESIF_TRACE_DEBUG("%s: item %p", ESIF_FUNC, actionPtr); return ESIF_OK; }
eEsifError esif_uf_init() { eEsifError rc = ESIF_OK; ESIF_TRACE_ENTRY_INFO(); #ifdef ESIF_ATTR_SHELL_LOCK esif_ccb_mutex_init(&g_shellLock); #endif ESIF_TRACE_DEBUG("Init Upper Framework (UF)"); esif_ccb_mempool_init_tracking(); // Get Home directory CMD_OUT("Home: %s\n", esif_pathlist_get(ESIF_PATHTYPE_HOME)); /* OS Agnostic */ EsifLogMgrInit(); esif_link_list_init(); esif_ht_init(); esif_ccb_tmrm_init(); EsifCfgMgrInit(); EsifEventMgr_Init(); EsifCnjMgrInit(); EsifUpPm_Init(); EsifDspMgrInit(); EsifActMgrInit(); /* Web Server optionally started by shell scripts in esif_init */ /* OS Specific */ rc = esif_uf_os_init(); if (ESIF_OK != rc) { goto exit; } /* Start App Manager after all dependent components started * This does not actually start any apps. */ EsifAppMgrInit(); #ifdef ESIF_FEAT_OPT_ACTION_SYSFS SysfsRegisterParticipants(); #else ipc_connect(); sync_lf_participants(); #endif exit: ESIF_TRACE_EXIT_INFO_W_STATUS(rc); return rc; }
void EsifActMgrExit () { /* Call before destroying action manager */ EsifActExit(); if (NULL != g_actMgr.fActTypes) { esif_link_list_destroy(g_actMgr.fActTypes); } ESIF_TRACE_DEBUG("%s: Exit Action Manager (ACTMGR)", ESIF_FUNC); }
/* Lookup participant data for a instance */ static AppParticipantDataMapPtr EsifApp_GetParticipantDataMapFromInstance( const EsifAppPtr appPtr, const u8 participantId ) { UInt8 i = 0; AppParticipantDataMapPtr upDataMapPtr = NULL; /* First Find Upper Framework Pointer */ EsifUpPtr upPtr = EsifUpPm_GetAvailableParticipantByInstance(participantId); if (NULL == upPtr) { goto exit; } ESIF_TRACE_DEBUG("Have Event For Participant %s\n", EsifUp_GetName(upPtr)); /* * Okay now we have to find the correct particpant handle based on the appPtr. Note each * app will have a different particpant handle. */ for (i = 0; i < MAX_PARTICIPANT_ENTRY; i++) { if (NULL == appPtr->fParticipantData[i].fUpPtr) { continue; } if (appPtr->fParticipantData[i].fUpPtr == upPtr) { upDataMapPtr = &appPtr->fParticipantData[i]; ESIF_TRACE_DEBUG("Found participant data map for %s\n", EsifUp_GetName(upPtr)); break; } } exit: if (upPtr != NULL) { EsifUp_PutRef(upPtr); } return upDataMapPtr; }
static eEsifError EsifEventMgr_EnableEvent( EventMgrEntryPtr entryPtr ) { eEsifError rc = ESIF_OK; char guidStr[ESIF_GUID_PRINT_SIZE]; UNREFERENCED_PARAMETER(guidStr); ESIF_ASSERT(entryPtr != NULL); if (entryPtr->participantId != 0) { goto exit; } switch(entryPtr->fpcEvent.esif_group) { case ESIF_EVENT_GROUP_POWER: ESIF_TRACE_DEBUG(" Enabling Power Event: %s\n", esif_guid_print((esif_guid_t *)&entryPtr->fpcEvent.event_key, guidStr)); rc = register_for_power_notification((esif_guid_t *)&entryPtr->fpcEvent.event_key); break; case ESIF_EVENT_GROUP_SYSTEM_METRICS: ESIF_TRACE_DEBUG(" Enabling System Metrics Event: %s\n", esif_guid_print((esif_guid_t *)&entryPtr->fpcEvent.event_key, guidStr)); rc = register_for_system_metrics_notification((esif_guid_t *)&entryPtr->fpcEvent.event_key); break; case ESIF_EVENT_GROUP_SENSOR: ESIF_TRACE_DEBUG("Enabling CEM sensor events\n"); rc = esif_register_sensors(entryPtr->fpcEvent.esif_event); break; case ESIF_EVENT_GROUP_DPTF: case ESIF_EVENT_GROUP_ACPI: case ESIF_EVENT_GROUP_CODE: default: break; } exit: return rc; }
/* IPC OS Connect */ esif_handle_t esif_os_ipc_connect(char *session_id) { int fd = 0; char device[64];/* Jacob Is There a Standard Path Length? */ sprintf(device, "/dev/%s", IPC_DEVICE); fd = open(device, O_RDWR); ESIF_TRACE_DEBUG("linux_%s: session_id=%s device=%s handle=%d\n", __func__, session_id, device, fd); return fd; }