summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/i386/shared/pci/pcibios.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--c/src/lib/libbsp/i386/shared/pci/pcibios.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/c/src/lib/libbsp/i386/shared/pci/pcibios.c b/c/src/lib/libbsp/i386/shared/pci/pcibios.c
index 870721f1f8..ec19bb3732 100644
--- a/c/src/lib/libbsp/i386/shared/pci/pcibios.c
+++ b/c/src/lib/libbsp/i386/shared/pci/pcibios.c
@@ -7,7 +7,7 @@
#include <rtems.h>
#include <bsp.h>
-#include <pcibios.h>
+#include <rtems/pci.h>
#include <string.h> /* memcpy */
@@ -15,8 +15,6 @@
* This is simpliest possible PCI BIOS, it assumes that addressing
* is flat and that stack is big enough
*/
-
-
static int pcibInitialized = 0;
static unsigned int pcibEntry;
@@ -30,6 +28,18 @@ static volatile unsigned int pcibExchg[5];
static int pcib_convert_err(int err);
+/** @brief
+ * Make device signature from bus number, device numebr and function
+ * number
+ */
+#define PCIB_DEVSIG_MAKE(b,d,f) ((b<<8)|(d<<3)|(f))
+
+/** @brief
+ * Extract valrous part from device signature
+ */
+#define PCIB_DEVSIG_BUS(x) (((x)>>8) &0xff)
+#define PCIB_DEVSIG_DEV(x) (((x)>>3) & 0x1f)
+#define PCIB_DEVSIG_FUNC(x) ((x) & 0x7)
/*
* Detects presense of PCI BIOS, returns
* error code
@@ -232,33 +242,30 @@ pci_bus_count(void)
unsigned char nfn;
unsigned char hd = 0;
uint32_t d = 0;
- 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);
+ pci_read_config_dword(bus, dev, fun, PCI_VENDOR_ID, &d);
if ( -1 == d ) {
continue;
}
- pcib_conf_read8(sig, PCI_HEADER_TYPE, &hd);
+ pci_read_config_byte(bus, dev, fun, PCI_HEADER_TYPE, &hd);
nfn = (hd & 0x80) ? PCI_MAX_FUNCTIONS : 1;
for ( fun=0; fun<nfn; fun++ ) {
- sig = PCIB_DEVSIG_MAKE(bus,dev,fun);
- pcib_conf_read32(sig, PCI_VENDOR_ID, &d);
+ pci_read_config_dword(bus, dev, fun, PCI_VENDOR_ID, &d);
if ( -1 == d )
continue;
- pcib_conf_read32(sig, PCI_CLASS_REVISION, &d);
+ pci_read_config_dword(bus, dev, fun, PCI_CLASS_REVISION, &d);
if ( (d >> 16) == PCI_CLASS_BRIDGE_PCI ) {
- pcib_conf_read8(sig, PCI_SUBORDINATE_BUS, &hd);
+ pci_read_config_byte(bus, dev, fun, PCI_SUBORDINATE_BUS, &hd);
if ( hd > ucBusCount )
ucBusCount = hd;
@@ -313,7 +320,7 @@ pcib_special_cycle(int busNo, int data)
/*
* Read byte from config space
*/
-int
+static int
pcib_conf_read8(int sig, int off, uint8_t *data)
{
if (!pcibInitialized) {
@@ -349,7 +356,7 @@ pcib_conf_read8(int sig, int off, uint8_t *data)
/*
* Read word from config space
*/
-int
+static int
pcib_conf_read16(int sig, int off, uint16_t *data)
{
if (!pcibInitialized) {
@@ -385,7 +392,7 @@ pcib_conf_read16(int sig, int off, uint16_t *data)
/*
* Read dword from config space
*/
-int
+static int
pcib_conf_read32(int sig, int off, uint32_t *data)
{
if (!pcibInitialized) {
@@ -421,7 +428,7 @@ pcib_conf_read32(int sig, int off, uint32_t *data)
/*
* Write byte into config space
*/
-int
+static int
pcib_conf_write8(int sig, int off, uint8_t data)
{
if (!pcibInitialized) {
@@ -451,7 +458,7 @@ pcib_conf_write8(int sig, int off, uint8_t data)
/*
* Write word into config space
*/
-int
+static int
pcib_conf_write16(int sig, int off, uint16_t data)
{
if (!pcibInitialized) {
@@ -483,7 +490,7 @@ pcib_conf_write16(int sig, int off, uint16_t data)
/*
* Write dword into config space
*/
-int
+static int
pcib_conf_write32(int sig, int off, uint32_t data)
{
if (!pcibInitialized){