예제 #1
0
/** 
 * \fn     que_Create 
 * \brief  Create a queue. 
 * 
 * Allocate and init a queue object.
 * 
 * \note    
 * \param  hOs               - Handle to Os Abstraction Layer
 * \param  hReport           - Handle to report module
 * \param  uLimit            - Maximum items to store in queue
 * \param  uNodeHeaderOffset - Offset of NodeHeader field from the entry of the queued item.
 * \return Handle to the allocated queue 
 * \sa     que_Destroy
 */ 
handle_t que_Create (handle_t hMcpf, McpU32 uLimit, McpU32 uNodeHeaderOffset)
{
	TQueue *pQue;

	if(!hMcpf)
	{
		MCPF_OS_REPORT (("Mcpf handler is NULL\n"));
		return NULL;
	}

	/* allocate queue module */
	pQue = mcpf_mem_alloc (hMcpf, sizeof(TQueue));
	
	if (!pQue)
	{
		MCPF_OS_REPORT (("Error allocating the Queue Module\n"));
		return NULL;
	}
	
    mcpf_mem_zero (hMcpf, pQue, sizeof(TQueue));

	MCP_DL_LIST_InitializeHead (&pQue->tHead);

	/* Set the Queue parameters */
    pQue->hMcpf           = hMcpf;
	pQue->uLimit            = uLimit;
	pQue->uNodeHeaderOffset = uNodeHeaderOffset;

	return (handle_t)pQue;
}
void MCP_DL_LIST_MoveList(MCP_DL_LIST_Node* dest, MCP_DL_LIST_Node* src)
{
	MCP_FUNC_START("MCP_DL_LIST_MoveList");
	
	MCP_VERIFY_FATAL_NO_RETVAR((MCP_DL_LIST_IsCircular(src) == MCP_TRUE), ("MCP_DL_LIST_MoveList: List is not circular"));

	/* New head points at list*/
	dest->next = src->next;
	dest->prev = src->prev;

	/* Detach source head from list */
	src->next->prev = dest;
	src->prev->next = dest;
	
	MCP_DL_LIST_InitializeHead(src);

	MCP_FUNC_END();
}
예제 #3
0
/** 
 * \fn     CCMA_Create 
 * \brief  Create CCM adapter object
 * 
 */ 
handle_t CCMA_Create(const handle_t hMcpf,
                     const McpHalChipId chipId,
                     const CcmaMngrCb mngrCb)
{
    TCcmaObj *pCcma;

    pCcma = mcpf_mem_alloc(hMcpf, sizeof(TCcmaObj));
    MCPF_Assert(pCcma);
    mcpf_mem_zero(hMcpf, pCcma, sizeof(TCcmaObj));

    pCcma->hMcpf = hMcpf;
    pCcma->eChipId = chipId;
    pCcma->fMngrCb = mngrCb;

    MCP_DL_LIST_InitializeHead(&pCcma->tClientList);

    return(handle_t) pCcma;
}
예제 #4
0
/** 
 * \fn     mcpf_SLL_Create
 * \brief  Create a sorted linked list
 * 
 * This function creates a sorted linked list
 * 
 * \note
 * \param	hMcpf - MCPF handler.
 * \param	uLimit - max list length.
 * \param	uNodeHeaderOffset - Offset of node's header field in stored structure.
 * \param	uSortByFeildOffset - Offset of the field to sort by, in stored structure.
 * \param	tSortType - sort type, UP or DOWN.
 * \return 	List handler.
 * \sa     	mcpf_SLL_Create
 */ 
handle_t mcpf_SLL_Create (handle_t hMcpf, McpU32 uLimit, McpU32 uNodeHeaderOffset, 
							McpU32 uSortByFeildOffset, TSllSortType	tSortType)
{
    mcpf_SLL   *pSortedList;
    if (!hMcpf) 
	{
		MCPF_OS_REPORT(("Mcpf handler is NULL\n"));
		return NULL;	
	}
        
    /* Allocate memory for the sorted Linked List */
    pSortedList = mcpf_mem_alloc(hMcpf, sizeof(mcpf_SLL));

    if (NULL == pSortedList)
	{
		MCPF_REPORT_ERROR(pSortedList->hMcpf, MCPF_MODULE_LOG, ("mcpf_mem_alloc returned NULL\n"));
		return NULL;
	}
    
    /* Initialize the memory block to zero */
    mcpf_mem_zero(hMcpf, pSortedList, sizeof(mcpf_SLL));

    /* Initialize the list header */
	MCP_DL_LIST_InitializeHead (&pSortedList->tHead);

    /* Set the List paramaters */
	pSortedList->hMcpf = hMcpf;                  
	pSortedList->tSortType = tSortType;
	pSortedList->uSortByFieldOffset = (McpU16)uSortByFeildOffset;
	pSortedList->uNodeHeaderOffset  = (McpU16)uNodeHeaderOffset;
	pSortedList->uOverflow = 0;
	pSortedList->uLimit = (McpU16)uLimit;
	pSortedList->uCount = 0;
        
    return (handle_t)pSortedList;
}