+2002-12-26 Martin Mares <mj@ucw.cz>
+
+ * Added preliminary version of NetBSD support by Quentin Garnier
+ <netbsd@quatriemek.com>.
+
2002-04-06 Martin Mares <mj@ucw.cz>
* lspci.c: Mention "-xxx" in the help.
(show_htype2): Stub routine.
(scan_config): Write sensible error message if the kernel denies reading of
upper part of the PCI config space.
-
-# $Id: Makefile,v 1.42 2002/03/30 15:42:16 mj Exp $
+# $Id: Makefile,v 1.43 2002/12/26 19:28:33 mj Exp $
# Makefile for Linux PCI Utilities
# (c) 1998--2002 Martin Mares <mj@ucw.cz>
#OPT=-O2 -g
CFLAGS=$(OPT) -Wall -W -Wno-parentheses -Wstrict-prototypes
-VERSION=2.1.10
-#SUFFIX=-pre2
-#SUFFIX=-alpha
-DATE=2002-03-30
+VERSION=2.1.11
+SUFFIX=-pre1
+DATE=2002-12-26
INSTALL=install
DIRINSTALL=install -d
+PCILIB=libpci.a
ifeq ($(shell uname),FreeBSD)
ROOT=/usr/local
PREFIX=/usr/local
else
+ifeq ($(shell uname),NetBSD)
+ROOT=$(PREFIX)
+PCILIB=libpciutils.a
+LDFLAGS+=-lpci
+else
ifeq ($(shell uname),AIX)
ROOT=/usr/local
PREFIX=/usr/local
PREFIX=/usr
endif
endif
+endif
MANDIR=$(shell if [ -d $(PREFIX)/share/man ] ; then echo $(PREFIX)/share/man ; else echo $(PREFIX)/man ; fi)
DISTTMP=/tmp/pciutils-dist
-# $Id: Makefile,v 1.5 2002/03/30 15:39:25 mj Exp $
+# $Id: Makefile,v 1.6 2002/12/26 19:28:33 mj Exp $
# Makefile for The PCI Library
# (c) 1999 Martin Mares <mj@ucw.cz>
OBJS=access.o generic.o dump.o names.o filter.o
INCL=internal.h pci.h config.h
+PCILIB=libpci.a
+
ifdef HAVE_PM_LINUX_PROC
OBJS += proc.o
endif
OBJS += aix-device.o
endif
+ifdef HAVE_PM_NBSD_LIBPCI
+OBJS += nbsd-libpci.o
+PCILIB=libpciutils.a
+endif
+
ifdef HAVE_OWN_HEADER_H
INCL += header.h
endif
-all: libpci.a
+all: $(PCILIB)
-libpci.a: $(OBJS)
+$(PCILIB): $(OBJS)
rm -f $@
ar rcs $@ $^
ranlib $@
dump.o: dump.c $(INCL)
names.o: names.c $(INCL)
filter.o: filter.c $(INCL)
+nbsd-libpci.o: nbsd-libpci.c $(INCL)
/*
- * $Id: access.c,v 1.8 2002/03/30 15:39:25 mj Exp $
+ * $Id: access.c,v 1.9 2002/12/26 19:28:33 mj Exp $
*
* The PCI Library -- User Access
*
#else
NULL,
#endif
+#ifdef HAVE_PM_NBSD_LIBPCI
+ &pm_nbsd_libpci,
+#else
+ NULL,
+#endif
#ifdef HAVE_PM_DUMP
&pm_dump,
#else
echo >>$c '#define HAVE_PM_AIX_DEVICE'
ok=1
;;
+ NetBSD)
+ echo_n " nbsd-libpci"
+ echo >>$c '#define HAVE_PM_NBSD_LIBPCI'
+ echo >>$c '#define PATH_NBSD_DEVICE "/dev/pci0"'
+ ok=1
+ ;;
*)
- echo " The PCI library currently supports only Linux, AIX and FreeBSD"
+ echo " The PCI library currently supports only Linux, AIX, FreeBSD and NetBSD"
exit 1
;;
esac
/*
- * $Id: internal.h,v 1.6 2002/03/30 15:39:25 mj Exp $
+ * $Id: internal.h,v 1.7 2002/12/26 19:28:33 mj Exp $
*
* The PCI Library -- Internal Include File
*
int pci_link_dev(struct pci_access *, struct pci_dev *);
extern struct pci_methods pm_intel_conf1, pm_intel_conf2, pm_linux_proc,
- pm_syscalls, pm_fbsd_device, pm_aix_device, pm_dump;
+ pm_syscalls, pm_fbsd_device, pm_aix_device, pm_nbsd_libpci, pm_dump;
--- /dev/null
+/*
+ * The PCI Library -- NetBSD libpci access
+ * (based on FreeBSD /dev/pci access)
+ *
+ * Copyright (c) 1999 Jari Kirma <kirma@cs.hut.fi>
+ * Copyright (c) 2002 Quentin Garnier <cube@cubidou.net>
+ *
+ * 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.h>
+
+#include "internal.h"
+
+static void
+nbsd_config(struct pci_access *a)
+{
+ a->method_params[PCI_ACCESS_NBSD_LIBPCI] = PATH_NBSD_DEVICE;
+}
+
+static int
+nbsd_detect(struct pci_access *a)
+{
+ char *name = a->method_params[PCI_ACCESS_NBSD_LIBPCI];
+
+ if (access(name, R_OK))
+ {
+ a->warning("Cannot open %s", name);
+ return 0;
+ }
+ a->debug("...using %s", name);
+ return 1;
+}
+
+static void
+nbsd_init(struct pci_access *a)
+{
+ char *name = a->method_params[PCI_ACCESS_NBSD_LIBPCI];
+
+ a->fd = open(name, O_RDWR, 0);
+ if (a->fd < 0)
+ {
+ a->error("nbsd_init: %s open failed", name);
+ }
+}
+
+static void
+nbsd_cleanup(struct pci_access *a)
+{
+ close(a->fd);
+}
+
+static int
+nbsd_read(struct pci_dev *d, int pos, byte *buf, int len)
+{
+ pcireg_t val;
+
+ if (!(len == 1 || len == 2 || len == 4))
+ {
+ return pci_generic_block_read(d, pos, buf, len);
+ }
+
+
+ if (pcibus_conf_read(d->access->fd, d->bus, d->dev, d->func, pos, &val) < 0)
+ d->access->error("nbsd_read: pci_bus_conf_read() failed");
+
+ switch (len)
+ {
+ case 1:
+ buf[0] = (u8) ((val>>16) & 0xff);
+ break;
+ case 2:
+ ((u16 *) buf)[0] = (u16) val;
+ break;
+ case 4:
+ ((u32 *) buf)[0] = (u32) val;
+ break;
+ }
+ return 1;
+}
+
+static int
+nbsd_write(struct pci_dev *d, int pos, byte *buf, int len)
+{
+ pcireg_t val;
+
+ if (!(len == 1 || len == 2 || len == 4))
+ {
+ return pci_generic_block_write(d, pos, buf, len);
+ }
+
+ switch (len)
+ {
+ case 1:
+ val = buf[0];
+ break;
+ case 2:
+ val = ((u16 *) buf)[0];
+ break;
+ case 4:
+ val = ((u32 *) buf)[0];
+ break;
+ }
+
+ if (pcibus_conf_write(d->access->fd, d->bus, d->dev, d->func, pos, val) < 0)
+ d->access->error("nbsd_write: pci_bus_conf_write() failed");
+
+ return 1;
+}
+
+struct pci_methods pm_nbsd_libpci = {
+ "NetBSD-libpci",
+ nbsd_config,
+ nbsd_detect,
+ nbsd_init,
+ nbsd_cleanup,
+ pci_generic_scan,
+ pci_generic_fill_info,
+ nbsd_read,
+ nbsd_write,
+ NULL, /* dev_init */
+ NULL /* dev_cleanup */
+};
/*
- * $Id: pci.h,v 1.9 2002/03/30 15:39:25 mj Exp $
+ * $Id: pci.h,v 1.10 2002/12/26 19:28:33 mj Exp $
*
* The PCI Library
*
typedef u_int32_t u32;
#endif
+#ifdef OS_NETBSD
+#include <sys/types.h>
+
+typedef u_int8_t byte;
+typedef u_int8_t u8;
+typedef u_int16_t word;
+typedef u_int16_t u16;
+typedef u_int32_t u32;
+#endif
+
#ifdef OS_AIX
#include <sys/param.h>
#define PCI_ACCESS_I386_TYPE2 4 /* i386 ports, type 2 (params: none) */
#define PCI_ACCESS_FBSD_DEVICE 5 /* FreeBSD /dev/pci (params: path) */
#define PCI_ACCESS_AIX_DEVICE 6 /* /dev/pci0, /dev/bus0, etc. */
-#define PCI_ACCESS_DUMP 7 /* Dump file (params: filename) */
-#define PCI_ACCESS_MAX 8
+#define PCI_ACCESS_NBSD_LIBPCI 7
+#define PCI_ACCESS_DUMP 8 /* Dump file (params: filename) */
+#define PCI_ACCESS_MAX 9
struct pci_access {
/* Options you can change: */