[syslinux:master] libpci: merge BIOS read and BIOS write
syslinux-bot for H. Peter Anvin
hpa at zytor.com
Sat Feb 20 22:30:08 PST 2010
Commit-ID: ee43a6e64a6498f457e46f1e2844ab3506ba889d
Gitweb: http://syslinux.zytor.com/commit/ee43a6e64a6498f457e46f1e2844ab3506ba889d
Author: H. Peter Anvin <hpa at zytor.com>
AuthorDate: Sat, 20 Feb 2010 22:26:39 -0800
Committer: H. Peter Anvin <hpa at zytor.com>
CommitDate: Sat, 20 Feb 2010 22:27:28 -0800
libpci: merge BIOS read and BIOS write
Save a few bytes by merging the very similar BIOS read and BIOS write
functions.
Signed-off-by: H. Peter Anvin <hpa at zytor.com>
---
com32/lib/Makefile | 6 +++---
com32/lib/pci/{readbios.c => bios.c} | 4 +++-
com32/lib/pci/pci.h | 3 +--
com32/lib/pci/readx.c | 6 +++---
com32/lib/pci/writebios.c | 14 --------------
com32/lib/pci/writex.c | 5 +++--
6 files changed, 13 insertions(+), 25 deletions(-)
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index 0daa157..250c396 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
similarity index 73%
rename from com32/lib/pci/readbios.c
rename to com32/lib/pci/bios.c
index f8ff3bf..b3c2c57 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 66a1eb5..8d81b0e 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 f073eaa..ed66d5b 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 d367eee..0000000
--- 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 14b2038..d83a1ee 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:
More information about the Syslinux-commits
mailing list