forked from Imagelibrary/rtems
2004-09-27 Greg Menke <gregory.menke@gsfc.nasa.gov>
PR 608/bsps * pci/pcibios.c: BusCountPCI().
This commit is contained in:
@@ -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>
|
||||
|
||||
* irq/irq_asm.S: Include <rtems/asm.h> instead of <asm.h>.
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* is flat and that stack is big enough
|
||||
*/
|
||||
|
||||
|
||||
static int pcibInitialized = 0;
|
||||
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_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
|
||||
BSP_pciFindDevice( unsigned short vendorid, unsigned short deviceid,
|
||||
int instance, int *pbus, int *pdev, int *pfun )
|
||||
@@ -268,6 +330,9 @@ BSP_pciFindDevice( unsigned short vendorid, unsigned short deviceid,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Generate Special Cycle
|
||||
*/
|
||||
@@ -298,6 +363,7 @@ pcib_special_cycle(int busNo, int data)
|
||||
return pcib_convert_err((pcibExchg[0] >> 8) & 0xff);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Read byte from config space
|
||||
*/
|
||||
@@ -335,6 +401,7 @@ pcib_conf_read8(int sig, int off, unsigned char *data)
|
||||
return PCIB_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Read word from config space
|
||||
*/
|
||||
@@ -372,6 +439,7 @@ pcib_conf_read16(int sig, int off, unsigned short *data)
|
||||
return PCIB_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Read dword from config space
|
||||
*/
|
||||
@@ -409,6 +477,7 @@ pcib_conf_read32(int sig, int off, unsigned int *data)
|
||||
return PCIB_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
pcib_convert_err(int err)
|
||||
{
|
||||
@@ -522,3 +594,13 @@ pcib_convert_err(int err)
|
||||
}
|
||||
return PCIB_ERR_NOFUNC;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user