aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2010-02-20 22:26:39 -0800
committerH. Peter Anvin <hpa@zytor.com>2010-02-20 22:27:28 -0800
commitee43a6e64a6498f457e46f1e2844ab3506ba889d (patch)
tree9808fb8bb8e65b7256d7551ba6a32297e8389636
parent9591feebc4ea6f5469027f26ef0759c91e42cafe (diff)
downloadsyslinux.git-ee43a6e64a6498f457e46f1e2844ab3506ba889d.tar.gz
syslinux.git-ee43a6e64a6498f457e46f1e2844ab3506ba889d.tar.xz
syslinux.git-ee43a6e64a6498f457e46f1e2844ab3506ba889d.zip
libpci: merge BIOS read and BIOS writeHEADmaster
Save a few bytes by merging the very similar BIOS read and BIOS write functions. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--com32/lib/Makefile6
-rw-r--r--com32/lib/pci/bios.c (renamed from com32/lib/pci/readbios.c)4
-rw-r--r--com32/lib/pci/pci.h3
-rw-r--r--com32/lib/pci/readx.c6
-rw-r--r--com32/lib/pci/writebios.c14
-rw-r--r--com32/lib/pci/writex.c5
6 files changed, 13 insertions, 25 deletions
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index 0daa157f..250c3962 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -66,9 +66,9 @@ LIBOBJS = \
sys/vesa/alphatbl.o sys/vesa/screencpy.o sys/vesa/fmtpixel.o \
sys/vesa/i915resolution.o \
\
- pci/cfgtype.o pci/scan.o \
- pci/readb.o pci/readw.o pci/readl.o pci/readbios.o \
- pci/writeb.o pci/writew.o pci/writel.o pci/writebios.o \
+ pci/cfgtype.o pci/scan.o pci/bios.o \
+ pci/readb.o pci/readw.o pci/readl.o \
+ pci/writeb.o pci/writew.o pci/writel.o \
\
zlib/adler32.o zlib/compress.o zlib/crc32.o \
zlib/uncompr.o zlib/deflate.o zlib/trees.o zlib/zutil.o \
diff --git a/com32/lib/pci/readbios.c b/com32/lib/pci/bios.c
index f8ff3bff..b3c2c57d 100644
--- a/com32/lib/pci/readbios.c
+++ b/com32/lib/pci/bios.c
@@ -2,13 +2,15 @@
#include <string.h>
#include "pci/pci.h"
-uint32_t __pci_read_bios(uint32_t call, pciaddr_t a)
+uint32_t __pci_read_write_bios(uint32_t call, uint32_t v, pciaddr_t a)
{
com32sys_t rs;
memset(&rs, 0, sizeof rs);
rs.eax.w[0] = call;
rs.ebx.w[0] = a >> 8; /* bus:device:function */
rs.edi.b[0] = a; /* address:reg */
+ rs.ecx.l = v;
+ rs.eflags.l = EFLAGS_CF;
__intcall(0x1a, &rs, &rs);
return (rs.eflags.l & EFLAGS_CF) ? ~(uint32_t) 0 : rs.ecx.l;
diff --git a/com32/lib/pci/pci.h b/com32/lib/pci/pci.h
index 66a1eb50..8d81b0e4 100644
--- a/com32/lib/pci/pci.h
+++ b/com32/lib/pci/pci.h
@@ -10,7 +10,6 @@
#include <sys/cpu.h>
extern enum pci_config_type __pci_cfg_type;
-extern uint32_t __pci_read_bios(uint32_t call, pciaddr_t a);
-extern void __pci_write_bios(uint32_t call, uint32_t v, pciaddr_t a);
+extern uint32_t __pci_read_write_bios(uint32_t call, uint32_t v, pciaddr_t a);
#endif /* PCI_PCI_H */
diff --git a/com32/lib/pci/readx.c b/com32/lib/pci/readx.c
index f073eaa1..ed66d5b2 100644
--- a/com32/lib/pci/readx.c
+++ b/com32/lib/pci/readx.c
@@ -1,7 +1,7 @@
#include "pci/pci.h"
-#include <string.h>
-TYPE BWL(pci_read) (pciaddr_t a) {
+TYPE BWL(pci_read) (pciaddr_t a)
+{
TYPE r;
for (;;) {
@@ -42,7 +42,7 @@ TYPE BWL(pci_read) (pciaddr_t a) {
return r;
case PCI_CFG_BIOS:
- return (TYPE) __pci_read_bios(BIOSCALL, a);
+ return (TYPE) __pci_read_write_bios(BIOSCALL, 0, a);
default:
return (TYPE) ~ 0;
diff --git a/com32/lib/pci/writebios.c b/com32/lib/pci/writebios.c
deleted file mode 100644
index d367eee7..00000000
--- a/com32/lib/pci/writebios.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <com32.h>
-#include <string.h>
-#include "pci/pci.h"
-
-void __pci_write_bios(uint32_t call, uint32_t v, pciaddr_t a)
-{
- com32sys_t rs;
- memset(&rs, 0, sizeof rs);
- rs.eax.w[0] = call;
- rs.ebx.w[0] = a >> 8; /* bus:device:function */
- rs.edi.b[0] = a; /* address:reg */
- rs.ecx.l = v;
- __intcall(0x1a, &rs, NULL);
-}
diff --git a/com32/lib/pci/writex.c b/com32/lib/pci/writex.c
index 14b20380..d83a1eed 100644
--- a/com32/lib/pci/writex.c
+++ b/com32/lib/pci/writex.c
@@ -1,6 +1,7 @@
#include "pci/pci.h"
-void BWL(pci_write) (TYPE v, pciaddr_t a) {
+void BWL(pci_write)(TYPE v, pciaddr_t a)
+{
for (;;) {
switch (__pci_cfg_type) {
case PCI_CFG_AUTO:
@@ -39,7 +40,7 @@ void BWL(pci_write) (TYPE v, pciaddr_t a) {
return;
case PCI_CFG_BIOS:
- __pci_write_bios(BIOSCALL, v, a);
+ __pci_read_write_bios(BIOSCALL, v, a);
return;
default: