📄 syspciautoconfig.c
字号:
/* sysPciAutoConfig.c - Wind River PPMC74xx PCI autoconfig support *//* Copyright 1984-2001 Wind River Systems, Inc. *//*modification history--------------------01d,09nov01,g_h Remove include "wrPpmc74xx.h".01c,23oct01,g_h Cleaning for T2.201b,08aug01,g_h changing sysPciAutoConfigIntAsgn() to return 0.01a,30mar01,g_h written.*//*DESCRIPTIONThis module contains the "non-generic" or "board specific" PCI-PCIbridge initialization code. The module contains code to: 1. Determine if a particular function is to be excluded from the automatic configuration process. 2. Program the "interrupt line" field of the PCI configuration header.*//* includes */#include "vxWorks.h"#include "logLib.h"#include "taskLib.h"#include "config.h"#include "drv/pci/pciAutoConfigLib.h"/* globals */PCI_SYSTEM sysParams;/* locals *//* forward declarations */LOCAL UCHAR sysPciAutoConfigIntAsgn ( PCI_SYSTEM * pSys, PCI_LOC * pFunc, UCHAR intPin );LOCAL STATUS sysPciAutoConfigInclude ( PCI_SYSTEM *pSys, PCI_LOC *pciLoc, UINT devVend );/* Latency Timer value - 64 PCI clocks */#undef PCI_LAT_TIMER#define PCI_LAT_TIMER 0x40/* subroutines *//***************************************************************************** sysPciAutoConfigInclude - Determine if function is to be autoConfigured** This function is called with PCI bus, device, function, and vendor* information. It returns an indication of whether or not the particular* function should be included in the automatic configuration process.* This capability is useful if it is desired that a particular function* NOT be automatically configured. Of course, if the device is not* included in automatic configuration, it will be unusable unless the* user's code made provisions to configure the function outside of the* the automatic process.** RETURNS: TRUE if function is to be included in automatic configuration,* FALSE otherwise.*/LOCAL int sysPciAutoConfigInclude ( PCI_SYSTEM *pSys, /* input: AutoConfig system information */ PCI_LOC *pciLoc, /* input: PCI address of this function */ UINT devVend /* input: Device/vendor ID number */ ) { STATUS retVal = OK ; switch (devVend) { /* example code for an excluded device */ default: retVal = OK; break; } return(retVal); }/***************************************************************************** sysPciAutoConfigIntAssign - Assign the "interrupt line" value.** This routiner assign the interrupt line value.** RETURNS: "interrupt line" value.*/LOCAL UCHAR sysPciAutoConfigIntAsgn ( PCI_SYSTEM * pSys, /* input: AutoConfig system information */ PCI_LOC * pFunc, UCHAR intPin /* input: interrupt pin number */ ) { /* This prevents an interrupt being assigned to the bridge */ if (pFunc->bus ==0) if (pFunc->device == HOST_BRIDGE_IDSEL) return -1; /* No interrupt */ else#ifdef INCLUDE_PCI_STANDALONE /* PCI card in standalone */ return INT_LVL_GPP15_8;#else return 0;#endif else /* PCI interrupt: A=0, B=1, C=2, D=3 */ return (pFunc->device + intPin - 1) % 4;}/***************************************************************************** sysPciAutoConfig - PCI autoConfig support routine** This routine instantiates the PCI_SYSTEM structure needed to configure* the system. This consists of assigning address ranges to each category* of PCI system resource: Prefetchable and Non-Prefetchable 32-bit Memory, and* 16- and 32-bit I/O. Global values for the Cache Line Size and Maximum* Latency are also specified. Finally, the four supplemental routines for * device inclusion/exclusion, interrupt assignment, and pre- and* post-enumeration bridge initialization are specified. ** RETURNS: N/A*/void sysPciAutoConfig ( void ) { UINT32 ultmp; UINT16 ustmp, pciStatus; sysParams.pciMemIo32 = PCI_PP_MEM_START; sysParams.pciMemIo32Size = PCI_PP_MEM_SIZE; /* 32-bit Prefetchable Memory Space */ sysParams.pciMem32 = 0; sysParams.pciMem32Size = 0; /* 16-bit ISA I/O Space - First block of memory in the I/O space */ sysParams.pciIo16 = BRD_PCIIO_CPU2PCI(PCI_PP_IO16_START,HOST_BRIDGE_NUM); sysParams.pciIo16Size = PCI_PP_IO16_SIZE; /* 32-bit PCI I/O Space - Remaining memory in the I/O space */ sysParams.pciIo32 = BRD_PCIIO_CPU2PCI(PCI_PP_IO_START,HOST_BRIDGE_NUM); sysParams.pciIo32Size = PCI_PP_IO_SIZE; /* Configuration space parameters */ sysParams.cacheSize = ( _CACHE_ALIGN_SIZE / 4 ); sysParams.maxLatency = PCI_LAT_TIMER; sysParams.autoIntRouting = FALSE; sysParams.includeRtn = sysPciAutoConfigInclude; sysParams.intAssignRtn = sysPciAutoConfigIntAsgn; sysParams.bridgePreConfigInit = NULL; sysParams.bridgePostConfigInit = NULL; pciConfigInWord (0,0,0,6,&ustmp); pciConfigOutWord (0,0,0,6,ustmp); /* clear status before using it */ pciConfigInLong (0,7,0,0x00,&ultmp); /* read dev 7 */ pciConfigInWord (0,0,0,6,&ustmp); pciStatus = ustmp; pciConfigOutWord (0,0,0,6,ustmp); pciConfigInLong (0,7,0,0x00,&ultmp); /* read dev 7 */ if (ultmp != 0xffffffffL) { pciAutoConfig (&sysParams); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -