#include <pci/pci.h>
#include "pci.h"
+#ifdef PCI_LIB_VERSION
+#define LIBPCI_CHECK_VERSION(major,minor,micro) \
+ ((((major) << 16) | ((minor) << 8) | (micro)) <= PCI_LIB_VERSION)
+#else
+#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) )
+#endif
+
#define PCITAG struct pci_filter *
#define DEBUG_PCI 1
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;
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",
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",
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",
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
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
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