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.
This commit is contained in:
Joel Sherrill
2016-03-02 13:25:13 -06:00
parent 354064b92a
commit 12c9dc8ff5
6 changed files with 67 additions and 88 deletions

View File

@@ -21,7 +21,6 @@ EXTRA_DIST += shared/irq/idt.c
EXTRA_DIST += shared/irq/irq_init.c EXTRA_DIST += shared/irq/irq_init.c
# shared/pci # shared/pci
EXTRA_DIST += shared/pci/pcibios.h
EXTRA_DIST += shared/pci/pcibios.c EXTRA_DIST += shared/pci/pcibios.c
include $(top_srcdir)/../../../automake/subdirs.am include $(top_srcdir)/../../../automake/subdirs.am

View File

@@ -139,10 +139,8 @@ libbsp_a_SOURCES += ../../i386/shared/comm/gdb_glue.c
# gnat # gnat
libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
include_HEADERS += ../../i386/shared/pci/pcibios.h
# pci # pci
libbsp_a_SOURCES += ../../i386/shared/pci/pcibios.c \ libbsp_a_SOURCES += ../../i386/shared/pci/pcibios.c
../../i386/shared/pci/pcibios.h
include_HEADERS += ../../i386/shared/comm/uart.h include_HEADERS += ../../i386/shared/comm/uart.h
# startup # startup

View File

@@ -166,10 +166,6 @@ $(PROJECT_INCLUDE)/rtems/console_private.h: ../../shared/console_private.h $(PRO
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/console_private.h $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/console_private.h
PREINSTALL_FILES += $(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) $(PROJECT_INCLUDE)/uart.h: ../../i386/shared/comm/uart.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/uart.h $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/uart.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/uart.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/uart.h

View File

@@ -7,7 +7,7 @@
#include <rtems.h> #include <rtems.h>
#include <bsp.h> #include <bsp.h>
#include <pcibios.h> #include <rtems/pci.h>
#include <string.h> /* memcpy */ #include <string.h> /* memcpy */
@@ -15,8 +15,6 @@
* This is simpliest possible PCI BIOS, it assumes that addressing * This is simpliest possible PCI BIOS, it assumes that addressing
* 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;
@@ -30,6 +28,18 @@ static volatile unsigned int pcibExchg[5];
static int pcib_convert_err(int err); 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 * Detects presense of PCI BIOS, returns
* error code * error code
@@ -232,33 +242,30 @@ pci_bus_count(void)
unsigned char nfn; unsigned char nfn;
unsigned char hd = 0; unsigned char hd = 0;
uint32_t d = 0; uint32_t d = 0;
int sig;
ucBusCount = 0; ucBusCount = 0;
for (bus=0; bus< 0xff; bus++) { for (bus=0; bus< 0xff; bus++) {
for (dev=0; dev<PCI_MAX_DEVICES; dev++) { for (dev=0; dev<PCI_MAX_DEVICES; dev++) {
sig = PCIB_DEVSIG_MAKE(bus,dev,0); pci_read_config_dword(bus, dev, fun, PCI_VENDOR_ID, &d);
pcib_conf_read32(sig, PCI_VENDOR_ID, &d);
if ( -1 == d ) { if ( -1 == d ) {
continue; 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; nfn = (hd & 0x80) ? PCI_MAX_FUNCTIONS : 1;
for ( fun=0; fun<nfn; fun++ ) { for ( fun=0; fun<nfn; fun++ ) {
sig = PCIB_DEVSIG_MAKE(bus,dev,fun); pci_read_config_dword(bus, dev, fun, PCI_VENDOR_ID, &d);
pcib_conf_read32(sig, PCI_VENDOR_ID, &d);
if ( -1 == d ) if ( -1 == d )
continue; 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 ) { 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 ) if ( hd > ucBusCount )
ucBusCount = hd; ucBusCount = hd;
@@ -313,7 +320,7 @@ pcib_special_cycle(int busNo, int data)
/* /*
* Read byte from config space * Read byte from config space
*/ */
int static int
pcib_conf_read8(int sig, int off, uint8_t *data) pcib_conf_read8(int sig, int off, uint8_t *data)
{ {
if (!pcibInitialized) { if (!pcibInitialized) {
@@ -349,7 +356,7 @@ pcib_conf_read8(int sig, int off, uint8_t *data)
/* /*
* Read word from config space * Read word from config space
*/ */
int static int
pcib_conf_read16(int sig, int off, uint16_t *data) pcib_conf_read16(int sig, int off, uint16_t *data)
{ {
if (!pcibInitialized) { if (!pcibInitialized) {
@@ -385,7 +392,7 @@ pcib_conf_read16(int sig, int off, uint16_t *data)
/* /*
* Read dword from config space * Read dword from config space
*/ */
int static int
pcib_conf_read32(int sig, int off, uint32_t *data) pcib_conf_read32(int sig, int off, uint32_t *data)
{ {
if (!pcibInitialized) { if (!pcibInitialized) {
@@ -421,7 +428,7 @@ pcib_conf_read32(int sig, int off, uint32_t *data)
/* /*
* Write byte into config space * Write byte into config space
*/ */
int static int
pcib_conf_write8(int sig, int off, uint8_t data) pcib_conf_write8(int sig, int off, uint8_t data)
{ {
if (!pcibInitialized) { if (!pcibInitialized) {
@@ -451,7 +458,7 @@ pcib_conf_write8(int sig, int off, uint8_t data)
/* /*
* Write word into config space * Write word into config space
*/ */
int static int
pcib_conf_write16(int sig, int off, uint16_t data) pcib_conf_write16(int sig, int off, uint16_t data)
{ {
if (!pcibInitialized) { if (!pcibInitialized) {
@@ -483,7 +490,7 @@ pcib_conf_write16(int sig, int off, uint16_t data)
/* /*
* Write dword into config space * Write dword into config space
*/ */
int static int
pcib_conf_write32(int sig, int off, uint32_t data) pcib_conf_write32(int sig, int off, uint32_t data)
{ {
if (!pcibInitialized){ if (!pcibInitialized){

View File

@@ -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 */

View File

@@ -75,7 +75,6 @@
#include <sys/malloc.h> #include <sys/malloc.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <bsp.h> #include <bsp.h>
#include <pcibios.h>
#include <bsp/irq.h> #include <bsp/irq.h>
#include <rtems/pci.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"); 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) { static __inline unsigned int pci_get_vendor(struct fxp_softc *sc) {
u_int16_t vendor; u_int16_t vendor;
pcib_conf_read16(sc->pci_signature,0,&vendor); pcib_conf_read16(sc->pci_signature,0,&vendor);