Beispiel #1
0
static eEsifError EsifApp_RegisterParticipantsWithApp(
	EsifAppPtr self
	)
{
	eEsifError rc = ESIF_OK;
	EsifUpPtr upPtr = NULL;
	UInt8 i = 0;

	ESIF_ASSERT(self != NULL);

	/* Skip 0 ESIF treats this as a participant no one else does :) */
	/* TODO:  Use iterator here.  This function shouldn't know the number of participants */
	for (i = 1; i < MAX_PARTICIPANT_ENTRY; i++) {
		upPtr = EsifUpPm_GetAvailableParticipantByInstance(i);
		if (NULL == upPtr) {
			continue;
		}
		rc = EsifAppCreateParticipant(self, upPtr);
		EsifUp_PutRef(upPtr);
		if (ESIF_OK != rc) {
			break;
		}
	}
	ESIF_TRACE_INFO("Register participants with App, status = %s\n", esif_rc_str(rc));
	return rc;
}
Beispiel #2
0
eEsifError EsifAppsEventByDomainType(
	enum esif_domain_type domainType,
	eEsifEventType eventType,
	EsifDataPtr eventData
	)
{
	u8 i     = 0;
	u8 found = ESIF_FALSE;

	for (i = 0; i < MAX_PARTICIPANT_ENTRY; i++) {
		EsifUpPtr upPtr = EsifUpPm_GetAvailableParticipantByInstance(i);
		if (NULL == upPtr) {
			continue;
		}

		if (upPtr->fMetadata.fAcpiType == domainType) {
			found = ESIF_TRUE;
			EsifUp_PutRef(upPtr);
			break;
		}

		EsifUp_PutRef(upPtr);
	}

	if (ESIF_FALSE == found) {
		return ESIF_E_NOT_FOUND;
	} else {
		return EsifEventMgr_SignalEvent(i, EVENT_MGR_DOMAIN_NA, eventType, eventData);
	}
}
Beispiel #3
0
static eEsifError ESIF_CALLCONV  EsifActIface_ExecutePrimitiveV1(
	const esif_handle_t participantHandle,	/* Pass back in calls to ESIF for the participant instance */
	const UInt16 primitiveId,
	const UInt16 domain,					/* Must Be '0D' */
	const UInt8 instance,					/* Primitive instance */
	const EsifDataPtr requestPtr,			/* Input data to the primitive */
	EsifDataPtr responsePtr					/* Output data returned by primitivie execution */
	)
{
	eEsifError rc = ESIF_OK;
	EsifUpPtr upPtr = NULL;
	EsifPrimitiveTuple tuple = {primitiveId, domain, instance};

	/* Get the participant from the handle */
	upPtr = EsifUpPm_GetAvailableParticipantByInstance((UInt8)(size_t)participantHandle);
	if (NULL == upPtr) {
		rc = ESIF_E_PARTICIPANT_NOT_FOUND;
		goto exit;
	}

	rc = EsifUp_ExecutePrimitive(upPtr, &tuple, requestPtr, responsePtr);
exit:
	EsifUp_PutRef(upPtr);
	return rc;
}
Beispiel #4
0
eEsifError ESIF_CALLCONV EsifEventMgr_UnregisterEventByType(
	eEsifEventType eventType,
	UInt8 participantId,
	UInt16 domainId,
	EVENT_OBSERVER_CALLBACK eventCallback,
	void *contextPtr
	)
{
	eEsifError rc = ESIF_OK;
	EsifFpcEventPtr fpcEventPtr = NULL;
	EsifUpPtr upPtr = NULL;
	EsifFpcEvent phonyFpcEvent = {0};

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

	if (participantId != EVENT_MGR_MATCH_ANY) {
		/* 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_GetFpcEventByType(upPtr, eventType);
		if (NULL == fpcEventPtr) {
			rc = ESIF_E_NOT_FOUND;
			goto exit;
		}
	} else {
		phonyFpcEvent.esif_event = eventType;
		fpcEventPtr = &phonyFpcEvent;
	}

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

exit:
	if (upPtr != NULL) {
		EsifUp_PutRef(upPtr);
	}
	return rc;
}
Beispiel #5
0
eEsifError ESIF_CALLCONV EsifEventMgr_UnregisterEventByGuid(
	esif_guid_t *guidPtr,
	UInt8 participantId,
	UInt16 domainId,
	EVENT_OBSERVER_CALLBACK eventCallback,
	void *contextPtr
	)
{
	eEsifError rc = ESIF_OK;
	EsifFpcEventPtr fpcEventPtr = NULL;
	EsifUpPtr upPtr = NULL;

	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;
	}

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

exit:
	if (upPtr != NULL) {
		EsifUp_PutRef(upPtr);
	}
	return rc;
}
Beispiel #6
0
static eEsifError EsifApp_DestroyParticipants(EsifAppPtr self)
{
	EsifUpPtr upPtr = NULL;
	UInt8 i = 0;

	ESIF_ASSERT(self != NULL);

	/* TODO:  Use iterator here.  This function shouldn't know the number of participants */
	for (i = 0; i < MAX_PARTICIPANT_ENTRY; i++) {
		upPtr = EsifUpPm_GetAvailableParticipantByInstance(i);
		if (NULL == upPtr) {
			continue;
		}
		EsifAppDestroyParticipant(self, upPtr);
		EsifUp_PutRef(upPtr);
	}

	ESIF_TRACE_INFO("Destroy participants in App\n");
	return ESIF_OK;
}
Beispiel #7
0
/* 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;
}
Beispiel #8
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;
}
Beispiel #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;
}
Beispiel #10
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;
}
Beispiel #11
0
static eEsifError EsifDataLogAddParticipant(char *logString, int logColumn, int isHeader)
{
	eEsifError rc = ESIF_OK;
	char qualifier_str[32] = "D0";
	u8 domain_count = 1;
	char *participantNullValue = "";
	int j = 0;
	DataLogParticipant currentParticipant = g_dataLogParticipants[logColumn];
	UInt8 participantId = currentParticipant.participantId;
	EsifUpPtr upPtr = EsifUpPm_GetAvailableParticipantByInstance(participantId);

	if (NULL == upPtr) {
		int colCounter = 0;
		/* 
		 * If we get here, the participant went offline (because the participantId was pre-validated on log start)
		 * so we must output placeholders
		 */
		for (colCounter = 0; colCounter < currentParticipant.participantNumFields; colCounter++){
			esif_ccb_sprintf_concat(MAX_LOG_LINE, logString, "%s,", participantNullValue);
		}
		goto exit;
	}
	domain_count = (u8)upPtr->fDspPtr->get_domain_count(upPtr->fDspPtr);
	for (j = 0; j < domain_count; j++) {
		UInt32 temp = 255;
		UInt32 aux0 = 255;
		UInt32 aux1 = 255;
		UInt32 hyst = 0;
		UInt32 power = 0;
		UInt32 powerLimit = 0;
		UInt32 fanspeed = 0;
	
		struct esif_fpc_domain *domain_ptr = NULL;
		struct esif_data request = { ESIF_DATA_VOID, NULL, 0, 0 };
		struct esif_data temp_response = { ESIF_DATA_TEMPERATURE, &temp, sizeof(temp), 4 };
		struct esif_data aux0_response = { ESIF_DATA_TEMPERATURE, &aux0, sizeof(aux0), 4 };
		struct esif_data aux1_response = { ESIF_DATA_TEMPERATURE, &aux1, sizeof(aux1), 4 };
		struct esif_data hyst_response = { ESIF_DATA_TEMPERATURE, &hyst, sizeof(hyst), 4 };
		struct esif_data power_response = { ESIF_DATA_POWER, &power, sizeof(power), 4 };
		struct esif_data power_limit_response = { ESIF_DATA_POWER, &powerLimit, sizeof(powerLimit), 4 };
		struct esif_data_binary_fst_package fanpkg = { 0 };
		struct esif_data fan_response = { ESIF_DATA_BINARY, &fanpkg, sizeof(fanpkg), 4 };

		domain_ptr = upPtr->fDspPtr->get_domain(upPtr->fDspPtr, j + 1);
		if (NULL == domain_ptr) {
			continue;
		}

		if (domain_ptr->capability_for_domain.capability_flags & ESIF_CAPABILITY_TEMP_STATUS) {
			if (isHeader) {
				esif_ccb_sprintf_concat(MAX_LOG_LINE, logString, "%s_D%d_temp,%s_D%d_aux0,%s_D%d_aux1,%s_D%d_hysteresis,", upPtr->fMetadata.fName, j, upPtr->fMetadata.fName, j, upPtr->fMetadata.fName, j, upPtr->fMetadata.fName, j);
			}
			else {
				rc = EsifExecutePrimitive((u8) participantId, GET_TEMPERATURE, esif_primitive_domain_str(domain_ptr->descriptor.domain, qualifier_str, 32), 255, &request, &temp_response);
				LOG_APPEND_VALUE_OR_DEFAULT(rc, temp);

				rc = EsifExecutePrimitive((u8) participantId, GET_TEMPERATURE_THRESHOLDS, esif_primitive_domain_str(domain_ptr->descriptor.domain, qualifier_str, 32), 0, &request, &aux0_response);
				LOG_APPEND_VALUE_OR_DEFAULT(rc, aux0);

				rc = EsifExecutePrimitive((u8) participantId, GET_TEMPERATURE_THRESHOLDS, esif_primitive_domain_str(domain_ptr->descriptor.domain, qualifier_str, 32), 1, &request, &aux1_response);
				LOG_APPEND_VALUE_OR_DEFAULT(rc, aux1);

				rc = EsifExecutePrimitive((u8) participantId, GET_TEMPERATURE_THRESHOLD_HYSTERESIS, esif_primitive_domain_str(domain_ptr->descriptor.domain, qualifier_str, 32), 255, &request, &hyst_response);
				LOG_APPEND_VALUE_OR_DEFAULT(rc, hyst);
			}
		}
		if (domain_ptr->capability_for_domain.capability_flags & ESIF_CAPABILITY_POWER_CONTROL) {
			if (isHeader) {
				esif_ccb_sprintf_concat(MAX_LOG_LINE, logString, "%s_D%d_power,%s_D%d_powerlimit,", upPtr->fMetadata.fName, j, upPtr->fMetadata.fName, j);
			}
			else {
				rc = EsifExecutePrimitive((u8) participantId, GET_RAPL_POWER, esif_primitive_domain_str(domain_ptr->descriptor.domain, qualifier_str, 32), 255, &request, &power_response);
				LOG_APPEND_VALUE_OR_DEFAULT(rc, power);

				rc = EsifExecutePrimitive((u8) participantId, GET_RAPL_POWER_LIMIT, esif_primitive_domain_str(domain_ptr->descriptor.domain, qualifier_str, 32), 0, &request, &power_limit_response);
				LOG_APPEND_VALUE_OR_DEFAULT(rc, powerLimit);
			}
		}
		if (domain_ptr->capability_for_domain.capability_flags & ESIF_CAPABILITY_ACTIVE_CONTROL) {
			if (isHeader) {
				esif_ccb_sprintf_concat(MAX_LOG_LINE, logString, "%s_D%d_fanspeed,", upPtr->fMetadata.fName, j);
			}
			else {
				rc = EsifExecutePrimitive((u8) participantId, GET_FAN_STATUS, esif_primitive_domain_str(domain_ptr->descriptor.domain, qualifier_str, 32), 255, &request, &fan_response);
				if (rc == ESIF_OK) {
					struct esif_data_binary_fst_package *fanPtr = (struct esif_data_binary_fst_package *)fan_response.buf_ptr;
					fanspeed = (u32) fanPtr->control.integer.value;
				}
				LOG_APPEND_VALUE_OR_DEFAULT(rc, fanspeed);
			}
		}
	}
exit:
	if (upPtr != NULL) {
		EsifUp_PutRef(upPtr);
	}

	return rc;
}
Beispiel #12
0
static eEsifError EsifDataLogValidateParticipantList(char *inParticipantList)
{
	int i = 0;
	char *participantList = NULL;
	char *participantSelect = NULL;
	char colDelims [] = ",";
	char *partTok = NULL;
	UInt8 participantId = 0;
	int participantCounter = 0;
	int totalFields = 0;
	eEsifError rc = ESIF_OK;

	for (i = 0; i < MAX_PARTICIPANT_ENTRY; i++){
		g_dataLogParticipants[i].participantId = 0;
		g_dataLogParticipants[i].participantNumFields = 0;
	}
	
	if (inParticipantList == NULL) {
		for (i = 0; i < MAX_PARTICIPANT_ENTRY; i++) {
			EsifUpPtr upPtr = NULL;

			participantId = (UInt8) i;
			upPtr = EsifUpPm_GetAvailableParticipantByInstance(participantId);

			if (NULL != upPtr) {
				int j = 0;
				int fieldCounter = 0;
				struct esif_fpc_domain *domainPtr = NULL;
				UInt8 domainCount = (u8)upPtr->fDspPtr->get_domain_count(upPtr->fDspPtr);
				DataLogParticipant nextParticipant = { 0 };

				for (j = 0; j < domainCount; j++) {
					domainPtr = upPtr->fDspPtr->get_domain(upPtr->fDspPtr, j + 1);
					if (NULL == domainPtr) {
						continue;
					}
					if (domainPtr->capability_for_domain.capability_flags & ESIF_CAPABILITY_TEMP_STATUS) {
						fieldCounter += 4;
					}
					if (domainPtr->capability_for_domain.capability_flags & ESIF_CAPABILITY_POWER_CONTROL) {
						fieldCounter += 2;
					}
					if (domainPtr->capability_for_domain.capability_flags & ESIF_CAPABILITY_ACTIVE_CONTROL) {
						fieldCounter += 1;
					}
				}
				nextParticipant.participantId = participantId;
				nextParticipant.participantNumFields = fieldCounter;
				g_dataLogParticipants[participantCounter] = nextParticipant;

				totalFields += fieldCounter;
				EsifUp_PutRef(upPtr);
				participantCounter++;
			}
		}
		goto exit;
	}

	if (esif_ccb_strlen(inParticipantList, MAX_LOG_LINE) >= 1) {

		participantList = esif_ccb_strdup(inParticipantList);
		participantSelect = esif_ccb_strtok(participantList, colDelims, &partTok);

		while (participantSelect != NULL) {
			EsifUpPtr upPtr = { 0 };

			if (participantCounter >= (sizeof(g_dataLogParticipants)/sizeof(*g_dataLogParticipants))) {
					rc = ESIF_E_NOT_SUPPORTED;
					goto exit;
			}

			if ((int)esif_atoi(participantSelect) > 0 || esif_ccb_strcmp(participantSelect, "0") == 0) {
				participantId = (UInt8) esif_atoi(participantSelect);
				upPtr = EsifUpPm_GetAvailableParticipantByInstance(participantId);
			}
			else {
				upPtr = EsifUpPm_GetAvailableParticipantByName(participantSelect);
			}
			if (NULL == upPtr) {
				rc = ESIF_E_PARTICIPANT_NOT_FOUND;
				goto exit;
			}
			else {
				int j = 0;
				int fieldCounter = 0;
				struct esif_fpc_domain *domainPtr = NULL;
				UInt8 domainCount = (u8) upPtr->fDspPtr->get_domain_count(upPtr->fDspPtr);
				DataLogParticipant nextParticipant = { 0 };
				participantId = (UInt8) upPtr->fInstance; /* redundant in the case of an id passed in, but needed for name*/

				for (j = 0; j < domainCount; j++) {
					domainPtr = upPtr->fDspPtr->get_domain(upPtr->fDspPtr, j + 1);
					if (NULL == domainPtr) {
						continue;
					}
					if (domainPtr->capability_for_domain.capability_flags & ESIF_CAPABILITY_TEMP_STATUS) {
						fieldCounter += 4;
					}
					if (domainPtr->capability_for_domain.capability_flags & ESIF_CAPABILITY_POWER_CONTROL) {
						fieldCounter += 2;
					}
					if (domainPtr->capability_for_domain.capability_flags & ESIF_CAPABILITY_ACTIVE_CONTROL) {
						fieldCounter += 1;
					}
				}
				nextParticipant.participantId = participantId;
				nextParticipant.participantNumFields = fieldCounter;
				g_dataLogParticipants[participantCounter] = nextParticipant;

				totalFields += fieldCounter;
				EsifUp_PutRef(upPtr);
				participantCounter++;
			}
			participantSelect = esif_ccb_strtok(NULL, colDelims, &partTok);
		}
	}
	else {
		for (i = 0; i < MAX_PARTICIPANT_ENTRY; i++) {
			EsifUpPtr upPtr = NULL;

			participantId = (UInt8) i;
			upPtr = EsifUpPm_GetAvailableParticipantByInstance(participantId);

			if (NULL != upPtr) {
				int j = 0;
				int fieldCounter = 0;
				struct esif_fpc_domain *domainPtr = NULL;
				UInt8 domainCount = (u8)upPtr->fDspPtr->get_domain_count(upPtr->fDspPtr);
				DataLogParticipant nextParticipant = { 0 };

				for (j = 0; j < domainCount; j++) {
					domainPtr = upPtr->fDspPtr->get_domain(upPtr->fDspPtr, j + 1);
					if (NULL == domainPtr) {
						continue;
					}
					if (domainPtr->capability_for_domain.capability_flags & ESIF_CAPABILITY_TEMP_STATUS) {
						fieldCounter += 4;
					}
					if (domainPtr->capability_for_domain.capability_flags & ESIF_CAPABILITY_POWER_CONTROL) {
						fieldCounter += 2;
					}
					if (domainPtr->capability_for_domain.capability_flags & ESIF_CAPABILITY_ACTIVE_CONTROL) {
						fieldCounter += 1;
					}
				}
				nextParticipant.participantId = participantId;
				nextParticipant.participantNumFields = fieldCounter;
				g_dataLogParticipants[participantCounter] = nextParticipant;

				totalFields += fieldCounter;
				EsifUp_PutRef(upPtr);
				participantCounter++;
			}
		}
	}
exit:
	esif_ccb_free(participantList);

	if (totalFields == 0) {
		rc = ESIF_E_NOT_SUPPORTED;
	}
	return rc;
}