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
/*
 * If you pass in a NULL pointer, it will return 0.
 */
enum esif_action_type EsifAct_GetType(
	EsifActPtr self
	)
{
	eEsifError rc = ESIF_OK;
	enum esif_action_type type = 0;

	if (NULL == self) {
		goto exit;
	}

	rc = EsifActIface_GetType(&self->iface, &type);
	if (rc != ESIF_OK) {
		type = 0;
	}
exit:
	return type;
}
Beispiel #3
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 #4
0
eEsifError EsifActMgr_UnregisterAction(
	EsifActIfacePtr actIfacePtr
	)
{
	eEsifError rc = ESIF_OK;
	enum esif_action_type actType = 0;
	struct esif_link_list_node *nodePtr = NULL;
	EsifActMgrEntryPtr entryPtr = NULL;

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

	rc = EsifActIface_GetType(actIfacePtr, &actType);
	if (rc != ESIF_OK) {
		goto exit;
	}
	
	esif_ccb_write_lock(&g_actMgr.mgrLock);

	entryPtr = EsifActMgr_GetActionEntry_Locked(actType);
	if (NULL == entryPtr) {
		esif_ccb_write_unlock(&g_actMgr.mgrLock);
		rc = ESIF_E_NOT_FOUND;
		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);
exit:
	return rc;
}
Beispiel #5
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;
}