summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Reinauer <stepan@openbios.org>2005-01-17 11:08:08 +0000
committerStefan Reinauer <stepan@openbios.org>2005-01-17 11:08:08 +0000
commit18588446479fbac700d49e3d5b0061e436ca9be6 (patch)
treecf20273364c20d94d7a02ade8e8c620223f322dc
parent1d6b46060c303f7902ec414f544984af019b9908 (diff)
Make building with different libpci versions easier. The defines might go into
official libpci for 2.2 git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1878 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
-rw-r--r--util/vgabios/Makefile14
-rw-r--r--util/vgabios/pci-userspace.c34
2 files changed, 47 insertions, 1 deletions
diff --git a/util/vgabios/Makefile b/util/vgabios/Makefile
index d1c10f2361..5fadba6ab8 100644
--- a/util/vgabios/Makefile
+++ b/util/vgabios/Makefile
@@ -1,5 +1,17 @@
+#
+# NOTE: You need to add your libpci.a version to CFLAGS below if
+# pci-userspace.c does not build.
+#
+# If you are building on AMD64, you have to use /usr/lib64/libpci.a instead of
+# /usr/lib/...
+#
+
CC = gcc
-CFLAGS = -Wall -Ix86emu/include -O2 -g
+CFLAGS = -Wall -Ix86emu/include -O2 -g \
+ -DLIBPCI_MAJOR_VERSION=2 \
+ -DLIBPCI_MINOR_VERSION=1 \
+ -DLIBPCI_MICRO_VERSION=11
+
INTOBJS = int10.o int15.o int16.o int1a.o inte6.o
OBJECTS = testbios.o helper_exec.o helper_mem.o $(INTOBJS)
diff --git a/util/vgabios/pci-userspace.c b/util/vgabios/pci-userspace.c
index f09c167cec..7578e6f4a8 100644
--- a/util/vgabios/pci-userspace.c
+++ b/util/vgabios/pci-userspace.c
@@ -2,6 +2,12 @@
#include <pci/pci.h>
#include "pci.h"
+#define LIBPCI_CHECK_VERSION(major,minor,micro) \
+ ( (LIBPCI_MAJOR_VERSION > (major)) || \
+ (LIBPCI_MAJOR_VERSION == (major) && LIBPCI_MINOR_VERSION > (minor)) || \
+ (LIBPCI_MAJOR_VERSION == (major) && LIBPCI_MINOR_VERSION == (minor)) && \
+ LIBPCI_MICRO_VERSION >= (micro) )
+
#define PCITAG struct pci_filter *
#define DEBUG_PCI 1
@@ -44,7 +50,11 @@ PCITAG findPci(unsigned short bx)
tag->slot = slot;
tag->func = func;
+#if LIBPCI_CHECK_VERSION(2,1,99)
if (pci_get_dev(pacc, 0, bus, slot, func))
+#else
+ if (pci_get_dev(pacc, bus, slot, func))
+#endif
return tag;
return NULL;
@@ -58,7 +68,11 @@ u32 pciSlotBX(PCITAG tag)
u8 pciReadByte(PCITAG tag, u32 idx)
{
struct pci_dev *d;
+#if LIBPCI_CHECK_VERSION(2,1,99)
if ((d = pci_get_dev(pacc, 0, tag->bus, tag->slot, tag->func)))
+#else
+ if ((d = pci_get_dev(pacc, tag->bus, tag->slot, tag->func)))
+#endif
return pci_read_byte(d, idx);
#ifdef DEBUG_PCI
printf("PCI: device not found while read byte (%x:%x.%x)\n",
@@ -70,7 +84,11 @@ u8 pciReadByte(PCITAG tag, u32 idx)
u16 pciReadWord(PCITAG tag, u32 idx)
{
struct pci_dev *d;
+#if LIBPCI_CHECK_VERSION(2,1,99)
if ((d = pci_get_dev(pacc, 0, tag->bus, tag->slot, tag->func)))
+#else
+ if ((d = pci_get_dev(pacc, tag->bus, tag->slot, tag->func)))
+#endif
return pci_read_word(d, idx);
#ifdef DEBUG_PCI
printf("PCI: device not found while read word (%x:%x.%x)\n",
@@ -82,7 +100,11 @@ u16 pciReadWord(PCITAG tag, u32 idx)
u32 pciReadLong(PCITAG tag, u32 idx)
{
struct pci_dev *d;
+#if LIBPCI_CHECK_VERSION(2,1,99)
if ((d = pci_get_dev(pacc, 0, tag->bus, tag->slot, tag->func)))
+#else
+ if ((d = pci_get_dev(pacc, tag->bus, tag->slot, tag->func)))
+#endif
return pci_read_long(d, idx);
#ifdef DEBUG_PCI
printf("PCI: device not found while read long (%x:%x.%x)\n",
@@ -95,7 +117,11 @@ u32 pciReadLong(PCITAG tag, u32 idx)
void pciWriteLong(PCITAG tag, u32 idx, u32 data)
{
struct pci_dev *d;
+#if LIBPCI_CHECK_VERSION(2,1,99)
if ((d = pci_get_dev(pacc, 0, tag->bus, tag->slot, tag->func)))
+#else
+ if ((d = pci_get_dev(pacc, tag->bus, tag->slot, tag->func)))
+#endif
pci_write_long(d, idx, data);
#ifdef DEBUG_PCI
else
@@ -107,7 +133,11 @@ void pciWriteLong(PCITAG tag, u32 idx, u32 data)
void pciWriteWord(PCITAG tag, u32 idx, u16 data)
{
struct pci_dev *d;
+#if LIBPCI_CHECK_VERSION(2,1,99)
if ((d = pci_get_dev(pacc, 0, tag->bus, tag->slot, tag->func)))
+#else
+ if ((d = pci_get_dev(pacc, tag->bus, tag->slot, tag->func)))
+#endif
pci_write_word(d, idx, data);
#ifdef DEBUG_PCI
else
@@ -120,7 +150,11 @@ void pciWriteWord(PCITAG tag, u32 idx, u16 data)
void pciWriteByte(PCITAG tag, u32 idx, u8 data)
{
struct pci_dev *d;
+#if LIBPCI_CHECK_VERSION(2,1,99)
if ((d = pci_get_dev(pacc, 0, tag->bus, tag->slot, tag->func)))
+#else
+ if ((d = pci_get_dev(pacc, tag->bus, tag->slot, tag->func)))
+#endif
pci_write_long(d, idx, data);
#ifdef DEBUG_PCI
else