📄 pciiomaplib.c
字号:
* RETURNS:* OK, or ERROR if this library is not initialized.**/STATUS pciConfigInByte ( int busNo, /* bus number */ int deviceNo, /* device number */ int funcNo, /* function number */ int offset, /* offset into the configuration space */ char * pData /* data read from the offset */ ) { int retval = 0; int status; char *cfgAddr = NULL; if (pciLibInitStatus != OK) /* sanity check */ return (ERROR); cfgAddr = (char *)(((busNo == 0) ? pciConfigAddr0 : pciConfigAddr1) | MAKE_CFG_ADDR(busNo, deviceNo, funcNo, offset)); status = vxMemProbe (cfgAddr, VX_READ, 4, (char *)&retval); if(status == ERROR) { clearMasterAbort(); *pData = 0xFF; } else { *pData = (char)((retval >> ((offset % 0x4) * 8)) & 0xff); } return (OK); }/********************************************************************************* pciConfigInWord - read one word from the PCI configuration space** This routine reads one word from the PCI configuration space** RETURNS:* OK, or ERROR if this library is not initialized.**/STATUS pciConfigInWord ( int busNo, /* bus number */ int deviceNo, /* device number */ int funcNo, /* function number */ int offset, /* offset into the configuration space */ short * pData /* data read from the offset */ ) { int retval = 0; int status; char *cfgAddr = NULL; if (pciLibInitStatus != OK) /* sanity check */ return (ERROR); cfgAddr = (char *)(((busNo == 0) ? pciConfigAddr0 : pciConfigAddr1) | MAKE_CFG_ADDR(busNo, deviceNo, funcNo, offset)); status = vxMemProbe (cfgAddr, VX_READ, 4, (char *)&retval); if(status == ERROR) { clearMasterAbort(); *pData = 0xFFFF; } else { *pData = (short)((retval >> ((offset % 0x4) * 8)) & 0xffff); } return (OK); }/********************************************************************************* pciConfigInLong - read one longword from the PCI configuration space** This routine reads one longword from the PCI configuration space** RETURNS:* OK, or ERROR if this library is not initialized.**/STATUS pciConfigInLong ( int busNo, /* bus number */ int deviceNo, /* device number */ int funcNo, /* function number */ int offset, /* offset into the configuration space */ int * pData /* data read from the offset */ ) { int retval = 0; int status; char *cfgAddr = NULL; if (pciLibInitStatus != OK) /* sanity check */ return (ERROR); cfgAddr = (char *)(((busNo == 0) ? pciConfigAddr0 : pciConfigAddr1) | MAKE_CFG_ADDR(busNo, deviceNo, funcNo, offset)); status = vxMemProbe (cfgAddr, VX_READ, 4, (char *)&retval); if(status == ERROR) { clearMasterAbort(); *pData = 0xFFFFFFFF; } else { *pData = retval; } return (OK); }/********************************************************************************* pciConfigOutByte - write one byte to the PCI configuration space** This routine writes one byte to the PCI configuration space.** RETURNS:* OK, or ERROR if this library is not initialized.**/STATUS pciConfigOutByte ( int busNo, /* bus number */ int deviceNo, /* device number */ int funcNo, /* function number */ int offset, /* offset into the configuration space */ char data /* data written to the offset */ ) { int *addr; int retval, mask, temp; int status; if (pciLibInitStatus != OK) /* sanity check */ return (ERROR); addr = (int *)(((busNo == 0) ? pciConfigAddr0 : pciConfigAddr1) | MAKE_CFG_ADDR(busNo, deviceNo, funcNo, offset)); mask = ~(0x000000ff << ((offset % 0x4) * 8)); temp = (int)(((int)data) << ((offset % 0x4) * 8)); retval = (*addr & mask) | temp; status = vxMemProbe ((char*)addr, VX_WRITE, 4, (char *)&retval); if(status == ERROR) { clearMasterAbort(); } return (OK); }/********************************************************************************* 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 ( int busNo, /* bus number */ int deviceNo, /* device number */ int funcNo, /* function number */ int offset, /* offset into the configuration space */ short data /* data written to the offset */ ) { int *addr; int retval, mask, temp; int status; if (pciLibInitStatus != OK) /* sanity check */ return (ERROR); addr = (int *)(((busNo == 0) ? pciConfigAddr0 : pciConfigAddr1) | MAKE_CFG_ADDR(busNo, deviceNo, funcNo, offset)); mask = ~(0x0000ffff << ((offset % 0x4) * 8)); temp = (int)(((int)data) << ((offset % 0x4) * 8)); retval = (*addr & mask) | temp; status = vxMemProbe ((char *)addr, VX_WRITE, 4, (char *)&retval); if(status == ERROR) { clearMasterAbort(); } 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 ( int busNo, /* bus number */ int deviceNo, /* device number */ int funcNo, /* function number */ int offset, /* offset into the configuration space */ int data /* data written to the offset */ ) { int *addr; int status; if (pciLibInitStatus != OK) /* sanity check */ return (ERROR); addr = (int *)(((busNo == 0) ? pciConfigAddr0 : pciConfigAddr1) | MAKE_CFG_ADDR(busNo, deviceNo, funcNo, offset)); status = vxMemProbe ((char *)addr, VX_WRITE, 4, (char *)&data); if(status == ERROR) { clearMasterAbort(); } return (OK); }VOID pciIntEnable ( int irq /* IRQ associated to the PCI interrupt */ ) { UINT32 cpldReg; if(isNPUMaster()) { ixdp2400SPCfgSave(&spCfgOld); ixdp2400SPCfgRestore(&spCfgCpld); cpldReg = *((UINT32 *)(CPLD_INTMASK)); cpldReg &= ~(1 << irq); *((UINT32 *)(CPLD_INTMASK)) = cpldReg; ixdp2400SPCfgRestore(&spCfgOld); } return; }VOID pciIntDisable ( int irq /* IRQ associated to the PCI interrupt */ ) { UINT32 cpldReg; if(isNPUMaster()) { ixdp2400SPCfgSave(&spCfgOld); ixdp2400SPCfgRestore(&spCfgCpld); cpldReg = *((UINT32 *)(CPLD_INTMASK)); cpldReg |= (1 << irq); *((UINT32 *)(CPLD_INTMASK)) = cpldReg; ixdp2400SPCfgRestore(&spCfgOld); } return; }/********************************************************************************* pciInt - interrupt handler for shared PCI interrupt.** This routine executes interrupt handlers for a PCI interrupt.** RETURNS: N/A**/VOID pciInt ( int irq /* IRQ associated to the PCI interrupt */ ) { int i; UINT32 cpldReg; if(!isNPUMaster()) { if(pciISRList[CPLD_NIC_INT]) { (pciISRList[CPLD_NIC_INT])(pciISRDataList[CPLD_NIC_INT]); } } else { ixdp2400SPCfgSave(&spCfgOld); ixdp2400SPCfgRestore(&spCfgCpld); cpldReg = *((UINT32 *)(CPLD_INT)); for(i = 0; i < MAX_CPLD_INT; i++) { if((cpldReg & (1 << i)) && pciISRList[i]) { (pciISRList[i])(pciISRDataList[i]); } } ixdp2400SPCfgRestore(&spCfgOld); } return; }/********************************************************************************* pciIntConnect - connect the interrupt handler to the PCI interrupt.** This routine connects an interrupt handler to the PCI interrupt line B.** RETURNS:* OK, or ERROR if the interrupt handler cannot be built.**/STATUS pciIntConnect ( VOIDFUNCPTR *vector, /* interrupt vector to attach to */ VOIDFUNCPTR routine, /* routine to be called */ int parameter /* parameter to be passed to routine */ ) { int irq = IVEC_TO_INUM(vector); if(pciLibInitStatus != OK) return(ERROR); if(irq > (MAX_CPLD_INT - 1)) return(ERROR); pciISRList[irq] = routine; pciISRDataList[irq] = parameter; return (OK); }/********************************************************************************* pciIntDisconnect - disconnect the interrupt handler from the PCI interrupt.** This routine disconnects the interrupt handler from the PCI interrupt line B** RETURNS:* OK, or ERROR if the interrupt handler cannot be removed.**/STATUS pciIntDisconnect ( VOIDFUNCPTR *vector, /* interrupt vector to attach to */ VOIDFUNCPTR routine /* routine to be called */ ) { int irq = IVEC_TO_INUM(vector); if(pciLibInitStatus != OK) return(ERROR); if(irq > (MAX_CPLD_INT - 1)) return(ERROR); pciISRList[irq] = 0; pciISRDataList[irq] = 0; return (OK); }#endif /* defined(INCLUDE_PCI) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -