* The PCI Library -- FreeBSD /dev/pci access
*
* Copyright (c) 1999 Jari Kirma <kirma@cs.hut.fi>
+ * Updated in 2003 by Samy Al Bahra <samy@kerneled.com>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
-/*
- * Read functionality of this driver is briefly tested, and seems
- * to supply basic information correctly, but I promise no more.
- */
-
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
-
-#include <pci/pcivar.h>
-#include <pci/pci_ioctl.h>
+#include <osreldate.h>
+#include <stdint.h>
+
+#ifdef __FreeBSD_kernel_version
+# ifndef __FreeBSD_version
+# define __FreeBSD_version __FreeBSD_kernel_version
+# endif
+#endif
+
+#if __FreeBSD_version < 500000
+# include <pci/pcivar.h>
+#else
+# include <dev/pci/pcivar.h>
+#endif
+
+#if __FreeBSD_version < 430000
+# include <pci/pci_ioctl.h>
+#else
+# include <sys/pciio.h>
+#endif
#include "internal.h"
static void
fbsd_config(struct pci_access *a)
{
- a->method_params[PCI_ACCESS_FBSD_DEVICE] = PATH_FBSD_DEVICE;
+ a->method_params[PCI_ACCESS_FBSD_DEVICE] = PCI_PATH_FBSD_DEVICE;
}
static int
return pci_generic_block_read(d, pos, buf, len);
}
+ if (pos >= 256)
+ return 0;
+
pi.pi_sel.pc_bus = d->bus;
pi.pi_sel.pc_dev = d->dev;
pi.pi_sel.pc_func = d->func;
return pci_generic_block_write(d, pos, buf, len);
}
+ if (pos >= 256)
+ return 0;
+
pi.pi_sel.pc_bus = d->bus;
pi.pi_sel.pc_dev = d->dev;
pi.pi_sel.pc_func = d->func;