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

📄 ixp425pciconfiglib.c

📁 ixp425 bsp for vxworks
💻 C
📖 第 1 页 / 共 2 页
字号:
}/********************************************************************************* pciConfigOutWord - write one 16-bit word to the PCI configuration space** This routine writes one 16-bit word to the PCI configuration space.** RETURNS:* OK, or ERROR if this library is not initialized.**/STATUS pciConfigOutWord (UINT32 busNo,    /* bus number */		  UINT32 deviceNo, /* device number */		  UINT32 funcNo,   /* function number */		  UINT32 offset,   /* offset into configuration space */		  UINT16 data)     /* data written to the offset */    {    UINT32 addr;    UINT32 byteEnables;    UINT32 n;    UINT32 ldata;        if (pciLibInitStatus != OK)    {        return (ERROR);    }    n = offset % 4;    /*byte enables are 4 bits active low, the position of each      bit maps to the byte that it enables*/    byteEnables = (~(BIT (n)|BIT ((n+1)))) & IXP425_PCI_BOTTOM_NIBBLE_OF_LONG_MASK;     byteEnables = byteEnables << PCI_NP_CBE_BESL;    ldata = data << (8*n);    /*address bits 31:28 specify the device 10:8 specify the function*/    /*Set the address to be written*/    addr = BIT (31 - deviceNo) | (funcNo << PCI_NP_AD_FUNCSL) |  (offset & ~3);    nonPrefetchWrite (addr, byteEnables | NP_CMD_CONFIGWRITE, ldata );            return (OK);}/********************************************************************************* pciConfigOutLong - write one longword to the PCI configuration space** This routine writes one longword to the PCI configuration space.** RETURNS:* OK, or ERROR if this library is not initialized.**/STATUS pciConfigOutLong (UINT32 busNo,    /* bus number */		  UINT32 deviceNo, /* device number */		  UINT32 funcNo,   /* function number */		  UINT32 offset,   /* offset into configuration space */		  UINT32 data)     /* data written to the offset */    {    UINT32 addr;        if (pciLibInitStatus != OK)    {        return (ERROR);    }        /*address bits 31:28 specify the device 10:8 specify the function*/    /*Set the address to be written*/    addr = BIT (31 - deviceNo) | (funcNo << PCI_NP_AD_FUNCSL) |  (offset & ~3);    nonPrefetchWrite (addr, NP_CMD_CONFIGWRITE, data );            return (OK);}/********************************************************************************* pciIOInByte - read a Byte from the PCI IO space** This routine reads using PCI IO non-prefetch transactions** RETURNS:* OK, or ERROR if this library is not initialized.**/STATUS pciIOInByte (void *pciAddr, 	     UINT8 *pData){    UINT32 byteEnables;    UINT32 n;    UINT32 retval;        if (pciLibInitStatus != OK)    {	return (ERROR);    }        n = (UINT32)pciAddr % 4;    byteEnables = ~(BIT (n)) & IXP425_PCI_BOTTOM_NIBBLE_OF_LONG_MASK;    byteEnables = byteEnables << PCI_NP_CBE_BESL;    nonPrefetchRead ((UINT32)pciAddr,  byteEnables | NP_CMD_IOREAD, &retval);    *pData = retval >> (8*n) ;        return (OK);}/********************************************************************************* pciIOInWord - read a Word from the PCI IO space** This routine reads using PCI IO non-prefetch transactions** RETURNS:* OK, or ERROR if this library is not initialized.**/STATUS pciIOInWord (void *pciAddr, 	     UINT16 *pData){    UINT32 byteEnables;    UINT32 n;    UINT32 retval;        if (pciLibInitStatus != OK)    {	return (ERROR);    }    n = (UINT32)pciAddr % 4;    byteEnables = ~(BIT (n) | BIT (n+1) ) & IXP425_PCI_BOTTOM_NIBBLE_OF_LONG_MASK;    byteEnables = byteEnables << PCI_NP_CBE_BESL;    nonPrefetchRead ((UINT32)pciAddr,  byteEnables | NP_CMD_IOREAD, &retval);    *pData = retval >> (8*n);        return (OK);}/********************************************************************************* pciIOInLong - read a long from the PCI IO space** This routine reads using PCI IO transactions** RETURNS:* OK, or ERROR if this library is not initialized.**/STATUS pciIOInLong (void *pciAddr, 	     UINT32 *pData){    if (pciLibInitStatus != OK)    {				return (ERROR);    }    nonPrefetchRead ((UINT32)pciAddr,  NP_CMD_IOREAD, pData);        return (OK);}/********************************************************************************* pciIOOutByte - write one byte to the PCI IO space** This routine writes one byte to the PCI IO space.** RETURNS:* OK, or ERROR if this library is not initialized.**/STATUS pciIOOutByte (void *pciAddr, 	      UINT8 data){    UINT32 byteEnables;    UINT32 n;    UINT32 ldata;        if (pciLibInitStatus != OK)		    {	return (ERROR);    }    n = (UINT32)pciAddr % 4;    byteEnables = ~(BIT (n) ) & IXP425_PCI_BOTTOM_NIBBLE_OF_LONG_MASK;    byteEnables = byteEnables << PCI_NP_CBE_BESL;    ldata = data << (8*n);    nonPrefetchWrite ((UINT32)pciAddr, byteEnables | NP_CMD_IOWRITE, ldata );            return (OK);}/********************************************************************************* pciIOOutWord - write one word to the PCI IO space** This routine writes one word to the PCI IO space.** RETURNS:* OK, or ERROR if this library is not initialized.**/STATUS pciIOOutWord (void *pciAddr, 	      UINT16 data){    UINT32 byteEnables;    UINT32 n;    UINT32 ldata;        if (pciLibInitStatus != OK)			/* sanity check */        return (ERROR);        n = (UINT32)pciAddr % 4;    byteEnables = ~(BIT (n)|BIT (n+1) ) & IXP425_PCI_BOTTOM_NIBBLE_OF_LONG_MASK;    byteEnables = byteEnables << PCI_NP_CBE_BESL;    ldata = data << (8*n);    nonPrefetchWrite ((UINT32)pciAddr, byteEnables | NP_CMD_IOWRITE, ldata );         return (OK);}/********************************************************************************* pciIOOutLong - write one longword to the PCI IO space** This routine writes one longword to the PCI IO space.** RETURNS:* OK, or ERROR if this library is not initialized.**/STATUS pciIOOutLong (void *pciAddr, 	      UINT32 data){        if (pciLibInitStatus != OK)	     {        return (ERROR);    }        nonPrefetchWrite ((UINT32)pciAddr, NP_CMD_IOWRITE, data);            return (OK);}/********************************************************************************* pciMemInByte - read a Byte from the PCI Memory space** This routine reads using PCI Memory non-prefetch transactions** RETURNS:* OK, or ERROR if this library is not initialized.**/STATUS pciMemInByte (void *pciAddr, 	      UINT8 *pData){    UINT32 byteEnables;    UINT32 n;    UINT32 retval;        if (pciLibInitStatus != OK)		        {	return (ERROR);    }    n = (UINT32)pciAddr % 4;    byteEnables = ~(BIT (n)) & IXP425_PCI_BOTTOM_NIBBLE_OF_LONG_MASK;    byteEnables = byteEnables << PCI_NP_CBE_BESL;    pciAddr = (UINT32*)((UINT32)pciAddr & ~3);    nonPrefetchRead ((UINT32)pciAddr,  byteEnables | NP_CMD_MEMREAD, &retval);    *pData = retval >> (8*n) ;        return (OK);}/********************************************************************************* pciMemInWord - read a Word from the PCI Memory space** This routine reads using PCI Memory non-prefetch transactions** RETURNS:* OK, or ERROR if this library is not initialized.**/STATUS pciMemInWord (void *pciAddr, 	      UINT16 *pData){    UINT32 byteEnables;    UINT32 n;    UINT32 retval;        if (pciLibInitStatus != OK)	     {	return (ERROR);    }    n = (UINT32)pciAddr % 4;    byteEnables = ~(BIT (n) | BIT (n+1) ) & IXP425_PCI_BOTTOM_NIBBLE_OF_LONG_MASK;    byteEnables = byteEnables << PCI_NP_CBE_BESL;    pciAddr = (void*)((UINT32)pciAddr & ~3);    nonPrefetchRead ((UINT32)pciAddr,  byteEnables | NP_CMD_MEMREAD, &retval);    *pData = retval >> (8*n);        return (OK);}/********************************************************************************* pciMemInLong - read a long from the PCI Memory space** This routine reads using PCI Memory transactions** RETURNS:* OK, or ERROR if this library is not initialized.**/STATUS pciMemInLong (void *pciAddr, 	      UINT32 *pData){    if (pciLibInitStatus != OK)	     {	return (ERROR);    }    pciAddr = (UINT32*)((UINT32)pciAddr & ~3);    nonPrefetchRead ((UINT32)pciAddr,  NP_CMD_MEMREAD, pData);        return (OK);}/********************************************************************************* pciMemOutByte - write one byte to the PCI Memory space** This routine writes one byte to the PCI Memory space.** RETURNS:* OK, or ERROR if this library is not initialized.**/STATUS pciMemOutByte (void *pciAddr, 	       UINT8 data){    UINT32 byteEnables;    UINT32 n;    UINT32 ldata;        if (pciLibInitStatus != OK)		    {        return (ERROR);    }        n = (UINT32)pciAddr % 4;    byteEnables = ~(BIT (n)) & IXP425_PCI_BOTTOM_NIBBLE_OF_LONG_MASK;    byteEnables = byteEnables << PCI_NP_CBE_BESL;    ldata = data << (8*n);    pciAddr = (void*)((UINT32)pciAddr & ~3);    nonPrefetchWrite ((UINT32)pciAddr, byteEnables | NP_CMD_MEMWRITE, ldata );            return (OK);}/********************************************************************************* pciMemOutWord - write one word to the PCI Memory space** This routine writes one word to the PCI Memory space.** RETURNS: OK, or ERROR if this library is not initialized.**/STATUS pciMemOutWord (void *pciAddr, 	       UINT16 data){    UINT32 byteEnables;    UINT32 n;    UINT32 ldata;        if (pciLibInitStatus != OK)	         {        return (ERROR);    }        n = (UINT32)pciAddr % 4;    byteEnables = ~(BIT (n)|BIT (n+1) ) & IXP425_PCI_BOTTOM_NIBBLE_OF_LONG_MASK;    byteEnables = byteEnables << PCI_NP_CBE_BESL;    ldata = data << (8*n);    pciAddr = (void*)((UINT32)pciAddr & ~3);    nonPrefetchWrite ((UINT32)pciAddr, byteEnables | NP_CMD_MEMWRITE, ldata );            return (OK);}/********************************************************************************* pciMemOutLong - write one longword to the PCI Memory space** This routine writes one longword to the PCI Memory space.** RETURNS: OK, or ERROR if this library is not initialized.**/STATUS pciMemOutLong (void *pciAddr, 	       UINT32 data){        if (pciLibInitStatus != OK)	         {        return (ERROR);    }    pciAddr = (void*)((UINT32)pciAddr & ~3);    nonPrefetchWrite ((UINT32)pciAddr, NP_CMD_MEMWRITE, data );            return (OK);}/********************************************************************************* pciSpecialCycle - generate a special cycle with a message** This routine generates a special cycle with a message.** RETURNS: OK, or ERROR if this library is not initialized.**/STATUS pciSpecialCycle (UINT32 busNo,   /* bus number */		 UINT32 message) /* data on AD[31:0] during the special cycle */    {    if (pciLibInitStatus != OK)		    {        return (ERROR);    }    nonPrefetchWrite (message, NP_CMD_SPECIAL, message);            return (OK);}

⌨️ 快捷键说明

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