Example #1
0
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;
}
Example #2
0
eEsifError ESIF_CALLCONV EsifEventMgr_RegisterEventByGuid(
	esif_guid_t *guidPtr,
	UInt8 participantId,
	UInt16 domainId,
	EVENT_OBSERVER_CALLBACK eventCallback,
	void *contextPtr
	)
{
	eEsifError rc = ESIF_OK;
	EsifFpcEventPtr fpcEventPtr = NULL;
	EsifUpPtr upPtr = NULL;
	char guidStr[ESIF_GUID_PRINT_SIZE];

	UNREFERENCED_PARAMETER(guidStr);

	if((NULL == guidPtr) || (NULL == eventCallback)) {
		rc = ESIF_E_PARAMETER_IS_NULL;
		goto exit;
	}

	/* Find Our Participant */
	upPtr = EsifUpPm_GetAvailableParticipantByInstance(participantId);
	if (NULL == upPtr) {
		rc = ESIF_E_PARTICIPANT_NOT_FOUND;
		goto exit;
	}

	/* Find the event associated with the participant */
	fpcEventPtr = EsifUp_GetFpcEventByGuid(upPtr, guidPtr);
	if (NULL == fpcEventPtr) {
		rc = ESIF_E_EVENT_NOT_FOUND;
		goto exit;
	}

	ESIF_TRACE_DEBUG(
		"Registering event\n"
		"  Alias: %s\n"
		"  GUID: %s\n"
		"  Type: %s(%d)\n"
		"  Data: %s(%d)\n"
		"  Key: %s\n"
		"  Group: %s\n",
		fpcEventPtr->event_name,
		esif_guid_print((esif_guid_t *)fpcEventPtr->event_guid, guidStr),
		esif_event_type_str(fpcEventPtr->esif_event), fpcEventPtr->esif_event,
		esif_data_type_str(fpcEventPtr->esif_group_data_type), fpcEventPtr->esif_group_data_type,
		esif_guid_print((esif_guid_t *)fpcEventPtr->event_key, guidStr),
		esif_event_group_enum_str(fpcEventPtr->esif_group));

	rc = EsifEventMgr_AddEntry(
		fpcEventPtr,
		participantId,
		domainId,
		eventCallback,
		contextPtr);

exit:
	if (upPtr != NULL) {
		EsifUp_PutRef(upPtr);
	}
	return rc;
}
Example #3
0
/* Event handler for events registered for by the application */
static eEsifError ESIF_CALLCONV EsifApp_EventCallback(
	void *appHandle,
	UInt8 participantId,
	UInt16 domainId,
	EsifFpcEventPtr fpcEventPtr,
	EsifDataPtr eventDataPtr
	)
{
	eEsifError rc = ESIF_OK;
	EsifAppPtr appPtr = NULL;
	EsifUpPtr upPtr = NULL;
	AppParticipantDataMapPtr upDataMapPtr = NULL;
	void *participantHandle = NULL;
	void *domainHandle = NULL;
	EsifData dataGuid     = {ESIF_DATA_GUID, NULL, sizeof(fpcEventPtr->event_guid), sizeof(fpcEventPtr->event_guid)};
	char guidStr[ESIF_GUID_PRINT_SIZE];

	UNREFERENCED_PARAMETER(guidStr);
	UNREFERENCED_PARAMETER(domainId);

	if (NULL == fpcEventPtr) {
		rc = ESIF_E_PARAMETER_IS_NULL;
		goto exit;
	}

	appPtr = GetAppFromHandle(appHandle);
	if (appPtr == NULL) {
		rc = ESIF_E_UNSPECIFIED;
		goto exit;
	}
	if (NULL == appPtr->fInterface.fAppEventFuncPtr) {
		rc = ESIF_E_UNSPECIFIED;
		goto exit;
	}

	dataGuid.buf_ptr = &fpcEventPtr->event_guid;

	ESIF_TRACE_DEBUG("\n");

	if (ESIF_INSTANCE_LF == participantId) {

		/* Find Our Participant 0 */
		upPtr = EsifUpPm_GetAvailableParticipantByInstance(ESIF_INSTANCE_LF);
		if (NULL == upPtr) {
			rc = ESIF_E_UNSPECIFIED;
			goto exit;
		}
		ESIF_TRACE_DEBUG("Using Participant %s\n", EsifUp_GetName(upPtr));
		ESIF_TRACE_DEBUG("Ring Manager Door Bell:\n");

		EsifUp_PutRef(upPtr);
	} else {
		upDataMapPtr = EsifApp_GetParticipantDataMapFromInstance(appPtr, participantId);
		if (NULL == upDataMapPtr) {
			rc = ESIF_E_PARTICIPANT_NOT_FOUND;
			goto exit;
		}

		participantHandle = upDataMapPtr->fAppParticipantHandle;

		ESIF_TRACE_DEBUG("Using Participant %s\n", EsifUp_GetName(upDataMapPtr->fUpPtr));
		ESIF_TRACE_DEBUG("Ring Participant Door Bell:\n");
	}

	ESIF_TRACE_DEBUG(
		"  appHandle:         %p\n"
		"  participantHandle: %p\n"
		"  domainHandle:      %p\n"
		"  eventGuid:         %s\n",
		appHandle,
		participantHandle,
		domainHandle,
		esif_guid_print((esif_guid_t *)dataGuid.buf_ptr, guidStr));

	rc = appPtr->fInterface.fAppEventFuncPtr(
			appHandle,
			participantHandle,
			NULL,
			eventDataPtr,
			&dataGuid);
exit:
	return rc;
}
Example #4
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;
}
Example #5
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;
}