PR 608/bsps
	* pci/pcibios.c: BusCountPCI().
This commit is contained in:
Joel Sherrill
2004-09-27 22:49:48 +00:00
parent 092fe28eb2
commit d7034e1c25
2 changed files with 120 additions and 32 deletions

View File

@@ -1,3 +1,9 @@
2004-09-27 Greg Menke <gregory.menke@gsfc.nasa.gov>
PR 608/bsps
* pci/pcibios.c: BusCountPCI().
2004-04-09 Ralf Corsepius <ralf_corsepius@rtems.org> 2004-04-09 Ralf Corsepius <ralf_corsepius@rtems.org>
* irq/irq_asm.S: Include <rtems/asm.h> instead of <asm.h>. * irq/irq_asm.S: Include <rtems/asm.h> instead of <asm.h>.

View File

@@ -18,6 +18,7 @@
* is flat and that stack is big enough * is flat and that stack is big enough
*/ */
static int pcibInitialized = 0; static int pcibInitialized = 0;
static unsigned int pcibEntry; static unsigned int pcibEntry;
@@ -214,6 +215,67 @@ pcib_find_by_class(int classCode, int idx, int *sig)
#define PCI_MAX_DEVICES 16 #define PCI_MAX_DEVICES 16
#define PCI_MAX_FUNCTIONS 8 #define PCI_MAX_FUNCTIONS 8
#define PCI_VENDOR_ID 0x00 /* 16 bits */
#define PCI_DEVICE_ID 0x02 /* 16 bits */
#define PCI_CLASS_REVISION 0x08
#define PCI_HEADER_TYPE 0x0e
#define PCI_SUBORDINATE_BUS 0x1a
#define PCI_CLASS_BRIDGE_PCI 0x0604
static unsigned8 ucBusCount = 0xff;
int
BusCountPCI()
{
if( ucBusCount == 0xff )
{
unsigned char bus,dev,hd;
unsigned int d;
int sig;
ucBusCount = 0;
for(bus=0; bus< 0xff; bus++)
{
for(dev=0; dev<PCI_MAX_DEVICES; dev++)
{
sig = PCIB_DEVSIG_MAKE(bus,dev,0);
pcib_conf_read32(sig, PCI_VENDOR_ID, &d);
if( d != -1 )
{
pcib_conf_read32(sig, PCI_CLASS_REVISION, &d);
if( (d >> 16) == PCI_CLASS_BRIDGE_PCI )
{
pcib_conf_read8(sig, PCI_SUBORDINATE_BUS, &hd);
if( hd > ucBusCount )
ucBusCount = hd;
}
}
}
}
if( ucBusCount == 0 )
{
printk("BusCountPCI() found 0 busses, assuming 1\n");
ucBusCount = 1;
}
else if( ucBusCount == 0xff )
{
printk("BusCountPCI() found 0xff busses, assuming 1\n");
ucBusCount = 1;
}
}
return ucBusCount;
}
int int
BSP_pciFindDevice( unsigned short vendorid, unsigned short deviceid, BSP_pciFindDevice( unsigned short vendorid, unsigned short deviceid,
int instance, int *pbus, int *pdev, int *pfun ) int instance, int *pbus, int *pdev, int *pfun )
@@ -268,6 +330,9 @@ BSP_pciFindDevice( unsigned short vendorid, unsigned short deviceid,
return -1; return -1;
} }
/* /*
* Generate Special Cycle * Generate Special Cycle
*/ */
@@ -298,6 +363,7 @@ pcib_special_cycle(int busNo, int data)
return pcib_convert_err((pcibExchg[0] >> 8) & 0xff); return pcib_convert_err((pcibExchg[0] >> 8) & 0xff);
} }
/* /*
* Read byte from config space * Read byte from config space
*/ */
@@ -335,6 +401,7 @@ pcib_conf_read8(int sig, int off, unsigned char *data)
return PCIB_ERR_SUCCESS; return PCIB_ERR_SUCCESS;
} }
/* /*
* Read word from config space * Read word from config space
*/ */
@@ -372,6 +439,7 @@ pcib_conf_read16(int sig, int off, unsigned short *data)
return PCIB_ERR_SUCCESS; return PCIB_ERR_SUCCESS;
} }
/* /*
* Read dword from config space * Read dword from config space
*/ */
@@ -409,6 +477,7 @@ pcib_conf_read32(int sig, int off, unsigned int *data)
return PCIB_ERR_SUCCESS; return PCIB_ERR_SUCCESS;
} }
/* /*
* Write byte into config space * Write byte into config space
*/ */
@@ -471,6 +540,8 @@ pcib_conf_write16(int sig, int off, unsigned int data)
return pcib_convert_err((pcibExchg[0] >> 8) & 0xff); return pcib_convert_err((pcibExchg[0] >> 8) & 0xff);
} }
/* /*
* Write dword into config space * Write dword into config space
*/ */
@@ -502,6 +573,7 @@ pcib_conf_write32(int sig, int off, unsigned int data)
return pcib_convert_err((pcibExchg[0] >> 8) & 0xff); return pcib_convert_err((pcibExchg[0] >> 8) & 0xff);
} }
static int static int
pcib_convert_err(int err) pcib_convert_err(int err)
{ {
@@ -522,3 +594,13 @@ pcib_convert_err(int err)
} }
return PCIB_ERR_NOFUNC; return PCIB_ERR_NOFUNC;
} }