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

📄 pciautoconfiglib.c

📁 IXP425的BSP代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/************************************************************************ pciAutoConfigLibInit - initialize PCI autoconfig library.** pciAutoConfigLib initialization function.** ERRNO: not set** RETURNS: A cookie for use by subsequent pciAutoConfigLib function*	calls.**/void * pciAutoConfigLibInit    (    void * pArg				/* reserved for future use */    )    {    pPciCfgOpts = &pciAutoConfigOpts;    pPciCfgOpts->pciConfigInit = TRUE;    return((void *)pPciCfgOpts);    }/******************************************************************************** pciAutoCfg - Automatically configure all nonexcluded PCI headers.** Top level function in the PCI configuration process.** CALLING SEQUENCE:* .CS* pCookie = pciAutoConfigLibInit(NULL);* pciAutoCfgCtl(pCookie, COMMAND, VALUE);* ...* pciAutoCfgCtl(pCookie, COMMAND, VALUE);* pciAutoCfg(pCookie);* .CE** For ease in converting from the old interface to the new one,* a pciAutoCfgCtl() command PCI_PSYSTEM_STRUCT_COPY has been* implemented.  This can be used just like any other pciAutoCfgCtl()* command, and it will initialize all the values in pSystem.  If* used, it should be the first call to pciAutoCfgCtl().** For a description of the COMMANDs and VALUEs to pciAutoCfgCtl(), see* the pciAutoCfgCtl() documentation.** For all nonexcluded PCI functions on all PCI bridges, this routine* will automatically configure the PCI configuration headers for PCI* devices and subbridges.  The fields that are programmed are:** .IP 1. 4* Status register.* .IP 2. 4* Command Register.* .IP 3. 4* Latency timer.* .IP 4. 4* Cache Line size.* .IP 5. 4* Memory and/or I/O base address and limit registers.* .IP 6. 4* Primary, secondary, subordinate bus number (for PCI-PCI bridges).* .IP 7. 4* Expansion ROM disable.* .IP 8. 4* Interrupt Line.* .LP** ALGORITHM:** Probe PCI config space and create a list of available PCI functions.* Call device exclusion function, if registered, to exclude/include device.* Disable all devices before we initialize any.* Allocate and assign PCI space to each device.* Calculate and set interrupt line value.* Initialize and enable each device.** RETURNS: N/A.**/STATUS pciAutoCfg    (    void *pCookie		/* cookie returned by pciAutoConfigLibInit() */    )    {    PCI_AUTO_CONFIG_OPTS *pOpts;    pOpts = (PCI_AUTO_CONFIG_OPTS *)pCookie;    if ( pOpts->pciConfigInit != TRUE )	{	errnoSet(EINVAL);	return(ERROR);	}    pciAutoCfgFunc(pCookie);    /* check FBB Enable & activate if appropriate */    if ( pOpts->pciFBBEnable == TRUE )	{	if ( pciAutoConfigFBBEnable(pOpts) == OK )	    {    	    pOpts->pciFBBActive = TRUE;	    }	else	    {	    PCI_AUTO_DEBUG_MSG("pciAutoCfg(): fast back-to-back NOT enabled\n",			1,2,3,4,5,6);	    }	}    return(OK);    }/************************************************************************ pciAutoCfgCtl - set or get pciAutoConfigLib options.** pciAutoCfgCtl() can be considered analogous to ioctl()* calls: the call takes arguments of (1) a pCookie, returned by* pciAutoConfigLibInit().  (2) A command,* macros for which are defined in pciAutoConfigLib.h.  And, (3)* an argument, the type of which depends on the specific command,* but will always fit in a pointer variable.  Currently, only* globally effective commands are implemented.** The commands available are:** .IP "PCI_FBB_ENABLE - BOOL * pArg"* .IP "PCI_FBB_DISABLE - void"* .IP "PCI_FBB_UPDATE - BOOL * pArg"* .IP "PCI_FBB_STATUS_GET - BOOL * pArg"* Enable and disable the functions which check Fast Back To Back* functionality.  PCI_FBB_UPDATE is for use with dynamic/HA* applications.  It will* first disable FBB on all functions, then enable FBB on all* functions, if appropriate.  In HA applications, it should be* called any time a card is* added or removed.  The BOOL pointed to by pArg for PCI_FBB_ENABLE* and PCI_FBB_UPDATE will be set to TRUE if all cards allow FBB* functionality and FALSE if either any card does not allow FBB* functionality or if FBB is disabled.  The BOOL pointed to by pArg* for PCI_FBB_STATUS_GET will be set to TRUE if PCI_FBB_ENABLE has* been called and FBB is enabled, even if FBB is not activated on any* card.  It will be set to FALSE otherwise.** Note that in the current* implementation, FBB will be enabled or disabled on* the entire bus.  If any device anywhere on the bus cannot support* FBB, then it is not enabled, even if specific sub-busses* could support it.** .IP "PCI_MAX_LATENCY_FUNC_SET - FUNCPTR * pArg"* This routine will be called for each function present on the bus* when discovery takes place.  The routine must accept four* arguments, specifying bus, device, function, and a user-supplied* argument of type void *.  See PCI_MAX_LATENCY_ARG_SET.  The routine* should return a UINT8 value, which will be put into the MAX_LAT* field of the header structure.  The user supplied routine must* return a valid value each time it is called.  There is no mechanism* for any ERROR condition, but a default value can be returned in* such a case.  Default = NULL.** .IP "PCI_MAX_LATENCY_ARG_SET - void * pArg"* When the routine specified in PCI_MAX_LATENCY_FUNC_SET is called,* this will be passed to it as the fourth argument.** .IP "PCI_MAX_LAT_ALL_SET - int pArg"* Specifies a constant max latency value for all cards, if no* function has been specified with PCI_MAX_LATENCY_FUNC_SET..** .IP "PCI_MAX_LAT_ALL_GET - UINT * pArg"* Retrieves the value of max latency for all cards, if no function* has been specified with PCI_MAX_LATENCY_FUNC_SET.  Otherwise, the* integer pointed to by pArg is set to the* value 0xffffffff.** .IP "PCI_MSG_LOG_SET - FUNCPTR * pArg"* The argument specifies a routine will be called to print warning or* error messages from pciAutoConfigLib if logMsg() has not been* initialized at the time pciAutoConfigLib is used.  The specified* routine must accept arguments in the same format as logMsg(), but* it does not necessarily need to print the actual message.  An* example of this routine is presented below, which* saves the message into a safe memory space and turns on an LED.* This command is useful for BSPs which call pciAutoCfg() before* message logging is enabled.  Note that after logMsg() is configured,* output will go to logMsg() even if this command has been called.* Default = NULL.** .CS* /@ sample PCI_MSG_LOG_SET function @/* int pciLogMsg(char *fmt,int a1,int a2,int a3,int a4,int a5,int a6)*     {*     sysLedOn(4);*     return(sprintf(sysExcMsg,fmt,a1,a2,a3,a4,a5,a6));*     }* .CE** .IP "PCI_MAX_BUS_GET - int * pArg"* During autoconfiguration, the library will maintain a counter with* the highest numbered bus.  This can be retrieved by* .CS* pciAutoCfgCtl(pCookie, PCI_MAX_BUS_GET, &maxBus)* .CE** .IP "PCI_CACHE_SIZE_SET - int pArg"* Sets the pci cache line size to the specified value.  See* CONFIGURATION SPACE PARAMETERS in the pciAutoConfigLib* documentation for more details.** .IP "PCI_CACHE_SIZE_GET - int * pArg"* Retrieves the value of the pci cache line size.** .IP "PCI_AUTO_INT_ROUTE_SET - BOOL pArg"* Enables or disables automatic interrupt routing across bridges* during the autoconfig process.  See "INTERRUPT ROUTING ACROSS* PCI-TO-PCI BRIDGES" in the pciAutoConfigLib documentation for more* details.** .IP "PCI_AUTO_INT_ROUTE_GET - BOOL * pArg"* Retrieves the status of automatic interrupt routing.** .IP "PCI_MEM32_LOC_SET - UINT32 pArg"* Sets the base address of the PCI 32-bit memory space.  Normally,* this is given by the BSP constant PCI_MEM_ADRS.** .IP "PCI_MEM32_SIZE_SET - UINT32 pArg"* Sets the maximum size to use for the PCI 32-bit memory space.* Normally, this is given by the BSP constant PCI_MEM_SIZE.** .IP "PCI_MEM32_SIZE_GET - UINT32 * pArg"* After autoconfiguration has been completed, this retrieves* the actual amount of space which has been used for the* PCI 32-bit memory space.** .IP "PCI_MEMIO32_LOC_SET - UINT32 pArg"* Sets the base address of the PCI 32-bit non-prefetch memory space.* Normally, this is given by the BSP constant PCI_MEMIO_ADRS.** .IP "PCI_MEMIO32_SIZE_SET - UINT32 pArg"* Sets the maximum size to use for the PCI 32-bit non-prefetch memory* space.  Normally, this is given by the BSP constant* PCI_MEMIO_SIZE.** .IP "PCI_MEMIO32_SIZE_GET - UINT32 * pArg"* After autoconfiguration has been completed, this retrieves* the actual amount of space which has been used for the PCI* 32-bit non-prefetch memory space.** .IP "PCI_IO32_LOC_SET - UINT32 pArg"* Sets the base address of the PCI 32-bit I/O space.* Normally, this is given by the BSP constant PCI_IO_ADRS.** .IP "PCI_IO32_SIZE_SET - UINT32 pArg"* Sets the maximum size to use for the PCI 32-bit I/O space.* Normally, this is given by the BSP constant PCI_IO_SIZE.** .IP "PCI_IO32_SIZE_GET - UINT32 * pArg"* After autoconfiguration has been completed, this retrieves* the actual amount of space which has been used for the PCI* 32-bit I/O space.** .IP "PCI_IO16_LOC_SET - UINT32 pArg"* Sets the base address of the PCI 16-bit I/O space.* Normally, this is given by the BSP constant PCI_ISA_IO_ADRS** .IP "PCI_IO16_SIZE_SET - UINT32 pArg"* Sets the maximum size to use for the PCI 16-bit I/O space.* Normally, this is given by the BSP constant PCI_ISA_IO_SIZE** .IP "PCI_IO16_SIZE_GET - UINT32 * pArg"* After autoconfiguration has been completed, this retrieves* the actual amount of space which has been used for the PCI* 16-bit I/O space.** .IP "PCI_INCLUDE_FUNC_SET - FUNCPTR * pArg"* The device inclusion routine is specified by assigning a function* pointer with the PCI_INCLUDE_FUNC_SET pciAutoCfgCtl() command:* .CS* pciAutoCfgCtl(pSystem, PCI_INCLUDE_FUNC_SET,sysPciAutoconfigInclude);* .CE* This optional user-supplied routine takes as input both the* bus-device-function tuple, and a 32-bit quantity containing both* the PCI vendorID and deviceID of the function.  The function* prototype for this function is shown below:* .CS* STATUS sysPciAutoconfigInclude*     (*     PCI_SYSTEM *pSys,*     PCI_LOC *pLoc,*     UINT devVend*     );* .CE* This optional user-specified routine is called by PCI AutoConfig* for each and every function encountered in the scan phase.  The BSP* developer may use any combination of the input data to ascertain* whether a device is to be excluded from the autoconfig process.* The exclusion routine then returns ERROR if a device is to be* excluded, and OK if a device is to be included in the* autoconfiguration process.** Note that PCI-to-PCI Bridges may not be excluded, regardless of the* value returned by the BSP device inclusion routine.  The return* value is ignored for PCI-to-PCI bridges.** The Bridge device will be always be configured with proper primary,* secondary, and subordinate bus numbers in the device scanning phase* and proper I/O and Memory aperture settings in the configuration* phase of autoconfig regardless of the value returned by the BSP* device inclusion routine.** .IP "PCI_INT_ASSIGN_FUNC_SET - FUNCPTR * pArg"* The interrupt assignment routine is specified by assigning a* function pointer with the PCI_INCLUDE_FUNC_SET pciAutoCfgCtl()* command:* .CS* pciAutoCfgCtl(pCookie, PCI_INT_ASSIGN_FUNC_SET, sysPciAutoconfigIntrAssign);* .CE* This optional user-specified routine takes as input both the* bus-device-function tuple, and an 8-bit quantity containing the* contents of the interrupt Pin register from the PCI configuration* header of the device under consideration.  The interrupt pin* register specifies which of the four PCI Interrupt request lines* available are connected.  The function prototype for this function* is shown below:* .CS* UCHAR sysPciAutoconfigIntrAssign*     (*     PCI_SYSTEM *pSys,*     PCI_LOC *pLoc,*     UCHAR pin*     );* .CE** This routine may use any combination of these data to ascertain the* interrupt level.  This value is returned from the function, and* will be programmed into the interrupt line register of the* function's PCI configuration header.  In this manner, device drivers* may subsequently read this register in order to calculate the* appropriate interrupt vector which to attach an interrupt service* routine.** .IP "PCI_BRIDGE_PRE_CONFIG_FUNC_SET - FUNCPTR * pArg"* The bridge pre-configuration pass initialization routine is* provided so that the BSP Developer can initialize a bridge device* prior to the configuration pass on the bus that the bridge* implements.  This routine is specified by calling pciAutoCfgCtl()* with the PCI_BRIDGE_PRE_CONFIG_FUNC_SET command:* .CS* pciAutoCfgCtl(pCookie, PCI_BRIDGE_PRE_CONFIG_FUNC_SET,*         sysPciAutoconfigPreEnumBridgeInit);* .CE* This optional user-specified routine takes as input both the* bus-device-function tuple, and a 32-bit quantity containing both* the PCI deviceID and vendorID of the device.  The function prototype* for this function is shown below:* .CS* STATUS sysPciAutoconfigPreEnumBridgeInit*     (*     PCI_SYSTEM *pSys,*     PCI_LOC *pLoc,*     UINT devVend*     );* .CE* This routine may use any combination of these input data to* ascertain any special initialization requirements of a particular* type of bridge at a specified geographic location.** .IP "PCI_BRIDGE_POST_CONFIG_FUNC_SET - FUNCPTR * pArg"* The bridge post-configuration pass initialization routine is* provided so that the BSP Developer can initialize the bridge device* after the bus that the bridge implements has been enumerated.  This* routine is specified by calling pciAutoCfgCtl() with the* PCI_BRIDGE_POST_CONFIG_FUNC_SET command* .CS* pciAutoCfgCtl(pCookie, PCI_BRIDGE_POST_CONFIG_FUNC_SET,*         sysPciAutoconfigPostEnumBridgeInit);* .CE

⌨️ 快捷键说明

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