Exemplo n.º 1
0
STATUS
pciIntConnect (VOIDFUNCPTR *vector, VOIDFUNCPTR routine, int parameter)
{
    static int alreadyConnected=FALSE;

    int irq = IVEC_TO_INUM ((int)vector) - sysVectorIRQ0;
    PCI_INT_RTN *pRtn;
    int oldLevel;

    pRtn = (PCI_INT_RTN *)malloc (sizeof (PCI_INT_RTN));
    if (pRtn == NULL) {
        return (ERROR);
    }

    pRtn->routine   = routine;
    pRtn->parameter = parameter;

    oldLevel = intLock ();                      /* LOCK INTERRUPT */
    dllAdd (&pciIntList[irq], &pRtn->node);
    intUnlock (oldLevel);                       /* UNLOCK INTERRUPT */

    if (!alreadyConnected) {
        if (intConnect(vector, (VOIDFUNCPTR) pciInt, irq) == ERROR) {
            return -1;
        }
        alreadyConnected=TRUE;
    }
    return (OK);
}
Exemplo n.º 2
0
void qFifoPut
    (
    Q_FIFO_HEAD *pQFifoHead,
    Q_FIFO_NODE *pQFifoNode,
    ULONG        key
    )
    {
    if (key == FIFO_KEY_HEAD)
	dllInsert (pQFifoHead, (DL_NODE *)NULL, pQFifoNode);
    else
	dllAdd (pQFifoHead, pQFifoNode);
    }
Exemplo n.º 3
0
LOCAL void qFifoPut(
    Q_FIFO_HEAD *pQFifoHead,
    Q_FIFO_NODE *pQFifoNode,
    int key
    )
{
    if (key == FIFO_KEY_HEAD)
    {
        dllInsert(
            &pQFifoHead->qFifo.head,
            (DL_NODE *) NULL,
            &pQFifoNode->qFifo.node
            );
    }
    else
    {
        dllAdd(&pQFifoHead->qFifo.head, &pQFifoNode->qFifo.node);
    }
}
Exemplo n.º 4
0
static BLOCK_HDR* memAlignedBlockSplit(PART_ID partId
	, FAST BLOCK_HDR* pHdr
	, FAST unsigned nWords
	, unsigned minWords
	, unsigned align)
{
	FAST BLOCK_HDR *pNewHdr;
    FAST BLOCK_HDR *pNextHdr;
    FAST char *endOfBlock;
    FAST char *pNewBlock;
    int blockSize;

	endOfBlock = (char*)pHdr + (pHdr->nWords*2);

	pNewBlock = (char*)((unsigned)endOfBlock - ((nWords - sizeof(BLOCK_HDR)/2)*2));

	pNewBlock = (char*)((unsigned)pNewBlock & (~(align-1)));

	pNewHdr = BLOCK_TO_HDR(pNewBlock);

	blockSize = ((char*)pNewHdr - (char*)pHdr)/2;

	if(blockSize < minWords)
	{
		if(pNewHdr == pHdr)
		{
			dllRemove(&partId->freeList, HDR_TO_NODE(pHdr));
		}
		else
		{
			return NULL;
		}
	}
	else
	{	/* recaculate pHdr */
		pNewHdr->prevHdr = pHdr;
		pHdr->nWords = blockSize;
	}

	if(((U32)endOfBlock - (U32)pNewHdr - (nWords*2)) < (minWords*2))
	{
		pNewHdr->nWords = (endOfBlock - pNewBlock + sizeof(BLOCK_HDR))/2;
		pNewHdr->free = TRUE;

		NEXT_HDR(pNewHdr)->prevHdr = pNewHdr;
	}
	else
	{/* space left is enough to be a fragment on the free list then */
		pNewHdr->nWords = nWords;
		pNewHdr->free = TRUE;

		pNextHdr = NEXT_HDR(pNewHdr);
		/* words °üÀ¨BlockHdr */
		pNextHdr->nWords = ((U32)endOfBlock - (U32)pNextHdr) / 2;
		pNextHdr->prevHdr = pNewHdr;
		pNextHdr->free = TRUE;

		dllAdd(&partId->freeList, HDR_TO_NODE(pNextHdr));

		NEXT_HDR(pNextHdr)->prevHdr = pNewHdr;
	}

	return (pNewHdr);
}
Exemplo n.º 5
0
LOCAL BLOCK_HDR *memAlignedBlockSplit 
    (
    PART_ID partId,
    FAST BLOCK_HDR *pHdr,
    FAST unsigned nWords,            /* number of words in second block */
    unsigned minWords,               /* min num of words allowed in a block */
    unsigned alignment		     /* boundary to align to */
    )
    {
    FAST BLOCK_HDR *pNewHdr;
    FAST BLOCK_HDR *pNextHdr;
    FAST char *endOfBlock;
    FAST char *pNewBlock;
    int blockSize;

    /* calculate end of pHdr block */

    endOfBlock = (char *) pHdr + (pHdr->nWords * 2); 

    /* caluclate unaligned beginning of new block */ 

    pNewBlock = (char *) ((unsigned) endOfBlock - 
		((nWords - sizeof (BLOCK_HDR) / 2) * 2));

    /* align the beginning of the block */

    pNewBlock = (char *)((unsigned) pNewBlock & ~(alignment - 1));

    pNewHdr = BLOCK_TO_HDR (pNewBlock);

    /* adjust original block's word count */

    blockSize = ((char *) pNewHdr - (char *) pHdr) / 2;


    if (blockSize < minWords)
	{
	/* check to see if the new block is the same as the original block -
	 * if so, delete if from the free list.  If not, reject the newly
	 * split block because it's too small to hang on the free list.
	 */

	if (pNewHdr == pHdr)
	    dllRemove (&partId->freeList, HDR_TO_NODE (pHdr));
	else
	    return (NULL);
	}
    else
	{
	pNewHdr->pPrevHdr = pHdr;
	pHdr->nWords = blockSize;
	}

    /* check to see if space left over after we aligned the new buffer
     * is big enough to be a fragment on the free list.
     */

    if (((UINT) endOfBlock - (UINT) pNewHdr - (nWords * 2)) < (minWords * 2))
	{
	/* nope - give all the memory to the newly allocated block */

	pNewHdr->nWords = (endOfBlock - pNewBlock + sizeof (BLOCK_HDR)) / 2;
	pNewHdr->free     = TRUE; 

	/* fix next block to point to newly allocated block */

	NEXT_HDR (pNewHdr)->pPrevHdr = pNewHdr;
	}
    else
	{
	/* the extra bytes are big enough to be a fragment on the free list -
	 * first, fix up the newly allocated block.
	 */

	pNewHdr->nWords = nWords;
	pNewHdr->free     = TRUE; 

	/* split off the memory after pNewHdr and add it to the free list */

	pNextHdr = NEXT_HDR (pNewHdr);
	pNextHdr->nWords = ((UINT) endOfBlock - (UINT) pNextHdr) / 2;
	pNextHdr->pPrevHdr = pNewHdr;
	pNextHdr->free = TRUE;

	dllAdd (&partId->freeList, HDR_TO_NODE (pNextHdr));	

	/* fix next block to point to the new fragment on the free list */

	NEXT_HDR (pNextHdr)->pPrevHdr = pNextHdr;
	}

    return (pNewHdr);
    }