summaryrefslogtreecommitdiffstats
path: root/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
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 '')
-rw-r--r--c/src/lib/libbsp/i386/Makefile.am1
-rw-r--r--c/src/lib/libbsp/i386/pc386/Makefile.am4
-rw-r--r--c/src/lib/libbsp/i386/pc386/preinstall.am4
-rw-r--r--c/src/lib/libbsp/i386/shared/pci/pcibios.c41
-rw-r--r--c/src/lib/libbsp/i386/shared/pci/pcibios.h62
-rw-r--r--c/src/libchip/network/if_fxp.c43
6 files changed, 67 insertions, 88 deletions
diff --git a/c/src/lib/libbsp/i386/Makefile.am b/c/src/lib/libbsp/i386/Makefile.am
index 397e8e6021..f10b764067 100644
--- a/c/src/lib/libbsp/i386/Makefile.am
+++ b/c/src/lib/libbsp/i386/Makefile.am
@@ -21,7 +21,6 @@ EXTRA_DIST += shared/irq/idt.c
EXTRA_DIST += shared/irq/irq_init.c
# shared/pci
-EXTRA_DIST += shared/pci/pcibios.h
EXTRA_DIST += shared/pci/pcibios.c
include $(top_srcdir)/../../../automake/subdirs.am
diff --git a/c/src/lib/libbsp/i386/pc386/Makefile.am b/c/src/lib/libbsp/i386/pc386/Makefile.am
index 1d52cf411d..a9c645bb67 100644
--- a/c/src/lib/libbsp/i386/pc386/Makefile.am
+++ b/c/src/lib/libbsp/i386/pc386/Makefile.am
@@ -139,10 +139,8 @@ libbsp_a_SOURCES += ../../i386/shared/comm/gdb_glue.c
# gnat
libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
-include_HEADERS += ../../i386/shared/pci/pcibios.h
# pci
-libbsp_a_SOURCES += ../../i386/shared/pci/pcibios.c \
- ../../i386/shared/pci/pcibios.h
+libbsp_a_SOURCES += ../../i386/shared/pci/pcibios.c
include_HEADERS += ../../i386/shared/comm/uart.h
# startup
diff --git a/c/src/lib/libbsp/i386/pc386/preinstall.am b/c/src/lib/libbsp/i386/pc386/preinstall.am
index 1b9f862e58..46b646727a 100644
--- a/c/src/lib/libbsp/i386/pc386/preinstall.am
+++ b/c/src/lib/libbsp/i386/pc386/preinstall.am
@@ -166,10 +166,6 @@ $(PROJECT_INCLUDE)/rtems/console_private.h: ../../shared/console_private.h $(PRO
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/console_private.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/console_private.h
-$(PROJECT_INCLUDE)/pcibios.h: ../../i386/shared/pci/pcibios.h $(PROJECT_INCLUDE)/$(dirstamp)
- $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/pcibios.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/pcibios.h
-
$(PROJECT_INCLUDE)/uart.h: ../../i386/shared/comm/uart.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/uart.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/uart.h
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){
diff --git a/c/src/lib/libbsp/i386/shared/pci/pcibios.h b/c/src/lib/libbsp/i386/shared/pci/pcibios.h
deleted file mode 100644
index 0bd693ab0e..0000000000
--- a/c/src/lib/libbsp/i386/shared/pci/pcibios.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * @file
- * @ingroup i386_pcibios
- * @brief
- */
-
-/*
- * This software is Copyright (C) 1998 by T.sqware - all rights limited
- * It is provided in to the public domain "as is", can be freely modified
- * as far as this copyight notice is kept unchanged, but does not imply
- * an endorsement by T.sqware of the product in which it is included.
- */
-
-/**
- * @defgroup i386_pcibios
- * @ingroup i386_pci
- * @brief
- * @{
- */
-
-#ifndef _PCIB_H
-#define _PCIB_H
-
-#include <rtems/pci.h>
-
-/** @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)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int pcib_find_by_class(int classCode, int idx, int *sig);
-int pcib_special_cycle(int busNo, int data);
-int pcib_conf_read8(int sig, int off, uint8_t *data);
-int pcib_conf_read16(int sig, int off, uint16_t *data);
-int pcib_conf_read32(int sig, int off, uint32_t *data);
-int pcib_conf_write8(int sig, int off, uint8_t data);
-int pcib_conf_write16(int sig, int off, uint16_t data);
-int pcib_conf_write32(int sig, int off, uint32_t data);
-
-int
-pci_find_device( unsigned short vendorid, unsigned short deviceid,
- int instance, int *pbus, int *pdev, int *pfun );
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _PCIB_H */
diff --git a/c/src/libchip/network/if_fxp.c b/c/src/libchip/network/if_fxp.c
index 9d223bb11f..ce59db1599 100644
--- a/c/src/libchip/network/if_fxp.c
+++ b/c/src/libchip/network/if_fxp.c
@@ -75,7 +75,6 @@
#include <sys/malloc.h>
#include <sys/systm.h>
#include <bsp.h>
-#include <pcibios.h>
#include <bsp/irq.h>
#include <rtems/pci.h>
@@ -352,6 +351,48 @@ fxp_dma_wait(volatile u_int16_t *status, struct fxp_softc *sc)
device_printf(sc->dev, "DMA timeout\n");
}
+/*
+ * These macros and instantiations define PCI Configuration Space accessors
+ * which use the legacy API based on the PCI BIOS only used by pc386.
+ * This was the only device driver using these.
+ *
+ * TBD: It may be worth it to fix this driver to use the current PCI API rather
+ * than this legacy PC386 API.
+ */
+#define PCIB_DEVSIG_BUS(x) (((x)>>8) &0xff)
+#define PCIB_DEVSIG_DEV(x) (((x)>>3) & 0x1f)
+#define PCIB_DEVSIG_FUNC(x) ((x) & 0x7)
+#define PCIB_DEVSIG_MAKE(b,d,f) ((b<<8)|(d<<3)|(f))
+
+#define PCI_CONF_ACCESSOR(_confop, _baseop, _type) \
+ /* prototype before body */ \
+ static inline int _confop ( \
+ int signature, \
+ int offset, \
+ _type data ); \
+ \
+ static inline int _confop ( \
+ int signature, \
+ int offset, \
+ _type data ) \
+ { \
+ _baseop( \
+ PCIB_DEVSIG_BUS(signature), \
+ PCIB_DEVSIG_DEV(signature), \
+ PCIB_DEVSIG_FUNC(signature), \
+ offset, \
+ data \
+ ); \
+ return PCIB_ERR_SUCCESS; \
+ }
+
+PCI_CONF_ACCESSOR( pcib_conf_read8, pci_read_config_byte, uint8_t * );
+PCI_CONF_ACCESSOR( pcib_conf_read16, pci_read_config_word, uint16_t * );
+PCI_CONF_ACCESSOR( pcib_conf_read32, pci_read_config_dword, uint32_t * );
+PCI_CONF_ACCESSOR( pcib_conf_write8, pci_write_config_byte, uint8_t );
+PCI_CONF_ACCESSOR( pcib_conf_write16, pci_write_config_word, uint16_t );
+PCI_CONF_ACCESSOR( pcib_conf_write32, pci_write_config_dword, uint32_t );
+
static __inline unsigned int pci_get_vendor(struct fxp_softc *sc) {
u_int16_t vendor;
pcib_conf_read16(sc->pci_signature,0,&vendor);