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

📄 sysbuspci.c

📁 LoPEC Early Access VxWorks BSP
💻 C
字号:
/* sysBusPci.c - autoconfig support *//* Copyright 1997-2001 Wind River Systems, Inc. All Rights Reserved *//* Copyright 1999-2001 Motorola, Inc. All Rights Reserved *//*modification history--------------------01g,04apr01,scb  Updated to conform to 1.4 rev of eng. spec01f,22jan01,scb  Cleaned up PCI configuration items.01e,03jan01,cak  Added IBC and IDE to Excluded Devices list01d,18dec00,cak  Added comment for device #11 - PIB01c,15dec00,djs  removed references to PReP01b,09nov00,djs  changes made for initial board bring up01a,02nov00,djs  created based on 01f,28may99,rhk mv2100*//*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/pciConfigLib.h"#include "./pci/pciAutoConfigLib.h"/* defines *//* typedefs *//* globals */PCI_SYSTEM sysParams;static UCHAR intLine [][4] =    {	{ 0xff, 0xff, 0xff, 0xff },  /* device number 0 */	{ 0xff, 0xff, 0xff, 0xff },  /* device number 1 */	{ 0xff, 0xff, 0xff, 0xff },  /* device number 2 */	{ 0xff, 0xff, 0xff, 0xff },  /* device number 3 */	{ 0xff, 0xff, 0xff, 0xff },  /* device number 4 */	{ 0xff, 0xff, 0xff, 0xff },  /* device number 5 */	{ 0xff, 0xff, 0xff, 0xff },  /* device number 6 */	{ 0xff, 0xff, 0xff, 0xff },  /* device number 7 */	{ 0xff, 0xff, 0xff, 0xff },  /* device number 8 */	{ 0xff, 0xff, 0xff, 0xff },  /* device number 9 */	{ 0xff, 0xff, 0xff, 0xff },  /* device number 10 */	{ 0xff, 0xff, 0xff, 0xff },  /* device number 11 PIB */	{ SCSI_INT_LVL,		     /* device number 12 SCSI */	  0xff,	  0xff,	  0xff },	{ 0xff, 0xff, 0xff, 0xff },  /* device number 13 */	{ LN_INT_LVL,		     /* device number 14 I82559 Ethernet */	  0xff,	  0xff,	  0xff },	{ USB_INT_LVL,		     /* device number 15 USB */	  0xff,	  0xff,	  0xff },	{ PCI_INTA_LVL,	             /* device number 16 PMC 1 */	  PCI_INTB_LVL,	  PCI_INTC_LVL,	  PCI_INTD_LVL },	{ PCI_INTB_LVL,	             /* device number 17 PMC 2 */	  PCI_INTC_LVL,	  PCI_INTD_LVL,	  PCI_INTA_LVL },	{ PCI_INTC_LVL,	             /* device number 18 PCI slot 1 */	  PCI_INTD_LVL,	  PCI_INTA_LVL,	  PCI_INTB_LVL },	{ 0xff, 0xff, 0xff, 0xff },  /* device number 19 */	{ 0xff, 0xff, 0xff, 0xff },  /* device number 20 */	{ 0xff, 0xff, 0xff, 0xff },  /* device number 21 */	{ 0xff, 0xff, 0xff, 0xff },  /* device number 22 */	{ 0xff, 0xff, 0xff, 0xff },  /* device number 23 */	{ PCI_INTA_LVL,	             /* device number 24 PMC 1B (PrPMC) */	  PCI_INTB_LVL,	  PCI_INTC_LVL,	  PCI_INTD_LVL },	{ 0xff, 0xff, 0xff, 0xff },  /* device number 25 */	{ PCI_INTC_LVL,	             /* device number 26 PMC 2B (PrPMC) */	  PCI_INTD_LVL,	  PCI_INTA_LVL,	  PCI_INTB_LVL }    };/* 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 );/******************************************************************************** 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 STATUS sysPciAutoConfigInclude    (    PCI_SYSTEM *pSys,		/* input: AutoConfig system information */    PCI_LOC *pciLoc,		/* input: PCI address of this function */    UINT     devVend		/* input: Device/vendor ID number      */    )    {    BOOL retVal = OK;    /* If it's the host bridge then exclude it */    if ((pciLoc->bus == 0) && (pciLoc->device == 0) && (pciLoc->function == 0))	return ERROR;    switch(devVend)	{	/* EXCLUDED Devices */        case PCI_ID_IBC:            retVal = ERROR;            PCI_AUTO_DEBUG_MSG("sysPciAutoconfigInclude: Excluding IBC\n",                    0, 0, 0, 0, 0, 0);            break;        case PCI_ID_IDE:           retVal = ERROR;           PCI_AUTO_DEBUG_MSG("sysPciAutoconfigInclude: Excluding IDE\n",                   0, 0, 0, 0, 0, 0);           break;	/* INCLUDED Devices */	default:	    retVal = OK;            PCI_AUTO_DEBUG_MSG("sysPciAutoconfigInclude: Including unknown device\n",		    0, 0, 0, 0, 0, 0);	    break;	}    return retVal;    }/******************************************************************************** sysPciAutoConfigIntAssign - 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 */    )    {    UCHAR irqValue = 0xff;    /* Calculated value                */    if (intPin == 0) 	return irqValue;    irqValue = intLine [(pFunc->device)][(intPin - 1)];    PCI_AUTO_DEBUG_MSG("intAssign called for device [%d %d %d] IRQ: %d\n",		pFunc->bus, pFunc->device, pFunc->function,		irqValue, 0, 0 );    return (irqValue);    }/********************************************************************************* 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. The "MASK_PCI_xxx_BITS is dependant on the memory map,* (i.e. if CHRP_ADRS_MAP is defined).  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. ** ADDRESS MAPS:** Local CPU Space		    PCI Space (these are the values used *					   for autoconfig setup)* *                          Memory Map B (CHRP)* PCI_MSTR_MEMIO_LOCAL =  ----------------------  PCI_MSTR_MEMIO_BUS =*    0x80000000          |PCI_MSTR_MEMIO_SIZE = |    0x80000000*                        |   0x04000000         |  (nonprefetch)*                        |                      |*                         ----------------------  PCI_MSTR_MEM_BUS =* PCI_MSTR_MEM_LOCAL =   |PCI_MSTR_MEM_SIZE =   |    0x84000000*    0x84000000          |   0x00800000         |   (prefetch)*                         ----------------------*                                 .....** ISA_MSTR_IO_LOCAL =     ---------------------- ISA_MSTR_IO_BUS =*    0xfe000000          |ISA_MSTR_IO_SIZE =    |    0x00000000*                        |   0x00010000         |*                         ----------------------*                                 .....* PCI_MSTR_IO_LOCAL =     ---------------------- PCI_MSTR_IO_BUS =*    0xfe800000          |PCI_MSTR_IO_SIZE =    |    0x00800000*                        |                      |*                         ----------------------** RETURNS: N/A*/void sysPciAutoConfig (void)    {    /*      * 32-bit Non-prefetchable Memory Space,     * Make sure it does not start at address 0 which would turn off a     * PCI address BAR.     */     sysParams.pciMemIo32 = PCI_MSTR_MEMIO_BUS;    sysParams.pciMemIo32Size = PCI_MSTR_MEMIO_SIZE;    if (sysParams.pciMemIo32 == 0)       {       sysParams.pciMemIo32++;       sysParams.pciMemIo32Size--;       }    /*      * 32-bit Prefetchable Memory Space     * Make sure it does not start at address 0 which would turn off a     * PCI address BAR.     */     sysParams.pciMem32 = PCI_MSTR_MEM_BUS;    sysParams.pciMem32Size = PCI_MSTR_MEM_SIZE;    if (sysParams.pciMem32 == 0)	{        sysParams.pciMem32++;        sysParams.pciMem32Size--;	}     /* 16-bit ISA I/O Space - start after legacy devices, kbd, com1, ...  */    sysParams.pciIo16 = (ISA_MSTR_IO_BUS + ISA_LEGACY_SIZE);    sysParams.pciIo16Size = (ISA_MSTR_IO_SIZE - ISA_LEGACY_SIZE);    /*     * 32-bit PCI I/O Space     * Make sure it does not start at address 0 which would turn off a     * PCI address BAR.     */     sysParams.pciIo32 = PCI_MSTR_IO_BUS;    sysParams.pciIo32Size = PCI_MSTR_IO_SIZE;    if (sysParams.pciIo32 == 0)	{        sysParams.pciIo32++;        sysParams.pciIo32Size--;	}    /* Configuration space parameters */     sysParams.cacheSize = (_CACHE_ALIGN_SIZE/4);    sysParams.maxLatency = PCI_LAT_TIMER;    sysParams.autoIntRouting = TRUE;    sysParams.includeRtn = sysPciAutoConfigInclude;    sysParams.intAssignRtn = sysPciAutoConfigIntAsgn;    sysParams.bridgePreConfigInit = NULL;    sysParams.bridgePostConfigInit = NULL;     /* Perform AutoConfig */    pciAutoConfig (&sysParams);     return;    }

⌨️ 快捷键说明

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