From 5de270feba04b7b9d0ea24789b67224b2060733e Mon Sep 17 00:00:00 2001 From: hpa Date: Tue, 4 Jan 2005 23:48:29 +0000 Subject: [PATCH] Fix PCI access functions --- com32/include/sys/pci.h | 12 ++++++------ com32/lib/Makefile | 4 +++- com32/lib/pci/readb.c | 15 +++++++++++++++ com32/lib/pci/readl.c | 15 +++++++++++++++ com32/lib/pci/readw.c | 15 +++++++++++++++ com32/lib/pci/writeb.c | 12 ++++++++++++ com32/lib/pci/writel.c | 12 ++++++++++++ com32/lib/pci/writew.c | 12 ++++++++++++ 8 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 com32/lib/pci/readb.c create mode 100644 com32/lib/pci/readl.c create mode 100644 com32/lib/pci/readw.c create mode 100644 com32/lib/pci/writeb.c create mode 100644 com32/lib/pci/writel.c create mode 100644 com32/lib/pci/writew.c diff --git a/com32/include/sys/pci.h b/com32/include/sys/pci.h index 9a01cc4..03d8884 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 522761b..18c952e 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 0000000..ac0efaa --- /dev/null +++ b/com32/lib/pci/readb.c @@ -0,0 +1,15 @@ +#include +#include +#include + +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 0000000..1cd43c0 --- /dev/null +++ b/com32/lib/pci/readl.c @@ -0,0 +1,15 @@ +#include +#include +#include + +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 0000000..b7558a6 --- /dev/null +++ b/com32/lib/pci/readw.c @@ -0,0 +1,15 @@ +#include +#include +#include + +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 0000000..db399cd --- /dev/null +++ b/com32/lib/pci/writeb.c @@ -0,0 +1,12 @@ +#include +#include +#include + +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 0000000..cfe58d6 --- /dev/null +++ b/com32/lib/pci/writel.c @@ -0,0 +1,12 @@ +#include +#include +#include + +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 0000000..805ca50 --- /dev/null +++ b/com32/lib/pci/writew.c @@ -0,0 +1,12 @@ +#include +#include +#include + +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); +} -- 2.7.4