summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/i386/shared/pci/pcibios.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel@rtems.org>2016-03-02 13:25:13 -0600
committerJoel Sherrill <joel@rtems.org>2016-03-10 10:26:48 -0600
commit12c9dc8ff5ad2e1226562474600a5abe8c2e575d (patch)
tree50c652446c8674b72317626dc39e41b085f94d96 /c/src/lib/libbsp/i386/shared/pci/pcibios.c
parentlibtests/syscall01: Explicitly request close (diff)
downloadrtems-12c9dc8ff5ad2e1226562474600a5abe8c2e575d.tar.bz2
pc386: Eliminate pcibios.h and begin removal obsolete PCI BIOS API uses
This first step eliminates the following as public APIs for the pc386 BSP: + pcib_conf_read8 + pcib_conf_read16 + pcib_conf_read32 + pcib_conf_write8 + pcib_conf_write16 + pcib_conf_write32 The if_fxp.c driver uses these enough where I provided local macros to allow the code to be mostly unmodified. On other architectures these names have been used privately. It will take multiple patches to completely eliminate these symbols from the RTEMS source tree. The focus of the first effort is just to eliminate these as a public pc386 API so support can be added for systems without legacy PCI BIOS.
Diffstat (limited to 'c/src/lib/libbsp/i386/shared/pci/pcibios.c')
-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){