Beispiel #1
0
static eEsifError EsifActMgr_GetTypeFromPossAct_Locked(
	EsifActMgrEntryPtr entryPtr,
	enum esif_action_type *typePtr
	)
{
	eEsifError rc = ESIF_OK;
	GetIfaceFuncPtr getIfacePtr = NULL;
	EsifActIface iface = {0};

	ESIF_ASSERT(entryPtr != NULL);
	ESIF_ASSERT(typePtr != NULL);

	/* If we already have the type from a previous search, return it */
	if (entryPtr->type != 0) {
		*typePtr = entryPtr->type;
	}

	/* If we don't already have the type; load the library and get the type */
	rc = EsifActMgr_LoadAction(entryPtr, &getIfacePtr);
	if (rc != ESIF_OK) {
		goto exit;
	}

	iface.hdr.fIfaceType = eIfaceTypeAction;
	iface.hdr.fIfaceVersion = ESIF_INTERFACE_VERSION;
	iface.hdr.fIfaceSize = sizeof(iface);

	rc = getIfacePtr(&iface);
	if (ESIF_OK != rc) {
		goto exit;
	}

	/* Check EsifActIface */
	if (iface.hdr.fIfaceType != eIfaceTypeAction ||
		iface.hdr.fIfaceVersion > ESIF_ACT_FACE_VER_MAX ||
		iface.hdr.fIfaceSize != EsifActIface_Sizeof(iface.hdr.fIfaceVersion)) {
		ESIF_TRACE_ERROR("The action interface does not meet requirements\n");
		goto exit;
	}

	/* Check if this type is already available; we only allow one instance */
	rc = EsifActIface_GetType(&iface, &entryPtr->type);
	if (rc != ESIF_OK) {
		goto exit;
	}

	*typePtr = entryPtr->type;
exit:
	if (rc != ESIF_OK) {
		EsifActMgr_UnloadAction(entryPtr);
	}
	return rc;
}
Beispiel #2
0
static eEsifError EsifActMgr_CreateAction(
	EsifActMgrEntryPtr entryPtr,
	EsifActIfacePtr actIfacePtr
	)
{
	eEsifError rc = ESIF_OK;
	enum esif_action_type actType = 0;
	EsifActPtr actPtr = NULL;

	ESIF_ASSERT(entryPtr != NULL);
	ESIF_ASSERT(actIfacePtr != NULL);

	/* Check EsifActIface */
	if (actIfacePtr->hdr.fIfaceType != eIfaceTypeAction ||
		actIfacePtr->hdr.fIfaceVersion > ESIF_ACT_FACE_VER_MAX ||
		actIfacePtr->hdr.fIfaceSize != EsifActIface_Sizeof(actIfacePtr->hdr.fIfaceVersion)) {
		ESIF_TRACE_ERROR("The action interface does not meet requirements\n");
		goto exit;
	}

	/* Check if this type is already available; we only allow one instance */
	rc = EsifActIface_GetType(actIfacePtr, &actType);
	if (rc != ESIF_OK) {
		goto exit;
	}

	actPtr = EsifActMgr_GetAction(actType, ACT_MGR_NO_UPINSTANCE);
	if (actPtr != NULL) {
		EsifAct_PutRef(actPtr);
		rc = ESIF_E_ACTION_ALREADY_STARTED;
		goto exit;
	}

	rc = EsifAct_CreateAction(actIfacePtr, entryPtr->upInstance, &actPtr);
	if (rc != ESIF_OK) {
		goto exit;
	}

	entryPtr->type = actPtr->type;
	entryPtr->actCtx = actPtr->actCtx;
	entryPtr->actPtr = actPtr;
exit:
	return rc;
}
Beispiel #3
0
Bool EsifActIface_IsSupported(
		EsifActIfacePtr self
	)
{
	Bool isSupported = ESIF_TRUE;

	if (NULL == self) {
		isSupported = ESIF_FALSE;
		ESIF_TRACE_ERROR("Interface ptr is NULL\n");
		goto exit;
	}

	if (self->hdr.fIfaceType != eIfaceTypeAction ||
		self->hdr.fIfaceVersion > ESIF_ACT_FACE_VER_MAX ||
		self->hdr.fIfaceSize != EsifActIface_Sizeof(self->hdr.fIfaceVersion)) {
		isSupported = ESIF_FALSE;
		ESIF_TRACE_INFO("The action interface does not meet requirements\n");
	}
exit:
	return isSupported;
}
Beispiel #4
0
/*
 * FUNCTION DEFINITIONS
 */
eEsifError EsifAct_CreateAction(
	EsifActIfacePtr actIfacePtr,
	EsifActPtr *actPtr
	)
{
	eEsifError rc = ESIF_OK;
	EsifActPtr newActPtr = NULL;
	enum esif_action_type actionType;
	UInt16 intfcSize = 0;

	if ((NULL == actIfacePtr) || (NULL == actPtr)){
		rc = ESIF_E_PARAMETER_IS_NULL;
		goto exit;
	}

	/* Check EsifActIface */
	if (!EsifActIface_IsSupported(actIfacePtr)) {
		rc = ESIF_E_IFACE_NOT_SUPPORTED;
		goto exit;	
	}

	intfcSize = EsifActIface_Sizeof(actIfacePtr->hdr.fIfaceVersion);
	if (intfcSize != actIfacePtr->hdr.fIfaceSize) {
		rc = ESIF_E_PARAMETER_IS_OUT_OF_BOUNDS;
		goto exit;
	}

	newActPtr = esif_ccb_malloc(sizeof(*newActPtr));
	if (NULL == newActPtr) {
		rc = ESIF_E_NO_MEMORY;
		goto exit;
	}

	esif_ccb_memcpy(&newActPtr->iface, actIfacePtr, intfcSize);

	rc = EsifActIface_GetType(actIfacePtr, &actionType);
	if (rc != ESIF_OK) {
		goto exit;
	}
	newActPtr->type = actionType;

	newActPtr->refCount = 1;
	newActPtr->markedForDelete = ESIF_FALSE;

	esif_ccb_lock_init(&newActPtr->objLock);
	esif_ccb_event_init(&newActPtr->deleteEvent);

	rc = EsifAct_CallIfaceCreate(newActPtr);
	if (rc != ESIF_OK) {
		goto exit;
	}

	rc = EsifAct_RegisterEvents(newActPtr);
	if (rc != ESIF_OK) {
		goto exit;
	}

	ESIF_TRACE_DEBUG("\n"
		"Created new action:"
		"  Name   : %s\n"
		"  Desc   : %s\n"
		"  Type   : %d\n"
		"  Version: %u\n",
		EsifAct_GetName(newActPtr),
		EsifAct_GetDesc(newActPtr),
		EsifAct_GetType(newActPtr),
		EsifAct_GetVersion(newActPtr));

	*actPtr = newActPtr;
exit:
	if (rc != ESIF_OK) {
		EsifAct_DestroyAction(newActPtr);
	}
	return rc;
}