⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pciaddralloc.c

📁 MPC8241:本程序是freescale的824*系列的BSP源程序
💻 C
字号:
#include "vxWorks.h"
#include "logLib.h"
#include "taskLib.h"
#include "string.h"
#include "dllLib.h"
#include "config.h"

#include "drv/pci/pciConfigLib.h"
#if 0
#include "drv/pci/pciAutoConfigLib.h"
#else
#include "./pci/pciAutoConfigLib.h"
#endif

    	
STATUS pciDeviceAddrAlloc
	(
    OTHER_DEVICE * pci9030,      /*must be &otherdev*/
    UINT size,                   /*size you want to alloc*/
    UINT baseAddr,               /*base-address register address */
    UINT devicenum               /*device number*/
    )
   {
    UINT addr;
    UINT baseaddr_mask;
    UINT * pBase;
    UINT * pAvail;
        UINT32 alignedBase;
    UINT32 sizeAdj;
    STATUS retStat = ERROR;
    
	/*logMsg("pciAutoMemAlloc: PF Mem requested"
		"\n", 0, 0, 0, 0, 0, 0);*/

	pBase = &(pci9030->pciMem32);
	pAvail = &(pci9030->pciMem32Size);

	if (*pAvail > 0)
	    {
	    retStat = pciAutoAddrAlign (*pBase,
					(*pBase + *pAvail),
					size,
					&alignedBase);
	    }

	if (retStat == ERROR)
	    {

	    /* If no PF memory available, then try conventional */
		
	    /*logMsg("pciAutoMemAlloc: No PF Mem available"
		    "Trying MemIO\n", 0, 0, 0, 0, 0, 0);*/
		    return ERROR;

	    }
	   /* PCI_AUTO_DEBUG_MSG("pciAutoMemAlloc: \n", 0, 0, 0, 0, 0, 0);
    PCI_AUTO_DEBUG_MSG("  Pre: pBase[0x%08x], pAvail[0x%08x]\n",
	    (int)(*pBase), (int)(*pAvail), 0, 0, 0, 0);*/

    addr  = alignedBase;
    sizeAdj = (alignedBase - *pBase) + size;
    *pBase  += sizeAdj;
    *pAvail -= sizeAdj;

  /* PCI_AUTO_DEBUG_MSG("pciAutoRegConfig:[0x%08x] written to BAR[0x%08x]\n",
		addr, baseAddr, 0, 0, 0, 0);
    PCI_AUTO_DEBUG_MSG("  Post: pBase[0x%08x], pAvail[0x%08x]\n",
	    (int)(*pBase), (int)(*pAvail), 0, 0, 0, 0);*/

   baseaddr_mask = 0xFFFFFFF0;
   pciConfigModifyLong (0, devicenum, 
				0, baseAddr, 
				baseaddr_mask, addr);
        return OK;
   	}
   	
/* move by zoutl 2003-3-14 10:21 */   	
STATUS pciAddrAlloc(
    UINT size,                   /*size you want to alloc*/
    UINT offset,               /*base-address register address */
    UINT devicenum               /*device number*/
    )
    {
        if(pciDeviceAddrAlloc(&otherdev,size,offset,devicenum)==OK)
            return OK;
        else
            return ERROR;
    	}   	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -