eEsifError EsifActMgrInit() { eEsifError rc = ESIF_OK; ESIF_TRACE_ENTRY_INFO(); esif_ccb_lock_init(&g_actMgr.fLock); g_actMgr.fActTypes = esif_link_list_create(); if (NULL == g_actMgr.fActTypes) { rc = ESIF_E_NO_MEMORY; goto exit; } g_actMgr.GetActType = GetActionType; g_actMgr.GetActFromName = GetActionFromName; g_actMgr.AddActType = AddAction; g_actMgr.RemoveActType = RemoveAction; /* Action manager must be initialized */ EsifActInit(); exit: ESIF_TRACE_EXIT_INFO_W_STATUS(rc); return rc; }
DataBankPtr DataBank_Create () { DataBankPtr self = (DataBankPtr)esif_ccb_malloc(sizeof(*self)); if (self) { esif_ccb_lock_init(&self->lock); } return self; }
// constructor static void DataVault_ctor(DataVaultPtr self) { if (self) { WIPEPTR(self); esif_ccb_lock_init(&self->lock); self->cache = DataCache_Create(); self->stream = IOStream_Create(); } }
/* Initialize manager */ eEsifError EsifUppMgrInit(void) { eEsifError rc = ESIF_OK; ESIF_TRACE_INFO("%s: Init Upper Participant Manager (PM)", ESIF_FUNC); /* Initialize Lock */ esif_ccb_lock_init(&g_uppMgr.fLock); return rc; }
eEsifError EsifDspMgrInit(void) { eEsifError rc = ESIF_OK; ESIF_TRACE_ENTRY_INFO(); esif_ccb_lock_init(&g_dm.lock); rc = esif_dsp_table_build(); ESIF_TRACE_EXIT_INFO_W_STATUS(rc); return rc; }
/* Init */ enum esif_rc esif_event_init(void) { ESIF_TRACE_DYN_INIT("%s: Initialize Event\n", ESIF_FUNC); g_event_queue = esif_queue_create(1024, g_event_queue_name); if (NULL == g_event_queue) return ESIF_E_NO_MEMORY; esif_ccb_lock_init(&g_event_lock); return ESIF_OK; }
eEsifError EsifCnjMgrInit() { eEsifError rc = ESIF_OK; ESIF_TRACE_DEBUG("%s: Init Action Manager (CNJMGR)", ESIF_FUNC); esif_ccb_lock_init(&g_cnjMgr.fLock); EsifCnjInit(); ESIF_TRACE_EXIT_INFO(); return rc; }
void esif_memtrace_init() { struct memalloc_s *mem = NULL; esif_ccb_lock_init(&g_memtrace.lock); esif_ccb_write_lock(&g_memtrace.lock); mem = g_memtrace.allocated; // Ignore any allocations made before this function was called while (mem) { struct memalloc_s *node = mem; mem = mem->next; native_free(node); } g_memtrace.allocated = NULL; esif_ccb_write_unlock(&g_memtrace.lock); ESIF_TRACE_EXIT_INFO(); }
eEsifError EsifLogMgrInit(void) { int j; ESIF_TRACE_ENTRY_INFO(); esif_ccb_memset(g_EsifLogFile, 0, sizeof(g_EsifLogFile)); for (j=0; j < MAX_ESIFLOG; j++) { esif_ccb_lock_init(&g_EsifLogFile[j].lock); } g_EsifLogFile[ESIF_LOG_EVENTLOG].name = esif_ccb_strdup("event"); g_EsifLogFile[ESIF_LOG_DEBUGGER].name = esif_ccb_strdup("debug"); g_EsifLogFile[ESIF_LOG_SHELL].name = esif_ccb_strdup("shell"); g_EsifLogFile[ESIF_LOG_TRACE].name = esif_ccb_strdup("trace"); g_EsifLogFile[ESIF_LOG_UI].name = esif_ccb_strdup("ui"); ESIF_TRACE_EXIT_INFO(); return ESIF_OK; }
eEsifError EsifAppMgrInit() { eEsifError rc = ESIF_OK; ESIF_TRACE_ENTRY_INFO(); esif_ccb_lock_init(&g_appMgr.fLock); EsifAppInit(); g_appMgr.GetAppFromName = GetAppFromName; g_appMgr.GetPrompt = GetPrompt; EsifEventMgr_RegisterEventByType(ESIF_EVENT_PARTICIPANT_SUSPEND, EVENT_MGR_MATCH_ANY, EVENT_MGR_DOMAIN_D0, EsifAppMgr_EventCallback, NULL); EsifEventMgr_RegisterEventByType(ESIF_EVENT_PARTICIPANT_RESUME, EVENT_MGR_MATCH_ANY, EVENT_MGR_DOMAIN_D0, EsifAppMgr_EventCallback, NULL); ESIF_TRACE_EXIT_INFO_W_STATUS(rc); return rc; }
eEsifError EsifActMgrInit() { eEsifError rc = ESIF_OK; ESIF_TRACE_ENTRY_INFO(); esif_ccb_lock_init(&g_actMgr.mgrLock); g_actMgr.actions = esif_link_list_create(); if (NULL == g_actMgr.actions) { rc = ESIF_E_NO_MEMORY; goto exit; } /* Action manager must be initialized before this call */ EsifActMgr_InitActions(); exit: ESIF_TRACE_EXIT_INFO_W_STATUS(rc); return rc; }
eEsifError EsifEventMgr_Init(void) { eEsifError rc = ESIF_OK; UInt8 i; ESIF_TRACE_ENTRY_INFO(); esif_ccb_lock_init(&g_EsifEventMgr.listLock); for (i = 0; i < NUM_EVENT_LISTS; i++) { g_EsifEventMgr.observerLists[i] = esif_link_list_create(); if (NULL == g_EsifEventMgr.observerLists[i]) { rc = ESIF_E_NO_MEMORY; goto exit; } } g_EsifEventMgr.eventQueuePtr = esif_queue_create(ESIF_UF_EVENT_QUEUE_SIZE, ESIF_UF_EVENT_QUEUE_NAME, ESIF_UF_EVENT_QUEUE_TIMEOUT); g_EsifEventMgr.garbageList = esif_link_list_create(); if ((NULL == g_EsifEventMgr.eventQueuePtr) || (NULL == g_EsifEventMgr.garbageList)) { rc = ESIF_E_NO_MEMORY; goto exit; } rc = esif_ccb_thread_create(&g_EsifEventMgr.eventQueueThread, EsifEventMgr_EventQueueThread, NULL); if (rc != ESIF_OK) { goto exit; } exit: if (rc != ESIF_OK) { EsifEventMgr_Exit(); } ESIF_TRACE_EXIT_INFO_W_STATUS(rc); return rc; }
/* Init */ enum esif_rc esif_action_systemio_init(void) { ESIF_TRACE_DYN_INIT("Initialize SYSTEMIO Action\n"); esif_ccb_lock_init(&g_esif_action_systemio_lock); return ESIF_OK; }
/* * This functions is expected to be called when the system is in a "known" state * before any attempt to create a timer */ enum esif_rc esif_ccb_tmrm_init(void) { esif_ccb_lock_init(&g_tmrm.mgr_lock); g_tmrm.enabled = ESIF_TRUE; return ESIF_OK; }
/* * FUNCTION DEFINITIONS */ eEsifError EsifAct_CreateAction( EsifActIfacePtr actIfacePtr, EsifActPtr *actPtr ) { eEsifError rc = ESIF_OK; EsifActPtr newActPtr = NULL; enum esif_action_type actionType; UInt16 intfcSize = 0; if ((NULL == actIfacePtr) || (NULL == actPtr)){ rc = ESIF_E_PARAMETER_IS_NULL; goto exit; } /* Check EsifActIface */ if (!EsifActIface_IsSupported(actIfacePtr)) { rc = ESIF_E_IFACE_NOT_SUPPORTED; goto exit; } intfcSize = EsifActIface_Sizeof(actIfacePtr->hdr.fIfaceVersion); if (intfcSize != actIfacePtr->hdr.fIfaceSize) { rc = ESIF_E_PARAMETER_IS_OUT_OF_BOUNDS; goto exit; } newActPtr = esif_ccb_malloc(sizeof(*newActPtr)); if (NULL == newActPtr) { rc = ESIF_E_NO_MEMORY; goto exit; } esif_ccb_memcpy(&newActPtr->iface, actIfacePtr, intfcSize); rc = EsifActIface_GetType(actIfacePtr, &actionType); if (rc != ESIF_OK) { goto exit; } newActPtr->type = actionType; newActPtr->refCount = 1; newActPtr->markedForDelete = ESIF_FALSE; esif_ccb_lock_init(&newActPtr->objLock); esif_ccb_event_init(&newActPtr->deleteEvent); rc = EsifAct_CallIfaceCreate(newActPtr); if (rc != ESIF_OK) { goto exit; } rc = EsifAct_RegisterEvents(newActPtr); if (rc != ESIF_OK) { goto exit; } ESIF_TRACE_DEBUG("\n" "Created new action:" " Name : %s\n" " Desc : %s\n" " Type : %d\n" " Version: %u\n", EsifAct_GetName(newActPtr), EsifAct_GetDesc(newActPtr), EsifAct_GetType(newActPtr), EsifAct_GetVersion(newActPtr)); *actPtr = newActPtr; exit: if (rc != ESIF_OK) { EsifAct_DestroyAction(newActPtr); } return rc; }
// Automatically Load all Static DataVaults and *.dv files in the current folder into the DataBank eEsifError DataBank_LoadDataVaults (DataBankPtr self) { eEsifError rc = ESIF_OK; esif_ccb_file_find_handle find_handle; esif_string file_path = 0; char file_pattern[MAX_PATH]; char file_path_buf[MAX_PATH] = {0}; struct esif_ccb_file *ffd_ptr; UInt32 idx; ASSERT(self); esif_ccb_lock_init(&self->lock); // TODO: Locking // Import all Static DataVaults into ReadOnly DataVaults for (idx = 0; g_StaticDataVaults[idx].name; idx++) { DataVaultPtr DB = DataBank_OpenNameSpace(self, g_StaticDataVaults[idx].name); if (DB) { IOStream_SetMemory(DB->stream, g_StaticDataVaults[idx].buffer, g_StaticDataVaults[idx].buf_len); DB->flags |= (ESIF_SERVICE_CONFIG_READONLY | ESIF_SERVICE_CONFIG_NOCACHE); DataVault_ReadVault(DB); } } // Create ESIFDV_DIR if it doesn't exit (only 1 level deep for now) esif_ccb_makepath(ESIFDV_DIR); // Import all matching *.dv files into ReadWrite DataVaults esif_ccb_strcpy(file_path_buf, ESIFDV_DIR, sizeof(file_path_buf)); file_path = file_path_buf; esif_ccb_sprintf(MAX_PATH, file_pattern, "*%s", ESIFDV_FILEEXT); ffd_ptr = (struct esif_ccb_file*)esif_ccb_malloc(sizeof(*ffd_ptr)); if (NULL == ffd_ptr) { return ESIF_E_NO_MEMORY; } find_handle = esif_ccb_file_enum_first(file_path, file_pattern, ffd_ptr); if (INVALID_HANDLE_VALUE == find_handle) { rc = ESIF_OK; // No Persisted DataVaults found } else { do { struct esif_ccb_file dv_file = {0}; DataVaultPtr DB = 0; // Read DataVault File, unless it's already been loaded as a Static DataVault if (esif_ccb_strlen(ffd_ptr->filename, MAX_PATH) > sizeof(ESIFDV_FILEEXT)) { ffd_ptr->filename[esif_ccb_strlen(ffd_ptr->filename, MAX_PATH) - (sizeof(ESIFDV_FILEEXT) - 1)] = 0; // Truncate ".dv" extension if (DataBank_GetNameSpace(self, ffd_ptr->filename) == NULL) { DB = DataBank_OpenNameSpace(self, ffd_ptr->filename); if (DB) { esif_ccb_sprintf(MAX_PATH, dv_file.filename, "%s%s%s", file_path, DB->name, ESIFDV_FILEEXT); IOStream_SetFile(DB->stream, dv_file.filename, "rb"); DataVault_ReadVault(DB); } } } } while (esif_ccb_file_enum_next(find_handle, file_pattern, ffd_ptr)); esif_ccb_file_enum_close(find_handle); } esif_ccb_free(ffd_ptr); return rc; }