Contributed by Jari Kirma <kirma@cs.hut.fi> and tweaked by me.
Tue Jul 20 13:25:09 1999 Martin Mares <mj@albireo.ucw.cz>
+ * lib/pci.h: Types are OS dependent.
+
+ * lib/internal.h: Byte order hacks are OS dependent.
+
+ * lib/configure: Recognize FreeBSD. Also set OS_XXX according to the OS.
+
+ * lib/Makefile, lib/access.c: Added fbsd-device target.
+
+ * pci.ids: Added an entry for PLX 9080 bridges with subsystem ID
+ incorrectly set to device ID.
+
+ * README: Added a note that we support FreeBSD.
+
+ * Makefile (PREFIX, ROOT): Set it depending on the OS.
+ (%.8): Grrr, BSD date is not able to convert date formats the same way
+ as GNU date does. Use sed instead.
+ (install): Use `-c' when calling install.
+
+ * lib/fbsd-device.c: Added FreeBSD /dev/pci access module contributed
+ by Jari Kirma <kirma@cs.hut.fi>.
+
* lib/proc.c: Rewrote the pread/pwrite things once again. Use pread
and pwrite only when we are certain it's safe (i.e., glibc 2.1
on all architectures or any libc on a i386 where we really know
-# $Id: Makefile,v 1.19 1999/07/20 12:13:39 mj Exp $
+# $Id: Makefile,v 1.20 1999/07/20 14:01:17 mj Exp $
# Makefile for Linux PCI Utilities
# (c) 1998--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
#OPT=-O2 -g
CFLAGS=$(OPT) -Wall -W -Wno-parentheses -Wstrict-prototypes -Werror
-ROOT=/
-PREFIX=/usr
-
VERSION=2.1-pre5
SUFFIX=
#SUFFIX=-alpha
-DATE=99-07-20
+DATE=1999-07-20
+
+ifeq ($(shell uname),FreeBSD)
+ROOT=/usr/local
+PREFIX=/usr/local
+else
+ROOT=/
+PREFIX=/usr
+endif
export
common.o: common.c pciutils.h lib/libpci.a
%.8: %.man
- sed <$< >$@ "s/@TODAY@/`date -d $(DATE) '+%d %B %Y'`/;s/@VERSION@/pciutils-$(VERSION)$(SUFFIX)/"
+ M=`echo $(DATE) | sed 's/-01-/-January-/;s/-02-/-February-/;s/-03-/-March-/;s/-04-/-April-/;s/-05-/-May-/;s/-06-/-June-/;s/-07-/-July-/;s/-08-/-August-/;s/-09-/-September-/;s/-10-/-October-/;s/-11-/-November-/;s/-12-/-December-/;s/\(.*\)-\(.*\)-\(.*\)/\3 \2 \1/'` ; sed <$< >$@ "s/@TODAY@/$$M/;s/@VERSION@/pciutils-$(VERSION)$(SUFFIX)/"
clean:
rm -f `find . -name "*~" -or -name "*.[oa]" -or -name "\#*\#" -or -name TAGS -or -name core`
rm -rf dist
install: all
- install -m 755 -s lspci setpci $(ROOT)/sbin
- install -m 644 pci.ids $(PREFIX)/share
- install -m 644 lspci.8 setpci.8 $(PREFIX)/man/man8
+ # -c is ignored on Linux, but required on FreeBSD
+ install -c -m 755 -s lspci setpci $(ROOT)/sbin
+ install -c 644 pci.ids $(PREFIX)/share
+ install -c 644 lspci.8 setpci.8 $(PREFIX)/man/man8
# Remove relics from old versions
rm -f $(ROOT)/etc/pci.ids
The PCI Utilities package contains a library for portable access to PCI bus
configuration space and several utilities based on this library. Current
-version works only on Linux, but it can be easily extended to work on other
-systems as well.
+version works only on Linux and also has an experimental support for FreeBSD,
+but it can be easily extended to work on other systems as well.
The utilities include: (See manual pages for more details)
-# $Id: Makefile,v 1.2 1999/01/24 21:35:35 mj Exp $
+# $Id: Makefile,v 1.3 1999/07/20 14:01:27 mj Exp $
# Makefile for The PCI Library
# (c) 1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
OBJS += syscalls.o
endif
+ifdef HAVE_PM_FBSD_DEVICE
+OBJS += fbsd-device.o
+CFLAGS += -I/usr/src/sys
+endif
+
ifdef HAVE_OWN_HEADER_H
INCL += header.h
endif
proc.o: proc.c $(INCL)
generic.o: generic.c $(INCL)
syscalls.o: syscalls.c $(INCL)
+fbsd-device.o: fbsd-device.c $(INCL)
dump.o: dump.c $(INCL)
names.o: names.c $(INCL)
filter.o: filter.c $(INCL)
/*
- * $Id: access.c,v 1.4 1999/07/07 11:23:08 mj Exp $
+ * $Id: access.c,v 1.5 1999/07/20 14:01:28 mj Exp $
*
* The PCI Library -- User Access
*
#else
NULL,
#endif
+#ifdef HAVE_PM_FBSD_DEVICE
+ &pm_fbsd_device,
+#else
+ NULL,
+#endif
#ifdef HAVE_PM_INTEL_CONF
&pm_intel_conf1,
&pm_intel_conf2,
rel=`uname -r`
cpu=`uname -m | sed 's/^i.86$/i386/;s/^sun4u$/sparc64/'`
echo "$sys/$cpu $rel"
-if [ "$sys" != Linux ] ; then
- echo "libpci currently supports only Linux"
- exit 1
-fi
-echo -n "Looking for access methods..."
+
c=config.h
echo >$c "#define ARCH_`echo $cpu | tr 'a-z' 'A-Z'`"
-case $rel in
- 2.[1-9]*|[3-9]*) echo -n " proc"
- echo >>$c '#define HAVE_PM_LINUX_PROC'
- echo >>$c '#define HAVE_LINUX_BYTEORDER_H'
- echo >>$c '#define PATH_PROC_BUS_PCI "/proc/bus/pci"'
- ok=1
- ;;
-esac
-case $cpu in
- i386) echo -n " i386-ports"
- echo >>$c '#define HAVE_PM_INTEL_CONF'
- ok=1
- ;;
- alpha) echo >>$c '#define HAVE_64BIT_ADDRESS'
-# echo -n " syscalls"
-# echo >>$c '#define HAVE_PM_SYSCALLS'
-# ok=1
- ;;
- sparc|sparc64) echo >>$c '#define HAVE_64BIT_ADDRESS'
- echo >>$c '#define HAVE_LONG_ADDRESS'
-# echo -n " syscalls"
-# echo >>$c '#define HAVE_PM_SYSCALLS'
-# ok=1
- ;;
+echo >$c "#define OS_`echo $sys | tr 'a-z' 'A-Z'`"
+
+echo -n "Looking for access methods..."
+
+case $sys in
+ Linux)
+ case $rel in
+ 2.[1-9]*|[3-9]*) echo -n " proc"
+ echo >>$c '#define HAVE_PM_LINUX_PROC'
+ echo >>$c '#define HAVE_LINUX_BYTEORDER_H'
+ echo >>$c '#define PATH_PROC_BUS_PCI "/proc/bus/pci"'
+ ok=1
+ ;;
+ esac
+ case $cpu in
+ i386) echo -n " i386-ports"
+ echo >>$c '#define HAVE_PM_INTEL_CONF'
+ ok=1
+ ;;
+ alpha) echo >>$c '#define HAVE_64BIT_ADDRESS'
+# echo -n " syscalls"
+# echo >>$c '#define HAVE_PM_SYSCALLS'
+# ok=1
+ ;;
+ sparc|sparc64) echo >>$c '#define HAVE_64BIT_ADDRESS'
+ echo >>$c '#define HAVE_LONG_ADDRESS'
+# echo -n " syscalls"
+# echo >>$c '#define HAVE_PM_SYSCALLS'
+# ok=1
+ ;;
+ esac
+ ;;
+ FreeBSD)
+ echo -n " fbsd-device"
+ echo >>$c '#define HAVE_PM_FBSD_DEVICE'
+ echo >>$c '#define PATH_FBSD_DEVICE "/dev/pci"'
+ ok=1
+ ;;
+ *)
+ echo " The PCI library currently supports only Linux and FreeBSD"
+ exit 1
+ ;;
esac
+
echo >>$c '#define HAVE_PM_DUMP'
echo " dump"
if [ -z "$ok" ] ; then
--- /dev/null
+/*
+ * The PCI Library -- FreeBSD /dev/pci access
+ *
+ * Copyright (c) 1999 Jari Kirma <kirma@cs.hut.fi>
+ *
+ * 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 "internal.h"
+
+static void
+fbsd_config(struct pci_access *a)
+{
+ a->method_params[PCI_ACCESS_FBSD_DEVICE] = PATH_FBSD_DEVICE;
+}
+
+static int
+fbsd_detect(struct pci_access *a)
+{
+ char *name = a->method_params[PCI_ACCESS_FBSD_DEVICE];
+
+ if (access(name, R_OK))
+ {
+ a->warning("Cannot open %s", name);
+ return 0;
+ }
+ a->debug("...using %s", name);
+ return 1;
+}
+
+static void
+fbsd_init(struct pci_access *a)
+{
+ char *name = a->method_params[PCI_ACCESS_FBSD_DEVICE];
+
+ a->fd = open(name, O_RDWR, 0);
+ if (a->fd < 0)
+ {
+ a->error("fbsd_init: %s open failed", name);
+ }
+}
+
+static void
+fbsd_cleanup(struct pci_access *a)
+{
+ close(a->fd);
+}
+
+static int
+fbsd_read(struct pci_dev *d, int pos, byte *buf, int len)
+{
+ struct pci_io pi;
+
+ if (!(len == 1 || len == 2 || len == 4))
+ {
+ return pci_generic_block_read(d, pos, buf, len);
+ }
+
+ pi.pi_sel.pc_bus = d->bus;
+ pi.pi_sel.pc_dev = d->dev;
+ pi.pi_sel.pc_func = d->func;
+
+ pi.pi_reg = pos;
+ pi.pi_width = len;
+
+ if (ioctl(d->access->fd, PCIOCREAD, &pi) < 0)
+ d->access->error("fbsd_read: ioctl(PCIOCREAD) failed");
+
+ switch (len)
+ {
+ case 1:
+ buf[0] = (u8) pi.pi_data;
+ break;
+ case 2:
+ ((u16 *) buf)[0] = (u16) pi.pi_data;
+ break;
+ case 4:
+ ((u32 *) buf)[0] = (u32) pi.pi_data;
+ break;
+ }
+ return 1;
+}
+
+static int
+fbsd_write(struct pci_dev *d, int pos, byte *buf, int len)
+{
+ struct pci_io pi;
+
+ if (!(len == 1 || len == 2 || len == 4))
+ {
+ return pci_generic_block_write(d, pos, buf, len);
+ }
+
+ pi.pi_sel.pc_bus = d->bus;
+ pi.pi_sel.pc_dev = d->dev;
+ pi.pi_sel.pc_func = d->func;
+
+ pi.pi_reg = pos;
+ pi.pi_width = len;
+
+ switch (len)
+ {
+ case 1:
+ pi.pi_data = buf[0];
+ break;
+ case 2:
+ pi.pi_data = ((u16 *) buf)[0];
+ break;
+ case 4:
+ pi.pi_data = ((u32 *) buf)[0];
+ break;
+ }
+
+ if (ioctl(d->access->fd, PCIOCWRITE, &pi) < 0)
+ {
+ d->access->error("fbsd_write: ioctl(PCIOCWRITE) failed");
+ }
+
+ return 1;
+}
+
+struct pci_methods pm_fbsd_device = {
+ "FreeBSD-device",
+ fbsd_config,
+ fbsd_detect,
+ fbsd_init,
+ fbsd_cleanup,
+ pci_generic_scan,
+ pci_generic_fill_info,
+ fbsd_read,
+ fbsd_write,
+ NULL, /* dev_init */
+ NULL /* dev_cleanup */
+};
/*
- * $Id: internal.h,v 1.2 1999/07/07 11:23:10 mj Exp $
+ * $Id: internal.h,v 1.3 1999/07/20 14:01:32 mj Exp $
*
* The PCI Library -- Internal Include File
*
#else
+#ifdef OS_LINUX
#include <endian.h>
-#if __BYTE_ORDER == __BIG_ENDIAN
+#define BYTE_ORDER __BYTE_ORDER
+#define BIG_ENDIAN __BIG_ENDIAN
+#endif
+
+#ifdef OS_FREEBSD
+#include <sys/types.h>
+#endif
+
+#if BYTE_ORDER == BIG_ENDIAN
#define cpu_to_le16 swab16
#define cpu_to_le32 swab32
#define le16_to_cpu swab16
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_dump;
+ pm_syscalls, pm_fbsd_device, pm_dump;
#define UNUSED __attribute__((unused))
/*
- * $Id: pci.h,v 1.5 1999/07/20 12:13:40 mj Exp $
+ * $Id: pci.h,v 1.6 1999/07/20 14:01:35 mj Exp $
*
* The PCI Library
*
* Types
*/
+#ifdef OS_LINUX
#include <linux/types.h>
typedef __u8 byte;
typedef __u16 word;
typedef __u16 u16;
typedef __u32 u32;
+#endif
+
+#ifdef OS_FREEBSD
+#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 HAVE_LONG_ADDRESS
typedef unsigned long long pciaddr_t;
#define PCI_ACCESS_SYSCALLS 2 /* pciconfig_read() syscalls (params: none) */
#define PCI_ACCESS_I386_TYPE1 3 /* i386 ports, type 1 (params: none) */
#define PCI_ACCESS_I386_TYPE2 4 /* i386 ports, type 2 (params: none) */
-#define PCI_ACCESS_DUMP 5 /* Dump file (params: filename) */
-#define PCI_ACCESS_MAX 6
+#define PCI_ACCESS_FBSD_DEVICE 5 /* FreeBSD /dev/pci (params: path) */
+#define PCI_ACCESS_DUMP 6 /* Dump file (params: filename) */
+#define PCI_ACCESS_MAX 7
struct pci_access {
/* Options you can change: */
# Maintained by Martin Mares <pci-ids@ucw.cz>
# If you have any new entries, send them to the maintainer.
#
-# $Id: pci.ids,v 1.32 1999/07/20 11:29:41 mj Exp $
+# $Id: pci.ids,v 1.33 1999/07/20 14:01:21 mj Exp $
#
# Vendors and devices. Please keep sorted.
4820 Viper V550 Graphics Accelerator
S 10b4 STB Systems Inc
273e Velocity 4400
+S 10b5 PLX Technology, Inc.
+ 9080 9080 [real subsystem ID not set]
S 1102 Creative Labs
1015 Graphics Blaster CT6710
S 125c Aurora Technologies, Inc.