aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhpa <hpa>2005-01-04 23:48:29 +0000
committerhpa <hpa>2005-01-04 23:48:29 +0000
commit5de270feba04b7b9d0ea24789b67224b2060733e (patch)
treedd8851ee71b895303bb1d05fe8e766f54eaeb4b9
parent0f5815800c602279e8a764441a16fd5478c0f387 (diff)
downloadsyslinux-elf-5de270feba04b7b9d0ea24789b67224b2060733e.tar.gz
syslinux-elf-5de270feba04b7b9d0ea24789b67224b2060733e.tar.xz
syslinux-elf-5de270feba04b7b9d0ea24789b67224b2060733e.zip
Fix PCI access functions
-rw-r--r--com32/include/sys/pci.h12
-rw-r--r--com32/lib/Makefile4
-rw-r--r--com32/lib/pci/readb.c15
-rw-r--r--com32/lib/pci/readl.c15
-rw-r--r--com32/lib/pci/readw.c15
-rw-r--r--com32/lib/pci/writeb.c12
-rw-r--r--com32/lib/pci/writel.c12
-rw-r--r--com32/lib/pci/writew.c12
8 files changed, 90 insertions, 7 deletions
diff --git a/com32/include/sys/pci.h b/com32/include/sys/pci.h
index 9a01cc47..03d8884f 100644
--- a/com32/include/sys/pci.h
+++ b/com32/include/sys/pci.h
@@ -13,11 +13,11 @@ static inline pciaddr_t pci_mkaddr(uint32_t bus, uint32_t dev,
((func & 0x07) << 8) | (reg & 0xff);
}
-uint8_t pci_read8(pciaddr_t a);
-uint16_t pci_read16(pciaddr_t a);
-uint32_t pci_read32(pciaddr_t a);
-void pci_write8(uint8_t v, pciaddr_t a);
-void pci_write16(uint16_t v, pciaddr_t a);
-void pci_write32(uint32_t v, pciaddr_t a);
+uint8_t pci_readb(pciaddr_t a);
+uint16_t pci_readw(pciaddr_t a);
+uint32_t pci_readl(pciaddr_t a);
+void pci_writeb(uint8_t v, pciaddr_t a);
+void pci_writew(uint16_t v, pciaddr_t a);
+void pci_writel(uint32_t v, pciaddr_t a);
#endif /* _SYS_PCI_H */
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index 522761b5..18c952e1 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -25,7 +25,9 @@ LIBOBJS = abort.o atexit.o atoi.o atol.o atoll.o calloc.o creat.o \
sys/stdcon_read.o sys/stdcon_write.o sys/rawcon_read.o \
sys/rawcon_write.o sys/err_read.o sys/err_write.o \
sys/null_read.o sys/null_write.o sys/serial_write.o \
- sys/ansicon_write.o sys/ansiserial_write.o
+ sys/ansicon_write.o sys/ansiserial_write.o \
+ pci/readb.o pci/readw.o pci/readl.o \
+ pci/writeb.o pci/writew.o pci/writel.o
BINDIR = /usr/bin
LIBDIR = /usr/lib
diff --git a/com32/lib/pci/readb.c b/com32/lib/pci/readb.c
new file mode 100644
index 00000000..ac0efaa4
--- /dev/null
+++ b/com32/lib/pci/readb.c
@@ -0,0 +1,15 @@
+#include <inttypes.h>
+#include <sys/io.h>
+#include <sys/pci.h>
+
+uint8_t pci_readb(pciaddr_t a)
+{
+ uint32_t oldcf8 = inl(0xcf8);
+ uint8_t r;
+
+ outl(a, 0xcf8);
+ r = inb(0xcfc + (a & 3));
+ outl(oldcf8, 0xcf8);
+
+ return r;
+}
diff --git a/com32/lib/pci/readl.c b/com32/lib/pci/readl.c
new file mode 100644
index 00000000..1cd43c03
--- /dev/null
+++ b/com32/lib/pci/readl.c
@@ -0,0 +1,15 @@
+#include <inttypes.h>
+#include <sys/io.h>
+#include <sys/pci.h>
+
+uint32_t pci_readl(pciaddr_t a)
+{
+ uint32_t oldcf8 = inl(0xcf8);
+ uint32_t r;
+
+ outl(a, 0xcf8);
+ r = inl(0xcfc + (a & 3));
+ outl(oldcf8, 0xcf8);
+
+ return r;
+}
diff --git a/com32/lib/pci/readw.c b/com32/lib/pci/readw.c
new file mode 100644
index 00000000..b7558a6c
--- /dev/null
+++ b/com32/lib/pci/readw.c
@@ -0,0 +1,15 @@
+#include <inttypes.h>
+#include <sys/io.h>
+#include <sys/pci.h>
+
+uint16_t pci_readw(pciaddr_t a)
+{
+ uint32_t oldcf8 = inl(0xcf8);
+ uint16_t r;
+
+ outl(a, 0xcf8);
+ r = inw(0xcfc + (a & 3));
+ outl(oldcf8, 0xcf8);
+
+ return r;
+}
diff --git a/com32/lib/pci/writeb.c b/com32/lib/pci/writeb.c
new file mode 100644
index 00000000..db399cd5
--- /dev/null
+++ b/com32/lib/pci/writeb.c
@@ -0,0 +1,12 @@
+#include <inttypes.h>
+#include <sys/io.h>
+#include <sys/pci.h>
+
+void pci_writeb(uint8_t v, pciaddr_t a)
+{
+ uint32_t oldcf8 = inl(0xcf8);
+
+ outl(a, 0xcf8);
+ outb(v, 0xcfc + (a & 3));
+ outl(oldcf8, 0xcf8);
+}
diff --git a/com32/lib/pci/writel.c b/com32/lib/pci/writel.c
new file mode 100644
index 00000000..cfe58d68
--- /dev/null
+++ b/com32/lib/pci/writel.c
@@ -0,0 +1,12 @@
+#include <inttypes.h>
+#include <sys/io.h>
+#include <sys/pci.h>
+
+void pci_writel(uint32_t v, pciaddr_t a)
+{
+ uint32_t oldcf8 = inl(0xcf8);
+
+ outl(a, 0xcf8);
+ outl(v, 0xcfc + (a & 3));
+ outl(oldcf8, 0xcf8);
+}
diff --git a/com32/lib/pci/writew.c b/com32/lib/pci/writew.c
new file mode 100644
index 00000000..805ca50a
--- /dev/null
+++ b/com32/lib/pci/writew.c
@@ -0,0 +1,12 @@
+#include <inttypes.h>
+#include <sys/io.h>
+#include <sys/pci.h>
+
+void pci_writew(uint16_t v, pciaddr_t a)
+{
+ uint32_t oldcf8 = inl(0xcf8);
+
+ outl(a, 0xcf8);
+ outw(v, 0xcfc + (a & 3));
+ outl(oldcf8, 0xcf8);
+}