Пример #1
0
// IPC Auto Connect
eEsifError ipc_autoconnect(UInt32 max_retries)
{
	eEsifError rc = ESIF_OK;
	UInt32 connect_retries = 0;

	ESIF_TRACE_ENTRY_INFO();

	if (g_ipc_handle != ESIF_INVALID_HANDLE) {
		return rc;
	}

	// Attempt to connect to LF indefinitely until ESIF exits (unless the LF version is unsupported)
	while (!g_quit) {
		rc = ipc_connect();
		if (rc == ESIF_OK || rc == ESIF_E_NOT_SUPPORTED) {
			break;
		}

		if (max_retries > 0 && ++connect_retries >= max_retries) {
			ESIF_TRACE_ERROR("Unable to do an IPC connect\n");
			break;
		}

		esif_ccb_sleep(1);
	}
	ESIF_TRACE_EXIT_INFO_W_STATUS(rc);
	return rc;
}
Пример #2
0
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;
}
Пример #3
0
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;
}
Пример #4
0
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;
}
Пример #5
0
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;
}
Пример #6
0
// IPC Connect
eEsifError ipc_connect()
{
	eEsifError rc = ESIF_OK;
	int check_kernel_version = ESIF_TRUE;

	ESIF_TRACE_ENTRY_INFO();

	// Exit if IPC already connected
	if (g_ipc_handle != ESIF_INVALID_HANDLE) {
		return ESIF_OK;
	}

	// Connect to LF
	g_ipc_handle = esif_ipc_connect((char *)SESSION_ID);
	if (g_ipc_handle == ESIF_INVALID_HANDLE) {
		ESIF_TRACE_WARN("ESIF LF is not available\n");
		rc = ESIF_E_NO_LOWER_FRAMEWORK;
	}
	else {
		char *outbuf = esif_ccb_malloc(OUT_BUF_LEN);
		char *kern_str = (outbuf != NULL ? esif_cmd_info(outbuf) : NULL);
		ESIF_TRACE_DEBUG("ESIF IPC Kernel Device Opened\n");
		if (NULL != kern_str) {
			// Extract just the Kernel LF Version from the result string
			extract_kernel_version(kern_str, OUT_BUF_LEN);

			// Bypass Kernel Version check for DEBUG builds
			#if defined(ESIF_ATTR_DEBUG)
			check_kernel_version = ESIF_FALSE;
			#endif

			// Validate Kernel LF version is compatible with UF version
			if (check_kernel_version == ESIF_FALSE || esif_ccb_strcmp(kern_str, ESIF_VERSION) == 0) {
				ESIF_TRACE_INFO("Kernel Version: %s\n", kern_str);
				esif_ccb_sprintf(sizeof(g_esif_kernel_version), g_esif_kernel_version, "%s", kern_str);
			}
			else {
				ESIF_TRACE_ERROR("ESIF_LF Version (%s) Incompatible with ESIF_UF Version (%s)\n", kern_str, ESIF_VERSION);
				ipc_disconnect();
				rc = ESIF_E_NOT_SUPPORTED;
			}
		}
		esif_ccb_free(outbuf);
	}
	ESIF_TRACE_EXIT_INFO_W_STATUS(rc);
	return rc;
}
Пример #7
0
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;
}
Пример #8
0
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;
}
Пример #9
0
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;
}
Пример #10
0
/* Will sync any existing lower framework participatnts */
enum esif_rc sync_lf_participants()
{
	eEsifError rc = ESIF_OK;
	struct esif_command_get_participants *data_ptr = NULL;
	const UInt32 data_len = sizeof(struct esif_command_get_participants);
	struct esif_ipc_command *command_ptr = NULL;
	UInt8 i = 0;
	UInt32 count = 0;
	struct esif_ipc *ipc_ptr = NULL;
	
	ESIF_TRACE_ENTRY_INFO();
	
	ipc_ptr = esif_ipc_alloc_command(&command_ptr, data_len);
	if (NULL == ipc_ptr || NULL == command_ptr) {
		ESIF_TRACE_ERROR("Fail to allocate esif_ipc/esif_ipc_command\n");
		rc = ESIF_E_NO_MEMORY;
		goto exit;
	}

	command_ptr->type = ESIF_COMMAND_TYPE_GET_PARTICIPANTS;
	command_ptr->req_data_type   = ESIF_DATA_VOID;
	command_ptr->req_data_offset = 0;
	command_ptr->req_data_len    = 0;
	command_ptr->rsp_data_type   = ESIF_DATA_STRUCTURE;
	command_ptr->rsp_data_offset = 0;
	command_ptr->rsp_data_len    = data_len;

	rc = ipc_execute(ipc_ptr);
	if (ESIF_OK != rc) {
		goto exit;
	}

	if (ESIF_OK != ipc_ptr->return_code) {
		rc = ipc_ptr->return_code;
		ESIF_TRACE_WARN("ipc_ptr return_code failure - %s\n", esif_rc_str(rc));
		goto exit;
	}

	if (ESIF_OK != command_ptr->return_code) {
		rc = command_ptr->return_code;
		ESIF_TRACE_WARN("command_ptr return_code failure - %s\n", esif_rc_str(rc));
		goto exit;
	}

	/* Participant Data */
	data_ptr = (struct esif_command_get_participants *)(command_ptr + 1);
	count    = data_ptr->count;

	for (i = 0; i < count; i++) {
		struct esif_ipc_event_data_create_participant participantData;
		EsifData esifParticipantData = {ESIF_DATA_BINARY, &participantData, sizeof(participantData), sizeof(participantData)};

		rc = get_participant_data(&participantData, i);
		if (ESIF_OK != rc) {
			rc = ESIF_OK; /* Ignore RC for get_participant_data */
			continue;
		}
		EsifEventMgr_SignalEvent(0, EVENT_MGR_DOMAIN_D0, ESIF_EVENT_PARTICIPANT_CREATE, &esifParticipantData);
	}
exit:
	ESIF_TRACE_INFO("rc = %s(%u)", esif_rc_str(rc), rc);

	if (NULL != ipc_ptr) {
		esif_ipc_free(ipc_ptr);
	}

	ESIF_TRACE_EXIT_INFO_W_STATUS(rc);
	return rc;
}