Example #1
0
static void *ESIF_CALLCONV EsifEventMgr_EventQueueThread(void *ctxPtr)
{
	EsifEventQueueItemPtr queueEventPtr = NULL;

	UNREFERENCED_PARAMETER(ctxPtr);

	while(!g_EsifEventMgr.eventQueueExitFlag) {
		queueEventPtr = esif_queue_pull(g_EsifEventMgr.eventQueuePtr);

		if (NULL == queueEventPtr) {
			continue;
		}

		ESIF_TRACE_INFO("Dequeuing %s event for Part. %u Dom. 0x%04X\n",
			esif_event_type_str(queueEventPtr->eventType),
			queueEventPtr->participantId,
			queueEventPtr->domainId);

		EsifEventMgr_ProcessEvent(queueEventPtr->participantId,
			queueEventPtr->domainId,
			queueEventPtr->eventType,
			&queueEventPtr->eventData);

		esif_ccb_free(queueEventPtr->eventData.buf_ptr);
		esif_ccb_free(queueEventPtr);
	}
	return 0;
}
Example #2
0
void EsifEvent_SignalIpcEvent(struct esif_ipc_event *eventHdrPtr)
{
#ifdef ESIF_FEAT_OPT_ACTION_SYSFS
	UNREFERENCED_PARAMETER(domainStr);
#else
	eEsifError rc = ESIF_OK;
	EsifData binaryData = {ESIF_DATA_BINARY, NULL, 0, 0};
	EsifData voidData = {ESIF_DATA_VOID, NULL, 0};
	EsifDataPtr dataPtr = NULL;
	UInt8 participantId;
	char domainStr[8] = "";
	esif_ccb_time_t now;

	UNREFERENCED_PARAMETER(domainStr);

	esif_ccb_system_time(&now);

	ESIF_TRACE_DEBUG(
		"\n"
		"===================================================\n"
		"ESIF IPC EVENT HEADER: Timestamp: %llu\n"
		"                         Latency: %u msec\n"
		"===================================================\n"
		"Version:     %d\n"
		"Type:        %s(%d)\n"
		"ID:          %llu\n"
		"Timestamp:   %llu\n"
		"Priority:    %s(%d)\n"
		"Source:      %d\n"
		"Dest:        %d\n"
		"Dest Domain: %s(%04X)\n"
		"Data Size:   %u\n\n",
		(u64)now,
		(int)(now - eventHdrPtr->timestamp),
		eventHdrPtr->version,
		esif_event_type_str(eventHdrPtr->type),
		eventHdrPtr->type,
		eventHdrPtr->id,
		eventHdrPtr->timestamp,
		esif_event_priority_str(eventHdrPtr->priority),
		eventHdrPtr->priority,
		eventHdrPtr->src_id,
		eventHdrPtr->dst_id,
		esif_primitive_domain_str(eventHdrPtr->dst_domain_id, domainStr, 8),
		eventHdrPtr->dst_domain_id,
		eventHdrPtr->data_len);

	dataPtr = &voidData;
	if (eventHdrPtr->data_len > 0) {
		binaryData.buf_ptr = eventHdrPtr + 1;
		binaryData.buf_len = eventHdrPtr->data_len;
		binaryData.data_len = eventHdrPtr->data_len;
		dataPtr = &binaryData;
	}

	/*
	* If the mapping function fails, we assume that the participant hasn't been created
	* In that case, we use 0 for the participant as the real ID will be gathered from
	* the creation data.
	*/
	participantId = eventHdrPtr->dst_id;
	if (eventHdrPtr->dst_id == ESIF_INSTANCE_UF) {
		rc = EsifUpPm_MapLpidToParticipantInstance(eventHdrPtr->src_id, &participantId);
		if (rc != ESIF_OK) {
			participantId = 0;
		}
	}

	// Best Effort Delivery
	EsifEventMgr_SignalEvent(participantId, eventHdrPtr->dst_domain_id, eventHdrPtr->type, dataPtr);

	return;
#endif
}
Example #3
0
eEsifError ESIF_CALLCONV EsifEventMgr_SignalEvent(
	UInt8 participantId,
	UInt16 domainId,
	eEsifEventType eventType,
	const EsifDataPtr eventDataPtr
	)
{
	eEsifError rc = ESIF_OK;
	EsifEventQueueItemPtr queueEventPtr = NULL;
	EsifDataPtr queueDataPtr = NULL;

	if (NULL == g_EsifEventMgr.eventQueuePtr) { /* Should never happen */
		rc = ESIF_E_UNSPECIFIED;
		goto exit;
	}

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

	if ((eventDataPtr != NULL) &&
	    (eventDataPtr->buf_ptr != NULL) && 
	    (eventDataPtr->buf_len > 0) &&
	    (eventDataPtr->data_len > 0) &&
	    (eventDataPtr->buf_len >= eventDataPtr->data_len)) {

		queueDataPtr = esif_ccb_malloc(eventDataPtr->data_len);
		if (NULL == queueDataPtr) {
			rc = ESIF_E_NO_MEMORY;
			goto exit;
		}

		esif_ccb_memcpy(queueDataPtr, eventDataPtr->buf_ptr, eventDataPtr->data_len);

		queueEventPtr->eventData.type = eventDataPtr->type;
		queueEventPtr->eventData.buf_ptr = queueDataPtr;
		queueEventPtr->eventData.buf_len = eventDataPtr->data_len;
		queueEventPtr->eventData.data_len = eventDataPtr->data_len;
	}

	queueEventPtr->participantId = participantId;
	queueEventPtr->domainId = domainId;
	queueEventPtr->eventType = eventType;

	ESIF_TRACE_INFO("Queuing %s event for Part. %u Dom. 0x%04X\n",
		esif_event_type_str(eventType),
		participantId,
		domainId);

	rc = esif_queue_enqueue(g_EsifEventMgr.eventQueuePtr, queueEventPtr);
	if (rc != ESIF_OK) {
		goto exit;
	}

exit:
	if (rc != ESIF_OK) {
		esif_ccb_free(queueEventPtr);
		esif_ccb_free(queueDataPtr);

	}
	return rc;
}
Example #4
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 #5
0
static eEsifError EsifEventMgr_ProcessEvent(
	UInt8 participantId,
	UInt16 domainId,
	eEsifEventType eventType,
	EsifDataPtr eventDataPtr
	)
{
	eEsifError rc = ESIF_OK;
	EsifLinkListPtr listPtr = NULL;
	EsifLinkListNodePtr nodePtr = NULL;
	EsifLinkListNodePtr nextNodePtr = NULL;
	EventMgrEntryPtr entryPtr = NULL;
	char domain_str[8] = "";
	atomic_t refCount = 0;
	UInt8 shouldDumpGarbage = ESIF_FALSE;

	UNREFERENCED_PARAMETER(domain_str);

	if (NULL == eventDataPtr) {
		ESIF_TRACE_DEBUG("APPLICATION_EVENT_NO_DATA:\n"
			"  ParticipantID: %u\n"
			"  Domain:        %s(%04X)\n"
			"  EventType:     %s(%d)\n",
			participantId,
			esif_primitive_domain_str(domainId, domain_str, sizeof(domain_str)),
			domainId,
			esif_event_type_str(eventType), eventType);
	} else {
		ESIF_TRACE_DEBUG("APPLICATION_EVENT\n"
						 "  ParticipantID: %u\n"
						 "  Domain:        %s(%04X)\n"
						 "  EventType:     %s(%d)\n"
						 "  EventDataType: %s(%d)\n"
						 "  EventData:     %p\n"
						 "    buf_ptr      %p\n"
						 "    buf_len      %d\n"
						 "    data_len     %d\n",
						 participantId,
						 esif_primitive_domain_str(domainId, domain_str, 8),
						 domainId,
						 esif_event_type_str(eventType), eventType,
						 esif_data_type_str(eventDataPtr->type), eventDataPtr->type,
						 eventDataPtr,
						 eventDataPtr->buf_ptr, eventDataPtr->buf_len, eventDataPtr->data_len
						 );

		if ((ESIF_DATA_STRING == eventDataPtr->type) && (NULL != eventDataPtr->buf_ptr)) {
			ESIF_TRACE_DEBUG(
				"  Data Length:   %d\n"
				"  Data:          %s\n",
				eventDataPtr->data_len,
				(EsifString)eventDataPtr->buf_ptr);
		}
	}

	esif_ccb_write_lock(&g_EsifEventMgr.listLock);

	listPtr = g_EsifEventMgr.observerLists[(unsigned)eventType % NUM_EVENT_LISTS];
	if(NULL == listPtr) {
		rc = ESIF_E_UNSPECIFIED;
		esif_ccb_write_unlock(&g_EsifEventMgr.listLock);
		goto exit;
	}

	nodePtr = listPtr->head_ptr;
	while (NULL != nodePtr) {
		nextNodePtr = nodePtr->next_ptr;

		entryPtr = (EventMgrEntryPtr)nodePtr->data_ptr;
		ESIF_ASSERT(entryPtr != NULL);

		if ((eventType == entryPtr->fpcEvent.esif_event) &&
			((entryPtr->participantId == participantId) || (entryPtr->participantId == EVENT_MGR_MATCH_ANY)) &&
			((entryPtr->domainId == domainId) || (entryPtr->domainId == EVENT_MGR_MATCH_ANY) || (domainId == EVENT_MGR_DOMAIN_NA)) &&
			(entryPtr->refCount > 0)) {

			/*
			 * Increment the reference count so that the node is not removed while in use,
			 * then release the lock so that we avoid a deadlock condition
			 */
			atomic_inc(&entryPtr->refCount);
			esif_ccb_write_unlock(&g_EsifEventMgr.listLock);

			entryPtr->callback(entryPtr->contextPtr,
				participantId,
				domainId,
				&entryPtr->fpcEvent,
				eventDataPtr);

			/* 
			 * Get the lock back and decrement the reference count.  Remove the node now
			 * if the reference count is 0
			 */
			esif_ccb_write_lock(&g_EsifEventMgr.listLock);

			nextNodePtr = nodePtr->next_ptr;

			refCount = atomic_dec(&entryPtr->refCount);
			if (refCount <= 0) {
				EsifEventMgr_MoveEntryToGarbage(entryPtr);
				esif_link_list_node_remove(listPtr, nodePtr);
				shouldDumpGarbage = ESIF_TRUE;
			}
		}
		nodePtr = nextNodePtr;
	}

	esif_ccb_write_unlock(&g_EsifEventMgr.listLock);

	if (shouldDumpGarbage) {
		EsifEventMgr_DumpGarbage();
	}

exit:
	return rc;
}
Example #6
0
eEsifError esif_fpc_load(
	EsifFpcPtr fpcPtr,
	EsifDspPtr dspPtr
	)
{
	eEsifError rc = ESIF_OK;
	EsifFpcDomainPtr domainPtr;
	EsifFpcPrimitivePtr primitivePtr;
	EsifFpcAlgorithmPtr algoPtr;
	EsifFpcEventPtr eventPtr;
	unsigned long offset = 0;
	UInt8 *basePtr    = (UInt8 *)fpcPtr;
	UInt32 numPrim    = 0;
	UInt32 i;
	UInt32 j;

	if ((fpcPtr == NULL) || (dspPtr == NULL))
	{
		ESIF_TRACE_ERROR("The fpc pointer or dsp pointer is NULL\n");
		rc = ESIF_E_PARAMETER_IS_NULL;
		goto exit;
	}

	if (fpcPtr->number_of_domains < 1) {
		ESIF_TRACE_WARN("No domain error, number_of_domain = %d (less than 1)\n",
			fpcPtr->number_of_domains);
		rc = ESIF_E_PARAMETER_IS_NULL;
		goto exit;
	}
	dspPtr->domain_count = &fpcPtr->number_of_domains;

	/* Allocate Hash and List. Hash Size 31 Is Hard-Coded And Chosen By DSP Compiler */
	dspPtr->ht_ptr     = esif_ht_create(ESIF_DSP_HASHTABLE_SIZE);
	dspPtr->algo_ptr   = esif_link_list_create();
	dspPtr->domain_ptr = esif_link_list_create();
	dspPtr->cap_ptr    = esif_link_list_create();
	dspPtr->evt_ptr    = esif_link_list_create();

	if (!dspPtr->ht_ptr || !dspPtr->algo_ptr || !dspPtr->domain_ptr || !dspPtr->cap_ptr || !dspPtr->evt_ptr) {
		ESIF_TRACE_ERROR("Fail to allocate linked list or hash table\n");
		rc = ESIF_E_NO_MEMORY;
		goto exit;
	}

	ESIF_TRACE_DEBUG("<fpc @ %p> FPC name '%s' ver %x,%x desc '%s' size %u num_domains %d num_algorithms %d num_events %d",
					 fpcPtr,
					 fpcPtr->header.name,
					 fpcPtr->header.ver_major,
					 fpcPtr->header.ver_minor,
					 fpcPtr->header.description,
					 fpcPtr->size,
					 fpcPtr->number_of_domains,
					 fpcPtr->number_of_algorithms,
					 fpcPtr->number_of_events);

	/* First Domain, Ok To Have Zero Primitive Of A Domain */
	domainPtr = (EsifFpcDomainPtr)(fpcPtr + 1);
	for (i = 0; i < fpcPtr->number_of_domains; i++) {
		offset = (unsigned long)((UInt8 *)domainPtr - basePtr);
		ESIF_TRACE_DEBUG("<%04lu> Domain[%d] name %s size %d num_of_primitives %d  "
						 "num_of_capabilites %u (0x%x)",
						 offset, i, domainPtr->descriptor.name, domainPtr->size,
						 domainPtr->number_of_primitives,
						 domainPtr->capability_for_domain.number_of_capability_flags,
						 domainPtr->capability_for_domain.capability_flags);

		/* Insert Domain Into Linked List */
		rc = dspPtr->insert_domain(dspPtr, domainPtr);
		if (ESIF_OK != rc) {
			ESIF_TRACE_ERROR("Fail to insert domain #%d\n", i);
			goto exit;
		}

		/* Capability */
		for (j = 0; j < domainPtr->capability_for_domain.number_of_capability_flags; j++) {
			offset = (unsigned long)(((UInt8 *)&domainPtr->capability_for_domain) - basePtr);
			ESIF_TRACE_DEBUG("<%04lu> Capability[%d] 0x%x", offset, j,
							 domainPtr->capability_for_domain.capability_mask[j]);
		}

		/* First Primtive */
		primitivePtr = (EsifFpcPrimitivePtr)(domainPtr + 1);
		for (j = 0; j < domainPtr->number_of_primitives; j++, numPrim++) {
			offset = (unsigned long)(((UInt8 *)primitivePtr) - basePtr);
			ESIF_TRACE_DEBUG("<%04lu> Primitive[%03d]: size %3d tuple_id <%03u %03u %03u> "
							 "operation %u(%s) req_type %u(%s) res_type %u(%s) num_actions %u",
							 offset, j,
							 primitivePtr->size,
							 primitivePtr->tuple.id,
							 primitivePtr->tuple.domain,
							 primitivePtr->tuple.instance,
							 primitivePtr->operation,
							 esif_primitive_opcode_str(primitivePtr->operation),
							 primitivePtr->request_type,
							 esif_data_type_str(primitivePtr->request_type),
							 primitivePtr->result_type,
							 esif_data_type_str(primitivePtr->result_type),
							 primitivePtr->num_actions);
			/* Insert Primitive Into Hash */
			rc = dspPtr->insert_primitive(dspPtr, primitivePtr);
			if (ESIF_OK != rc) {
				ESIF_TRACE_ERROR("Fail to insert primitive (id = %d)\n", primitivePtr->tuple.id);
				goto exit;
			}
			/* Next Primitive */
			primitivePtr = (EsifFpcPrimitivePtr)((UInt8 *)primitivePtr + primitivePtr->size);
		}
		/* Next Domain */
		domainPtr = (EsifFpcDomainPtr)((UInt8 *)domainPtr + domainPtr->size);
	}

	/* First Algorithm (Laid After The Last Domain) */
	algoPtr = (EsifFpcAlgorithmPtr)domainPtr;
	for (i = 0; i < fpcPtr->number_of_algorithms; i++) {
		offset = (unsigned long)((UInt8 *)algoPtr - basePtr);
		ESIF_TRACE_DEBUG("<%04lu> Algorithm[%03d]:  action_type %u(%s) temp_xform %u "
						 "tempC1 %u percent_xform %u size %u",
						 offset, i,
						 algoPtr->action_type,
						 esif_action_type_str(algoPtr->action_type),
						 algoPtr->temp_xform,
						 algoPtr->tempC1,
						 algoPtr->percent_xform,
						 algoPtr->size);

		/* Insert Algorithm Into Linked List */
		rc = dspPtr->insert_algorithm(dspPtr, algoPtr);
		if (ESIF_OK != rc) {
			ESIF_TRACE_ERROR("Fail to insert algorithm - %s\n", esif_action_type_str(algoPtr->action_type));
			goto exit;
		}

		/* Next Algorithm */
		algoPtr = (EsifFpcAlgorithmPtr)(algoPtr + 1);
	}

	/* First Event (Laid After The Last Algorithm) */
	eventPtr = (EsifFpcEventPtr)algoPtr;
	for (i = 0; i < fpcPtr->number_of_events; i++) {
		offset = (unsigned long)((UInt8 *)eventPtr - basePtr);
		ESIF_TRACE_DEBUG("<%04lu> Event [%03d] type %s(%d)\n",
						 offset, i, esif_event_type_str(eventPtr->esif_event), eventPtr->esif_event);

		/* Insert Algorithm Into Linked List */
		rc = dspPtr->insert_event(dspPtr, eventPtr);
		if (ESIF_OK != rc) {
			ESIF_TRACE_ERROR("Fail to insert event - %s\n", esif_event_type_str(eventPtr->esif_event));
			goto exit;
		}

		/* Next Event */
		eventPtr = (EsifFpcEventPtr)(eventPtr + 1);
	}

exit:
	if (fpcPtr != NULL) {
		ESIF_TRACE_DEBUG("%u domains, %u primitives and %u algorithms %u events inserted! status %s",
						 fpcPtr->number_of_domains, numPrim, fpcPtr->number_of_algorithms, fpcPtr->number_of_events,
						 esif_rc_str(rc));
	}
	return rc;
}
Example #7
0
/* Documented In Header */
struct esif_event *esif_event_allocate(
	const enum esif_event_type type,
	const u16 size,
	const enum esif_event_priority priority,
	const u8 src,
	const u8 dst,
	const u16 dst_domain_id,
	const void *data_ptr
	)
{
	u16 new_size = size + sizeof(struct esif_event);
	struct esif_event *event_ptr = NULL;
	event_ptr = esif_ccb_memtype_zalloc(ESIF_MEMTYPE_TYPE_EVENT, new_size);

	if (event_ptr) {
		event_ptr->version       = ESIF_EVENT_VERSION;
		event_ptr->size          = new_size;
		event_ptr->type          = type;
		event_ptr->priority      = priority;
		event_ptr->src           = src;
		event_ptr->dst           = dst;
		event_ptr->dst_domain_id = dst_domain_id;
		event_ptr->data_size     = size;

		/*
		 *  Assign Function Pointers If Any
		 */
#ifdef ESIF_EVENT_DEBUG
		event_ptr->get_type_str     = esif_event_type_str;
		event_ptr->get_priority_str = esif_event_priority_str;
		event_ptr->dump = esif_dump_event;
#endif

		/*
		** Transaction ID
		*/
		esif_ccb_write_lock(&g_event_lock);
		event_ptr->id = g_event_transaction_id++;
		esif_ccb_write_unlock(&g_event_lock);

		/*
		** Time Stamp
		*/
		esif_ccb_system_time(&event_ptr->timestamp);

		/*
		** Make A Copy Of The Data To Make Sure It Is Contigous
		** In The Buffer
		*/
		if (NULL != data_ptr)
			esif_ccb_memcpy((event_ptr + 1), data_ptr, size);

		ESIF_TRACE_DYN_EVENT("%s: buf %p bytes %d\n",
				     ESIF_FUNC,
				     event_ptr,
				     new_size);
		ESIF_TRACE_DYN_DECODE("Version:     %d\n"
				      "Type:        %s(%d)\n"
				      "ID:          %llu\n"
				      "Timestamp:   %llu\n"
				      "Priority:    %s(%d)\n"
				      "Source:      %d\n"
				      "Destination: %d\n"
				      "Data Size: %d\n",
				      event_ptr->version,
				      esif_event_type_str(event_ptr->type),
				      event_ptr->type,
				      event_ptr->id,
				      (u64)event_ptr->timestamp,
				      esif_event_priority_str(
					event_ptr->priority),
				      event_ptr->priority,
				      event_ptr->src,
				      event_ptr->dst,
				      event_ptr->data_size);
	}
	return event_ptr;
}
Example #8
0
/* Assumes hash table has already been created */
static enum esif_rc esif_cpc_to_dsp(struct esif_lp_dsp *dsp_ptr)
{
	struct esif_lp_cpc *cpc_ptr = dsp_ptr->cpc_ptr;
	struct esif_cpc_primitive *primitive_ptr = NULL;
	struct esif_cpc_algorithm *algorithm_ptr;
	struct esif_cpc_event *event_ptr;
	struct domain *domain_ptr;
	enum esif_rc rc = ESIF_OK;
	u32 i;
	u8 *base_ptr;
	u64 offset;

	base_ptr = (u8 *)cpc_ptr;
	dsp_ptr->code_ptr         = (esif_string)cpc_ptr->header.code;

	dsp_ptr->domain_count_ptr = (u8 *)&cpc_ptr->number_of_domains;
	dsp_ptr->ver_major_ptr    = (u8 *)&cpc_ptr->header.ver_major;
	dsp_ptr->ver_minor_ptr    = (u8 *)&cpc_ptr->header.ver_minor;
	dsp_ptr->capability_ptr   = (esif_flags_t *)
					&cpc_ptr->header.cpc.capability;

	ESIF_TRACE_DYN_CPC(
		"%s: <cpc @ %p> CPC name '%s' size %d num_primitives %u, num_algorithms %u, num_domains %u\n",
		ESIF_FUNC,
		cpc_ptr,
		cpc_ptr->header.code,
		cpc_ptr->size,
		cpc_ptr->number_of_basic_primitives,
		cpc_ptr->number_of_algorithms,
		*dsp_ptr->domain_count_ptr);

	/* 1. Insert All Primitives Into Hash */
	/* Locate First Primitive Laid After CPC Struct */
	primitive_ptr =
		(struct esif_cpc_primitive *)((u8 *)cpc_ptr +
					     sizeof(struct esif_lp_cpc));
	for (i = 0; i < cpc_ptr->number_of_basic_primitives; i++) {
		offset = (u64)((u8 *)primitive_ptr - base_ptr);
		ESIF_TRACE_DYN_CPC(
			"<%06llu> Primitive[%03d]: size %03d tuple <%03u %03u %03u> operation %u(%s) num_actions %d\n",
				   offset,
				   i,
				   primitive_ptr->size,
				   primitive_ptr->tuple.id,
				   primitive_ptr->tuple.domain,
				   primitive_ptr->tuple.instance,
				   primitive_ptr->operation,
				   esif_primitive_opcode_str(
					   (enum esif_primitive_opcode)
					   primitive_ptr->operation),
				   primitive_ptr->number_of_actions);

		/* Must Be ESIF Primitive Not CPC Primitive Format */
		rc = dsp_ptr->insert_primitive(dsp_ptr, primitive_ptr);
		if (ESIF_OK != rc)
			goto exit;

		/* Primitives Have Varaible Length Due To Number Of Actions */
		primitive_ptr =
			(struct esif_cpc_primitive *)((u8 *)primitive_ptr +
						     primitive_ptr->size);
	}

	/* 2. Insert All Algorithms Into Linked List */
	/* First Algorithm Laid After the Last Primitive */
	algorithm_ptr = (struct esif_cpc_algorithm *)primitive_ptr;
	for (i = 0; i < cpc_ptr->number_of_algorithms; i++) {
		offset = (u64)((u8 *)algorithm_ptr - base_ptr);
		ESIF_TRACE_DYN_CPC("<%06llu> Algorithm[%3d]: action_type %u(%s) temp_xform %u tempC1 %u tempC2 %u size %u\n",
				   offset,
				   i,
				   algorithm_ptr->action_type,
				   esif_action_type_str(
					   (enum esif_action_type)algorithm_ptr
					   ->action_type),
				   algorithm_ptr->temp_xform,
				   algorithm_ptr->tempC1,
				   algorithm_ptr->tempC2,
				   algorithm_ptr->size);

		rc = dsp_ptr->insert_algorithm(dsp_ptr, algorithm_ptr);
		if (ESIF_OK != rc)
			goto exit;

		/* Next Algorithm. Algorithms Are Fix-Sized */
		algorithm_ptr++;
	}

	/* Truncate any unsupported domain conunts */
	if (*dsp_ptr->domain_count_ptr > ESIF_DOMAIN_MAX)
		*dsp_ptr->domain_count_ptr = ESIF_DOMAIN_MAX;

	/* Domains are contained in an array one entry per domain */
	if (*dsp_ptr->domain_count_ptr > 0) {
		dsp_ptr->domains_ptr = (struct domain *)algorithm_ptr;
		ESIF_TRACE_DYN_CPC("%s: First DWORD %08x\n",
				   ESIF_FUNC,
				   *(u32 *)dsp_ptr->domains_ptr);
	}

	/* Domain */
	domain_ptr = (struct domain *)algorithm_ptr;
	for (i = 0; i < cpc_ptr->number_of_domains; i++) {
		offset = (u64)((u8 *)domain_ptr - base_ptr);
		ESIF_TRACE_DYN_CPC("<%06llu> domain size %d name %s\n",
				   offset,
				   domain_ptr->size,
				   domain_ptr->descriptor.name);
		domain_ptr =
			(struct domain *)((u8 *)domain_ptr + domain_ptr->size);
	}

	/* Event */
	event_ptr = (struct esif_cpc_event *)domain_ptr;
	for (i = 0; i < cpc_ptr->number_of_events; i++) {
		offset = (u64)((u8 *)event_ptr - base_ptr);
		ESIF_TRACE_DYN_CPC(
			"<%06llu> name %s notify %x esif_event %s(%d) esif_event_group TBD(%d)\n",
			offset,
			event_ptr->name,
			event_ptr->event_key[i],
			esif_event_type_str(event_ptr->esif_event),
			event_ptr->esif_event,
			event_ptr->esif_group);

		/* Todo Handle Other Types Here */
		if (ESIF_EVENT_GROUP_ACPI == event_ptr->esif_group) {
			rc = dsp_ptr->insert_event(dsp_ptr, event_ptr);
			if (ESIF_OK != rc)
				goto exit;
		}
		/* Next Event. Events Are Fix-Sized */
		event_ptr++;
	}

exit:

	ESIF_TRACE_DYN_CPC(
		"%s: %u primitives, %u algorithms and %u events inserted, status %s! %u domain found\n",
		ESIF_FUNC,
		cpc_ptr->number_of_basic_primitives,
		cpc_ptr->number_of_algorithms,
		cpc_ptr->number_of_events,
		esif_rc_str(rc),
		cpc_ptr->number_of_domains);

	return rc;
}