Esempio n. 1
0
static eEsifError ESIF_CALLCONV ActionConfigGet(
	esif_context_t actCtx,
	EsifUpPtr upPtr,
	const EsifFpcPrimitivePtr primitivePtr,
	const EsifFpcActionPtr fpcActionPtr,
	const EsifDataPtr requestPtr,
	const EsifDataPtr responsePtr
	)
{
	eEsifError rc = ESIF_OK;
	EsifData params[2] = {0};
	EsifString replacedStrs[2] = {0};
	EsifString replacedStr = NULL;
	UInt8 i;

	UNREFERENCED_PARAMETER(actCtx);
	UNREFERENCED_PARAMETER(requestPtr);

	ESIF_ASSERT(NULL != responsePtr);
	ESIF_ASSERT(NULL != responsePtr->buf_ptr);

	rc = EsifFpcAction_GetParams(fpcActionPtr,
		params,
		sizeof(params)/sizeof(*params));
	if (ESIF_OK != rc) {
		goto exit;
	}

	for (i = 0; i < sizeof(replacedStrs) / sizeof(*replacedStrs); i++) {
		replacedStr = EsifUp_CreateTokenReplacedParamString(upPtr, primitivePtr, params[i].buf_ptr);
		if (replacedStr != NULL) {
			params[i].buf_ptr = replacedStr;
			replacedStrs[i] = replacedStr;
		}
	}

	ESIF_ASSERT(NULL != params[0].buf_ptr);
	ESIF_ASSERT(ESIF_DATA_STRING == params[0].type);

	rc = EsifConfigGet(&params[0], &params[1], responsePtr);
exit:
	for (i = 0; i < sizeof(replacedStrs) / sizeof(*replacedStrs); i++) {
		esif_ccb_free(replacedStrs[i]);
	}
	return rc;
}
Esempio n. 2
0
static eEsifError ESIF_CALLCONV ActionConfigSet(
	esif_context_t actCtx,
	EsifUpPtr upPtr,
	const EsifFpcPrimitivePtr primitivePtr,
	const EsifFpcActionPtr fpcActionPtr,
	EsifDataPtr requestPtr
	)
{
	eEsifError rc = ESIF_OK;
	esif_flags_t flags = ESIF_SERVICE_CONFIG_PERSIST;
	EsifData params[3] = {0};
	EsifString replacedStrs[2] = {0};
	EsifString replacedStr = NULL;
	UInt8 i;
	UInt8 nparams = 2;

	UNREFERENCED_PARAMETER(actCtx);

	ESIF_ASSERT(NULL != requestPtr);
	ESIF_ASSERT(NULL != requestPtr->buf_ptr);

	/* Optional 3rd Parameter = Config Flags */
	if (fpcActionPtr->param_valid[2]) {
		nparams++;
	}

	rc = EsifFpcAction_GetParams(fpcActionPtr,
		params,
		nparams);
	if (ESIF_OK != rc) {
		goto exit;
	}

	/* Extract Optional EsifConfigSet flags */
	if (nparams > 2 && params[2].type == ESIF_DATA_UINT32) {
		flags = *(UInt32 *)(params[2].buf_ptr);
	}

	for (i = 0; i < sizeof(replacedStrs) / sizeof(*replacedStrs); i++) {
		replacedStr = EsifUp_CreateTokenReplacedParamString(upPtr, primitivePtr, params[i].buf_ptr);
		if (replacedStr != NULL) {
			params[i].buf_ptr = replacedStr;
			replacedStrs[i] = replacedStr;
		}
	}

	ESIF_ASSERT(NULL != params[0].buf_ptr);
	ESIF_ASSERT(ESIF_DATA_STRING == params[0].type);

	rc = EsifConfigSet(&params[0], &params[1], flags, requestPtr);

	/*
	 * Ignore DataVault I/O Errors so DSP Overrides can be written to or cleared 
	 * from DataCache even if DV file system is read-only
	 */
	switch (rc) {
	case ESIF_E_IO_ERROR:
	case ESIF_E_IO_OPEN_FAILED:
	case ESIF_E_IO_DELETE_FAILED:
		rc = ESIF_OK;
		break;
	default:
		break;
	}

	if (ESIF_OK == rc) {
		ActionConfigSignalChangeEvents(upPtr, primitivePtr->tuple, requestPtr);
	}
exit:
	for (i = 0; i < sizeof(replacedStrs) / sizeof(*replacedStrs); i++) {
		esif_ccb_free(replacedStrs[i]);
	}
	return rc;
}
Esempio n. 3
0
static eEsifError EsifSetActionDelegateRset(
	const EsifUpDomainPtr domainPtr,
	const EsifDataPtr requestPtr)
{
	eEsifError rc = ESIF_E_PRIMITIVE_ACTION_FAILURE;
	EsifPrimitiveTupleParameter parameters = { 0 };
	EsifPrimitiveTuple tuple = { 0 };
	Bool signal_event = ESIF_FALSE;
	char domain_str[8] = { 0 };
	int j = 0;

	ESIF_ASSERT(domainPtr != NULL);
	ESIF_ASSERT(requestPtr != NULL);
	
	if (requestPtr->buf_ptr == NULL) {
		rc = ESIF_E_PARAMETER_IS_NULL;
		goto exit;
	}
	if (requestPtr->data_len != sizeof(parameters)) {
		rc = ESIF_E_REQUEST_DATA_OUT_OF_BOUNDS;
		goto exit;
	}
	
	// Convert BINARY Parameters to Primitive Tuple
	esif_ccb_memcpy(&parameters, requestPtr->buf_ptr, sizeof(parameters));
	
	ESIF_TRACE_DEBUG("CONFIG RESET: { %s (%hd), %s, %hd }\n",
		esif_primitive_str(parameters.id.integer.value),
		(u16)parameters.id.integer.value,
		esif_primitive_domain_str((u16)parameters.domain.integer.value, domain_str, sizeof(domain_str)),
		(u16)parameters.instance.integer.value
		);

	// Look up Primitive Tuple in the DSP and verify it is a valid SET primtive
	EsifDspPtr dspPtr = EsifUp_GetDsp(domainPtr->upPtr);
	if (dspPtr == NULL) {
		rc = ESIF_E_NEED_DSP;
		goto exit;
	}
	tuple.id = (u16) parameters.id.integer.value;
	tuple.domain = (u16) parameters.domain.integer.value;
	tuple.instance = (u16) parameters.instance.integer.value;
	EsifFpcPrimitivePtr primitivePtr = dspPtr->get_primitive(dspPtr, &tuple);
	if (primitivePtr == NULL) {
		rc = ESIF_E_PRIMITIVE_NOT_FOUND_IN_DSP;
		goto exit;
	}
	if (primitivePtr->operation != ESIF_PRIMITIVE_OP_SET) {
		rc = ESIF_E_INVALID_REQUEST_TYPE;
		goto exit;
	}

	// Find first CONFIG Action and Delete its Key from its DataVault
	for (j = 0; j < (int)primitivePtr->num_actions; j++) {
		EsifFpcActionPtr fpcActionPtr = dspPtr->get_action(dspPtr, primitivePtr, (u8)j);
		DataItemPtr paramDataVault = EsifFpcAction_GetParam(fpcActionPtr, (const UInt8)0);
		DataItemPtr paramKeyName = EsifFpcAction_GetParam(fpcActionPtr, (const UInt8)1);
		EsifString expandedKeyName = NULL;
		if (fpcActionPtr->type != ESIF_ACTION_CONFIG) {
			continue;
		}
		if (paramDataVault == NULL || paramKeyName == NULL || paramDataVault->data_type != ESIF_DSP_PARAMETER_TYPE_STRING || paramKeyName->data_type != ESIF_DSP_PARAMETER_TYPE_STRING) {
			rc = ESIF_E_PARAMETER_IS_OUT_OF_BOUNDS;
			goto exit;
		}
		
		// Replace "%nm%" tokens in the key name or make a copy of the key name for static keys
		expandedKeyName = EsifUp_CreateTokenReplacedParamString(domainPtr->upPtr, primitivePtr, (StringPtr)paramKeyName->data);
		if (expandedKeyName == NULL) {
			expandedKeyName = esif_ccb_strdup((StringPtr)paramKeyName->data);
			if (expandedKeyName == NULL) {
				rc = ESIF_E_NO_MEMORY;
				goto exit;
			}
		}

		// Valid SET CONFIG Primitive found with valid DV/Key Name; Delete the associated Key from the DataVault
		EsifDataPtr data_nspace = EsifData_CreateAs(ESIF_DATA_STRING, (StringPtr)paramDataVault->data, 0, ESIFAUTOLEN);
		EsifDataPtr data_key    = EsifData_CreateAs(ESIF_DATA_STRING, expandedKeyName, 0, ESIFAUTOLEN);

		// Do not signal an Event if Key does not exist in DataVault
		if (DataBank_KeyExists(g_DataBankMgr, (StringPtr)paramDataVault->data, expandedKeyName) == ESIF_FALSE) {
			rc = ESIF_OK;
		}
		else if (data_nspace == NULL || data_key == NULL) {
			rc = ESIF_E_NO_MEMORY;
		}
		else {
			// Delete Existing Key from DataVault
			rc = EsifConfigDelete(data_nspace, data_key);
			if (rc == ESIF_OK) {
				signal_event = ESIF_TRUE;
			}

			ESIF_TRACE_DEBUG("CONFIG RESET: config delete @%s %s [rc=%s (%d)]\n",
				(StringPtr)data_nspace->buf_ptr,
				(StringPtr)data_key->buf_ptr,
				esif_rc_str(rc),
				rc
				);
		}

		// Signal any Event(s) associated with this SET Primitive
		if (signal_event) {
			EsifActConfigSignalChangeEvents(domainPtr->upPtr, tuple, NULL);
		}

		EsifData_Destroy(data_nspace);
		EsifData_Destroy(data_key);
		esif_ccb_free(expandedKeyName);
		break;
	}
	if (j >= (int)primitivePtr->num_actions) {
		rc = ESIF_E_UNSUPPORTED_ACTION_TYPE;
	}

exit:
	return rc;
}