Ejemplo n.º 1
0
/* See EsifUpDomain_InitIterator for usage */
static eEsifError get_next_fpc_domain(
	EsifDspPtr dspPtr,
	EsifFpcDomainIteratorPtr iteratorPtr,
	EsifFpcDomainPtr *fpcDomainPtr
	)
{
	eEsifError rc = ESIF_OK;

	if ((NULL == dspPtr) || (NULL == iteratorPtr) || (NULL == fpcDomainPtr)) {
		ESIF_TRACE_WARN("Parameter is NULL\n");
		rc = ESIF_E_PARAMETER_IS_NULL;
		goto exit;
	}

	/* Verify the iterator is initialized */
	if (iteratorPtr->marker != FPC_DOMAIN_ITERATOR_MARKER) {
		ESIF_TRACE_WARN("Iterator invalid\n");
		rc = ESIF_E_INVALID_HANDLE;
		goto exit;
	}

	if (iteratorPtr->currPtr == NULL) {
		*fpcDomainPtr = NULL;
		rc = ESIF_E_ITERATION_DONE;
	}
	else {
		*fpcDomainPtr = (EsifFpcDomainPtr) iteratorPtr->currPtr->data_ptr;
		iteratorPtr->currPtr = iteratorPtr->currPtr->next_ptr;
	}
	
exit:
	return rc;
}
Ejemplo n.º 2
0
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,
		&params[0],
		&params[1],
		&params[2],
		&params[3],
		&params[4],
		requestPtr,
		responsePtr);
exit:
	return rc;
}
Ejemplo n.º 3
0
/* 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;
}
Ejemplo n.º 4
0
// 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) {
		ESIF_TRACE_WARN("ESIF LF is not available\n");
		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;
}
Ejemplo n.º 5
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;
}
Ejemplo n.º 6
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;
}
Ejemplo n.º 7
0
/* Work Around */
static enum esif_rc get_participant_data(
	struct esif_ipc_event_data_create_participant *pi_ptr,
	UInt8 participantId
	)
{
	eEsifError rc = ESIF_OK;

	struct esif_command_get_part_detail *data_ptr = NULL;
	struct esif_ipc_command *command_ptr = NULL;
	struct esif_ipc *ipc_ptr = NULL;
	const u32 data_len = sizeof(struct esif_command_get_part_detail);

	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_PARTICIPANT_DETAIL;
	command_ptr->req_data_type   = ESIF_DATA_UINT32;
	command_ptr->req_data_offset = 0;
	command_ptr->req_data_len    = 4;
	command_ptr->rsp_data_type   = ESIF_DATA_STRUCTURE;
	command_ptr->rsp_data_offset = 0;
	command_ptr->rsp_data_len    = data_len;

	// ID For Command
	*(u32 *)(command_ptr + 1) = participantId;
	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;
	}

	// our data
	data_ptr = (struct esif_command_get_part_detail *)(command_ptr + 1);
	if (0 == data_ptr->version) {
		ESIF_TRACE_ERROR("Participant version is 0\n");
		goto exit;
	}

	pi_ptr->id = (u8)data_ptr->id;
	pi_ptr->version = data_ptr->version;
	esif_ccb_memcpy(pi_ptr->class_guid, data_ptr->class_guid, ESIF_GUID_LEN);

	pi_ptr->enumerator = data_ptr->enumerator;
	pi_ptr->flags = data_ptr->flags;

	esif_ccb_strcpy(pi_ptr->name, data_ptr->name, ESIF_NAME_LEN);
	esif_ccb_strcpy(pi_ptr->desc, data_ptr->desc, ESIF_DESC_LEN);
	esif_ccb_strcpy(pi_ptr->driver_name, data_ptr->driver_name, ESIF_NAME_LEN);
	esif_ccb_strcpy(pi_ptr->device_name, data_ptr->device_name, ESIF_NAME_LEN);
	esif_ccb_strcpy(pi_ptr->device_path, data_ptr->device_path, ESIF_NAME_LEN);

	/* ACPI */
	esif_ccb_strcpy(pi_ptr->acpi_device, data_ptr->acpi_device, ESIF_NAME_LEN);
	esif_ccb_strcpy(pi_ptr->acpi_scope, data_ptr->acpi_scope, ESIF_SCOPE_LEN);
	esif_ccb_strcpy(pi_ptr->acpi_uid, data_ptr->acpi_uid, sizeof(pi_ptr->acpi_uid));
	pi_ptr->acpi_type = data_ptr->acpi_type;

	/* PCI */
	pi_ptr->pci_vendor     = data_ptr->pci_vendor;
	pi_ptr->pci_device     = data_ptr->pci_device;
	pi_ptr->pci_bus        = data_ptr->pci_bus;
	pi_ptr->pci_bus_device = data_ptr->pci_bus_device;
	pi_ptr->pci_function   = data_ptr->pci_function;
	pi_ptr->pci_revision   = data_ptr->pci_revision;
	pi_ptr->pci_class      = data_ptr->pci_class;
	pi_ptr->pci_sub_class  = data_ptr->pci_sub_class;
	pi_ptr->pci_prog_if    = data_ptr->pci_prog_if;

exit:

	if (NULL != ipc_ptr) {
		esif_ipc_free(ipc_ptr);
	}
	return rc;
}
Ejemplo n.º 8
0
eEsifError esif_fpc_load(
	EsifFpcPtr fpcPtr,
	EsifDspPtr dspPtr
	)
{
	eEsifError rc = ESIF_OK;
	EsifFpcDomainPtr domainPtr;
	EsifFpcPrimitivePtr primitivePtr;
	EsifFpcAlgorithmPtr algoPtr;
	EsifFpcEventPtr eventPtr;
	unsigned long offset = 0;
	UInt8 *basePtr    = (UInt8 *)fpcPtr;
	UInt32 numPrim    = 0;
	UInt32 i;
	UInt32 j;

	if ((fpcPtr == NULL) || (dspPtr == NULL))
	{
		ESIF_TRACE_ERROR("The fpc pointer or dsp pointer is NULL\n");
		rc = ESIF_E_PARAMETER_IS_NULL;
		goto exit;
	}

	if (fpcPtr->number_of_domains < 1) {
		ESIF_TRACE_WARN("No domain error, number_of_domain = %d (less than 1)\n",
			fpcPtr->number_of_domains);
		rc = ESIF_E_PARAMETER_IS_NULL;
		goto exit;
	}
	dspPtr->domain_count = &fpcPtr->number_of_domains;

	/* Allocate Hash and List. Hash Size 31 Is Hard-Coded And Chosen By DSP Compiler */
	dspPtr->ht_ptr     = esif_ht_create(ESIF_DSP_HASHTABLE_SIZE);
	dspPtr->algo_ptr   = esif_link_list_create();
	dspPtr->domain_ptr = esif_link_list_create();
	dspPtr->cap_ptr    = esif_link_list_create();
	dspPtr->evt_ptr    = esif_link_list_create();

	if (!dspPtr->ht_ptr || !dspPtr->algo_ptr || !dspPtr->domain_ptr || !dspPtr->cap_ptr || !dspPtr->evt_ptr) {
		ESIF_TRACE_ERROR("Fail to allocate linked list or hash table\n");
		rc = ESIF_E_NO_MEMORY;
		goto exit;
	}

	ESIF_TRACE_DEBUG("<fpc @ %p> FPC name '%s' ver %x,%x desc '%s' size %u num_domains %d num_algorithms %d num_events %d",
					 fpcPtr,
					 fpcPtr->header.name,
					 fpcPtr->header.ver_major,
					 fpcPtr->header.ver_minor,
					 fpcPtr->header.description,
					 fpcPtr->size,
					 fpcPtr->number_of_domains,
					 fpcPtr->number_of_algorithms,
					 fpcPtr->number_of_events);

	/* First Domain, Ok To Have Zero Primitive Of A Domain */
	domainPtr = (EsifFpcDomainPtr)(fpcPtr + 1);
	for (i = 0; i < fpcPtr->number_of_domains; i++) {
		offset = (unsigned long)((UInt8 *)domainPtr - basePtr);
		ESIF_TRACE_DEBUG("<%04lu> Domain[%d] name %s size %d num_of_primitives %d  "
						 "num_of_capabilites %u (0x%x)",
						 offset, i, domainPtr->descriptor.name, domainPtr->size,
						 domainPtr->number_of_primitives,
						 domainPtr->capability_for_domain.number_of_capability_flags,
						 domainPtr->capability_for_domain.capability_flags);

		/* Insert Domain Into Linked List */
		rc = dspPtr->insert_domain(dspPtr, domainPtr);
		if (ESIF_OK != rc) {
			ESIF_TRACE_ERROR("Fail to insert domain #%d\n", i);
			goto exit;
		}

		/* Capability */
		for (j = 0; j < domainPtr->capability_for_domain.number_of_capability_flags; j++) {
			offset = (unsigned long)(((UInt8 *)&domainPtr->capability_for_domain) - basePtr);
			ESIF_TRACE_DEBUG("<%04lu> Capability[%d] 0x%x", offset, j,
							 domainPtr->capability_for_domain.capability_mask[j]);
		}

		/* First Primtive */
		primitivePtr = (EsifFpcPrimitivePtr)(domainPtr + 1);
		for (j = 0; j < domainPtr->number_of_primitives; j++, numPrim++) {
			offset = (unsigned long)(((UInt8 *)primitivePtr) - basePtr);
			ESIF_TRACE_DEBUG("<%04lu> Primitive[%03d]: size %3d tuple_id <%03u %03u %03u> "
							 "operation %u(%s) req_type %u(%s) res_type %u(%s) num_actions %u",
							 offset, j,
							 primitivePtr->size,
							 primitivePtr->tuple.id,
							 primitivePtr->tuple.domain,
							 primitivePtr->tuple.instance,
							 primitivePtr->operation,
							 esif_primitive_opcode_str(primitivePtr->operation),
							 primitivePtr->request_type,
							 esif_data_type_str(primitivePtr->request_type),
							 primitivePtr->result_type,
							 esif_data_type_str(primitivePtr->result_type),
							 primitivePtr->num_actions);
			/* Insert Primitive Into Hash */
			rc = dspPtr->insert_primitive(dspPtr, primitivePtr);
			if (ESIF_OK != rc) {
				ESIF_TRACE_ERROR("Fail to insert primitive (id = %d)\n", primitivePtr->tuple.id);
				goto exit;
			}
			/* Next Primitive */
			primitivePtr = (EsifFpcPrimitivePtr)((UInt8 *)primitivePtr + primitivePtr->size);
		}
		/* Next Domain */
		domainPtr = (EsifFpcDomainPtr)((UInt8 *)domainPtr + domainPtr->size);
	}

	/* First Algorithm (Laid After The Last Domain) */
	algoPtr = (EsifFpcAlgorithmPtr)domainPtr;
	for (i = 0; i < fpcPtr->number_of_algorithms; i++) {
		offset = (unsigned long)((UInt8 *)algoPtr - basePtr);
		ESIF_TRACE_DEBUG("<%04lu> Algorithm[%03d]:  action_type %u(%s) temp_xform %u "
						 "tempC1 %u percent_xform %u size %u",
						 offset, i,
						 algoPtr->action_type,
						 esif_action_type_str(algoPtr->action_type),
						 algoPtr->temp_xform,
						 algoPtr->tempC1,
						 algoPtr->percent_xform,
						 algoPtr->size);

		/* Insert Algorithm Into Linked List */
		rc = dspPtr->insert_algorithm(dspPtr, algoPtr);
		if (ESIF_OK != rc) {
			ESIF_TRACE_ERROR("Fail to insert algorithm - %s\n", esif_action_type_str(algoPtr->action_type));
			goto exit;
		}

		/* Next Algorithm */
		algoPtr = (EsifFpcAlgorithmPtr)(algoPtr + 1);
	}

	/* First Event (Laid After The Last Algorithm) */
	eventPtr = (EsifFpcEventPtr)algoPtr;
	for (i = 0; i < fpcPtr->number_of_events; i++) {
		offset = (unsigned long)((UInt8 *)eventPtr - basePtr);
		ESIF_TRACE_DEBUG("<%04lu> Event [%03d] type %s(%d)\n",
						 offset, i, esif_event_type_str(eventPtr->esif_event), eventPtr->esif_event);

		/* Insert Algorithm Into Linked List */
		rc = dspPtr->insert_event(dspPtr, eventPtr);
		if (ESIF_OK != rc) {
			ESIF_TRACE_ERROR("Fail to insert event - %s\n", esif_event_type_str(eventPtr->esif_event));
			goto exit;
		}

		/* Next Event */
		eventPtr = (EsifFpcEventPtr)(eventPtr + 1);
	}

exit:
	if (fpcPtr != NULL) {
		ESIF_TRACE_DEBUG("%u domains, %u primitives and %u algorithms %u events inserted! status %s",
						 fpcPtr->number_of_domains, numPrim, fpcPtr->number_of_algorithms, fpcPtr->number_of_events,
						 esif_rc_str(rc));
	}
	return rc;
}
Ejemplo n.º 9
0
/* Provide registration for ESIF event */
eEsifError EsifApp_RegisterEvent(
	const void *esifHandle,
	const void *appHandle,
	const void *upHandle,
	const void *domainHandle,
	const EsifDataPtr eventGuidPtr
	)
{
	eEsifError rc = ESIF_OK;
	char guidStr[ESIF_GUID_PRINT_SIZE];
	UNREFERENCED_PARAMETER(guidStr);

	if (NULL == esifHandle) {
		ESIF_TRACE_ERROR("Invalid esif handle\n");
		return ESIF_E_INVALID_HANDLE;
	}

	if (NULL == appHandle) {
		ESIF_TRACE_ERROR("Invalid app handle\n");
		return ESIF_E_INVALID_HANDLE;
	}

	if ((NULL == eventGuidPtr) || (NULL == eventGuidPtr->buf_ptr) || (ESIF_DATA_GUID != eventGuidPtr->type)) {
		ESIF_TRACE_ERROR("Invalid event GUID\n");
		return ESIF_E_PARAMETER_IS_NULL;
	}

	ESIF_TRACE_DEBUG("Registering App Event\n\n"
					 "ESIF Handle          : %p\n"
					 "App Handle           : %p\n"
					 "Participant Handle   : %p\n"
					 "Domain Handle        : %p\n"
					 "Event GUID           : %s\n\n",
					 esifHandle,
					 appHandle,
					 upHandle,
					 domainHandle,
					 esif_guid_print((esif_guid_t *)eventGuidPtr->buf_ptr, guidStr));

	/* Determine what to do based on provided parameters */
	switch (EsifApp_CategorizeEvent(appHandle, upHandle, domainHandle)) {
	case EVENT_CATEGORY_APP:
	{
		EsifAppPtr appPtr = NULL;
		EsifUpPtr upPtr   = NULL;

		/* Find Our Participant 0 */
		upPtr = EsifUpPm_GetAvailableParticipantByInstance(ESIF_INSTANCE_LF);
		if (NULL == upPtr) {
			ESIF_TRACE_WARN("Participant 0 was not found in UF participant manager\n");
			rc = ESIF_E_UNSPECIFIED;
			goto exit;
		}
		ESIF_TRACE_DEBUG("Using Participant %s\n", EsifUp_GetName(upPtr));

		EsifUp_PutRef(upPtr);

		appPtr = GetAppFromHandle(appHandle);
		if (NULL == appPtr) {
			ESIF_TRACE_ERROR("The app data was not found from app handle\n");
			rc = ESIF_E_INVALID_HANDLE;
			goto exit;
		}

		rc = EsifEventMgr_RegisterEventByGuid(eventGuidPtr->buf_ptr, 0, EVENT_MGR_DOMAIN_D0, EsifApp_EventCallback, appPtr->fHandle);
		if (ESIF_OK != rc) {
			goto exit;
		}
	}
	break;

	case EVENT_CATEGORY_PARTICIPANT:
	{
		/* Register with participant */
		AppParticipantDataMapPtr upMapPtr = NULL;
		EsifAppPtr appPtr = NULL;

		appPtr = GetAppFromHandle(appHandle);
		if (NULL == appPtr) {
			ESIF_TRACE_ERROR("The app data was not found from app handle\n");
			rc = ESIF_E_INVALID_HANDLE;
			goto exit;
		}

		upMapPtr = EsifApp_GetParticipantDataMapFromHandle(appPtr, upHandle);
		if (NULL == upMapPtr) {
			ESIF_TRACE_ERROR("The app participant data was not found from participant handle\n");
			rc = ESIF_E_INVALID_HANDLE;
			goto exit;
		}
		ESIF_TRACE_DEBUG("Using Participant %s\n", EsifUp_GetName(upMapPtr->fUpPtr));

		rc = EsifEventMgr_RegisterEventByGuid(eventGuidPtr->buf_ptr, upMapPtr->fUpPtr->fInstance, EVENT_MGR_MATCH_ANY, EsifApp_EventCallback, appPtr->fHandle);
		if (ESIF_OK != rc) {
			goto exit;
		}
	}
	break;

	case EVENT_CATEGORY_DOMAIN:
	{
		/* Register with domain */
		AppParticipantDataMapPtr upMapPtr = NULL;
		AppDomainDataMapPtr domainPtr   = NULL;
		EsifAppPtr appPtr = NULL;

		appPtr = GetAppFromHandle(appHandle);
		if (NULL == appPtr) {
			ESIF_TRACE_ERROR("The app data was not found from app handle\n");
			rc = ESIF_E_INVALID_HANDLE;
			goto exit;
		}

		upMapPtr = EsifApp_GetParticipantDataMapFromHandle(appPtr, upHandle);
		if (NULL == upMapPtr) {
			ESIF_TRACE_ERROR("The app participant data was not found from participant handle\n");
			rc = ESIF_E_INVALID_HANDLE;
			goto exit;
		}

		domainPtr = EsifApp_GetDomainDataMapByHandle(upMapPtr, domainHandle);
		if (NULL == domainPtr) {
			ESIF_TRACE_ERROR("The app domain data was not found from domain handle\n");
			rc = ESIF_E_INVALID_HANDLE;
			goto exit;
		}
		ESIF_TRACE_DEBUG("Using Participant %s\n", EsifUp_GetName(upMapPtr->fUpPtr));

		rc = EsifEventMgr_RegisterEventByGuid(eventGuidPtr->buf_ptr, upMapPtr->fUpPtr->fInstance, domainPtr->fQualifierId, EsifApp_EventCallback, appPtr->fHandle);
		if (ESIF_OK != rc) {
			goto exit;
		}
	}
	break;

	default:
		ESIF_TRACE_ERROR("Unknown category type\n");
		rc = ESIF_E_INVALID_HANDLE;
		break;
	}
exit:
	return rc;
}
Ejemplo n.º 10
0
/* See EsifUpPm_InitIterator for usage */
eEsifError EsifActMgr_GetNexAction(
	ActMgrIteratorPtr iteratorPtr,
	EsifActPtr *actPtr
	)
{
	eEsifError rc = ESIF_OK;
	EsifActPtr nextActPtr = NULL;
	struct esif_link_list_node *curNodePtr = NULL;
	struct esif_link_list_node *nextNodePtr = NULL;
	EsifActMgrEntryPtr entryPtr = NULL;

	if ((NULL == actPtr) || (NULL == iteratorPtr)) {
		ESIF_TRACE_WARN("Parameter is NULL\n");
		rc = ESIF_E_PARAMETER_IS_NULL;
		goto exit;
	}

	/* Verify the iterator is initialized */
	if (iteratorPtr->marker != ACT_MGR_ITERATOR_MARKER) {
		ESIF_TRACE_WARN("Iterator invalid\n");
		rc = ESIF_E_INVALID_HANDLE;
		goto exit;
	}

	if (iteratorPtr->ref_taken) {
		EsifAct_PutRef(iteratorPtr->actPtr);
		iteratorPtr->actPtr = NULL;
		iteratorPtr->ref_taken = ESIF_FALSE;
	}

	esif_ccb_write_lock(&g_actMgr.mgrLock);

	if (g_actMgr.actions == NULL) {
		esif_ccb_write_unlock(&g_actMgr.mgrLock);
		rc = ESIF_E_UNSPECIFIED;
		goto exit;
	}

	curNodePtr = g_actMgr.actions->head_ptr;

	if (iteratorPtr->type == 0) {
		nextNodePtr = curNodePtr;
	} else {
		while (curNodePtr) {
			entryPtr = (EsifActMgrEntryPtr)curNodePtr->data_ptr;
			if (entryPtr != NULL) {
				if (entryPtr->type == iteratorPtr->type) {
					nextNodePtr = curNodePtr->next_ptr;
					break;
				}
			}
			curNodePtr = curNodePtr->next_ptr;
		}
	}

	iteratorPtr->type = 0;
	if (nextNodePtr != NULL) {
		entryPtr = (EsifActMgrEntryPtr)nextNodePtr->data_ptr;
		if (entryPtr != NULL) {
			iteratorPtr->type = entryPtr->type;
		}
	}

	esif_ccb_write_unlock(&g_actMgr.mgrLock);

	if (iteratorPtr->type != 0) {
		nextActPtr = EsifActMgr_GetAction(iteratorPtr->type, ACT_MGR_NO_UPINSTANCE);
	}

	*actPtr = nextActPtr;

	if (nextActPtr != NULL) {
		iteratorPtr->actPtr = nextActPtr;
		iteratorPtr->ref_taken = ESIF_TRUE;
	} else {
		rc = ESIF_E_ITERATION_DONE;
	}
exit:
	return rc;
}
Ejemplo n.º 11
0
static eEsifError RegisterParticipant(const EsifParticipantIfacePtr piPtr)
{
	eEsifError rc    = ESIF_OK;
	EsifUpPtr up_ptr = NULL;
	UInt8 temp = 0;
	char guid_str[ESIF_GUID_PRINT_SIZE];
	EsifString dsp_code = "";

	UNREFERENCED_PARAMETER(guid_str);

	ESIF_ASSERT(piPtr != NULL);
	ESIF_TRACE_INFO(
		"\n"
		"=======================================================\n"
		"ESIF CREATE CONJURE PARTICIPANT:\n"
		"=======================================================\n"
		"Version:        %d\n"
		"Class:          %s\n"
		"Enumerator:     %s(%u)\n"
		"Flags:          0x%08x\n"
		"Name:           %s\n"
		"Description:    %s\n"
		"Driver Name:    %s\n"
		"Device Name:    %s\n"
		"Device Path:    %s\n"
		"Object ID:      %s\n\n",
		piPtr->version,
		esif_guid_print(&piPtr->class_guid, guid_str),
		esif_participant_enum_str(piPtr->enumerator),
		piPtr->enumerator,
		piPtr->flags,
		piPtr->name,
		piPtr->desc,
		piPtr->driver_name,
		piPtr->device_name,
		piPtr->device_path,
		piPtr->object_id);

	if (EsifUpManagerDoesAvailableParticipantExistByName(piPtr->name)) {
		ESIF_TRACE_WARN("Participant %s has already existed in upper framework\n", piPtr->name);
		rc     = ESIF_E_UNSPECIFIED;
		up_ptr = NULL;
		goto exit;
	}

	ESIF_TRACE_DEBUG("Create Participant\n");
	up_ptr = EsifUpManagerCreateParticipant(eParticipantOriginUF, &temp, piPtr);
	ESIF_TRACE_DEBUG("Create Participant up_ptr %p\n", up_ptr);

	/* Assign DSP Now */
	if (NULL == up_ptr) {
		rc = ESIF_E_NO_MEMORY;
		goto exit;
	}

	dsp_code = esif_uf_dm_select_dsp(eParticipantOriginUF, piPtr);
	if (NULL == dsp_code) {
		ESIF_TRACE_ERROR("Unknown dsp name %s\n", piPtr->name);
		rc = ESIF_E_NEED_DSP;
		goto exit;
	}
	ESIF_TRACE_DEBUG("dsp_code %s\n", dsp_code);

	up_ptr->fDspPtr = esif_uf_dm_select_dsp_by_code(dsp_code);
	if (NULL == up_ptr->fDspPtr) {
		ESIF_TRACE_ERROR("Missed DSP Lookup %s\n", dsp_code);
		rc = ESIF_E_NEED_DSP;
		goto exit;
	}
	/* Report the participant to the apps */
	EsifAppMgrCreateCreateParticipantInAllApps(up_ptr);

	ESIF_TRACE_DEBUG("Hit DSP Lookup %s\n", up_ptr->fDspPtr->code_ptr);
	up_ptr = NULL;	/* Indicate the participant should not be destroyed. */

exit:

	/*
	 * If up_ptr is non-NULL at this point, indicates a failure and the
	 * participant must be disabled in the manager.  If everything is
	 * successful, up_ptr will be set to NULL above.
	 */
	if (up_ptr != NULL) {
		ESIF_TRACE_WARN("Unregister participant in UP manager due to participant data creation failure\n");
		EsifUpManagerUnregisterParticipant(eParticipantOriginUF, up_ptr);
	}
	return rc;
}