-# $Id: Makefile,v 1.32 2000/04/17 15:59:16 mj Exp $
+# $Id: Makefile,v 1.33 2000/04/21 11:58:00 mj Exp $
# Makefile for Linux PCI Utilities
# (c) 1998--2000 Martin Mares <mj@suse.cz>
#OPT=-O2 -g
CFLAGS=$(OPT) -Wall -W -Wno-parentheses -Wstrict-prototypes -Werror
-VERSION=2.1.6
+VERSION=2.1.7
SUFFIX=
#SUFFIX=-alpha
-DATE=2000-04-17
+DATE=2000-04-21
+INSTALL=install
+DIRINSTALL=install -d
ifeq ($(shell uname),FreeBSD)
ROOT=/usr/local
PREFIX=/usr/local
else
+ifeq ($(shell uname),AIX)
+ROOT=/usr/local
+PREFIX=/usr/local
+CFLAGS=-g
+INSTALL=installbsd
+DIRINSTALL=mkdir -p
+else
ROOT=/
PREFIX=/usr
endif
+endif
MANDIR=$(shell if [ -d $(PREFIX)/share/man ] ; then echo $(PREFIX)/share/man ; else echo $(PREFIX)/man ; fi)
export
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 -f `find . -name "*~" -o -name "*.[oa]" -o -name "\#*\#" -o -name TAGS -o -name core`
rm -f lspci setpci lib/config.* *.8
rm -rf dist
install: all
# -c is ignored on Linux, but required on FreeBSD
- install -d -m 755 $(ROOT)/sbin $(PREFIX)/share $(MANDIR)/man8
- install -c -m 755 -s lspci setpci $(ROOT)/sbin
- install -c -m 644 pci.ids $(PREFIX)/share
- install -c -m 644 lspci.8 setpci.8 $(MANDIR)/man8
+ $(DIRINSTALL) -m 755 $(ROOT)/sbin $(PREFIX)/share $(MANDIR)/man8
+ $(INSTALL) -c -m 755 -s lspci setpci $(ROOT)/sbin
+ $(INSTALL) -c -m 644 pci.ids $(PREFIX)/share
+ $(INSTALL) -c -m 644 lspci.8 setpci.8 $(MANDIR)/man8
# Remove relics from old versions
rm -f $(ROOT)/etc/pci.ids
-# $Id: Makefile,v 1.3 1999/07/20 14:01:27 mj Exp $
+# $Id: Makefile,v 1.4 2000/04/21 11:58:00 mj Exp $
# Makefile for The PCI Library
# (c) 1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
CFLAGS += -I/usr/src/sys
endif
+ifdef HAVE_PM_AIX_DEVICE
+OBJS += aix-device.o
+endif
+
ifdef HAVE_OWN_HEADER_H
INCL += header.h
endif
generic.o: generic.c $(INCL)
syscalls.o: syscalls.c $(INCL)
fbsd-device.o: fbsd-device.c $(INCL)
+aix-device.o: aix-device.c $(INCL)
dump.o: dump.c $(INCL)
names.o: names.c $(INCL)
filter.o: filter.c $(INCL)
/*
- * $Id: access.c,v 1.6 2000/01/13 22:44:24 mj Exp $
+ * $Id: access.c,v 1.7 2000/04/21 11:58:00 mj Exp $
*
* The PCI Library -- User Access
*
#else
NULL,
#endif
+#ifdef HAVE_PM_AIX_DEVICE
+ &pm_aix_device,
+#else
+ NULL,
+#endif
#ifdef HAVE_PM_DUMP
&pm_dump,
#else
#!/bin/sh
-echo -n "Configuring libpci for your system..."
+echo_n() {
+ if [ -n "$BASH" ]
+ then
+ echo -n "$*"
+ else
+ echo "$*\c"
+ fi
+}
+
+echo_n "Configuring libpci for your system..."
prefix=${1:-/usr}
version=${2:-0.0}
sys=`uname -s`
rel=`uname -r`
-cpu=`uname -m | sed 's/^i.86$/i386/;s/^sun4u$/sparc64/'`
-echo "$sys/$cpu $rel"
+if [ "$sys" = "AIX" -a -x /usr/bin/oslevel -a -x /usr/sbin/lsattr ]
+then
+ rel=`/usr/bin/oslevel`
+ proc=`/usr/sbin/lsdev -C -c processor -S available -F name | head -1`
+ cpu=`/usr/sbin/lsattr -F value -l $proc -a type | sed 's/_.*//'`
+else
+ cpu=`uname -m | sed 's/^i.86$/i386/;s/^sun4u$/sparc64/'`
+fi
+echo " $sys/$cpu $rel"
c=config.h
echo >$c "#define ARCH_`echo $cpu | tr 'a-z' 'A-Z'`"
-echo >$c "#define OS_`echo $sys | tr 'a-z' 'A-Z'`"
+echo >>$c "#define OS_`echo $sys | tr 'a-z' 'A-Z'`"
-echo -n "Looking for access methods..."
+echo_n "Looking for access methods..."
case $sys in
Linux)
case $rel in
- 2.[1-9]*|[3-9]*) echo -n " proc"
+ 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"'
;;
esac
case $cpu in
- i386) echo -n " i386-ports"
+ i386) echo_n " i386-ports"
echo >>$c '#define HAVE_PM_INTEL_CONF'
ok=1
;;
alpha|ia64) echo >>$c '#define HAVE_64BIT_ADDRESS'
-# echo -n " syscalls"
+# 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_n " syscalls"
# echo >>$c '#define HAVE_PM_SYSCALLS'
# ok=1
;;
esac
;;
FreeBSD)
- echo -n " fbsd-device"
+ echo_n " fbsd-device"
echo >>$c '#define HAVE_PM_FBSD_DEVICE'
echo >>$c '#define PATH_FBSD_DEVICE "/dev/pci"'
ok=1
;;
+ AIX)
+ echo_n " aix-device"
+ echo >>$c '#define HAVE_PM_AIX_DEVICE'
+ ok=1
+ ;;
*)
- echo " The PCI library currently supports only Linux and FreeBSD"
+ echo " The PCI library currently supports only Linux, AIX and FreeBSD"
exit 1
;;
esac
/*
- * $Id: generic.c,v 1.5 1999/07/07 11:23:09 mj Exp $
+ * $Id: generic.c,v 1.6 2000/04/21 11:58:00 mj Exp $
*
* The PCI Library -- Generic Direct Access Functions
*
- * Copyright (c) 1997--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ * Copyright (c) 1997--2000 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include "internal.h"
-static void
+void
pci_generic_scan_bus(struct pci_access *a, byte *busmap, int bus)
{
int dev, multi, ht;
/*
- * $Id: internal.h,v 1.3 1999/07/20 14:01:32 mj Exp $
+ * $Id: internal.h,v 1.4 2000/04/21 11:58:00 mj Exp $
*
* The PCI Library -- Internal Include File
*
void (*cleanup_dev)(struct pci_dev *);
};
+void pci_generic_scan_bus(struct pci_access *, byte *busmap, int bus);
void pci_generic_scan(struct pci_access *);
int pci_generic_fill_info(struct pci_dev *, int flags);
int pci_generic_block_read(struct pci_dev *, int pos, byte *buf, int len);
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_dump;
+ pm_syscalls, pm_fbsd_device, pm_aix_device, pm_dump;
+#ifdef __GNUC__
#define UNUSED __attribute__((unused))
+#else
+#define UNUSED
+#define inline
+#endif
/*
- * $Id: pci.h,v 1.7 1999/10/09 13:26:14 mj Exp $
+ * $Id: pci.h,v 1.8 2000/04/21 11:58:00 mj Exp $
*
* The PCI Library
*
typedef u_int32_t u32;
#endif
+#ifdef OS_AIX
+#include <sys/param.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;
#else
#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_FBSD_DEVICE 5 /* FreeBSD /dev/pci (params: path) */
-#define PCI_ACCESS_DUMP 6 /* Dump file (params: filename) */
-#define PCI_ACCESS_MAX 7
+#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
struct pci_access {
/* Options you can change: */
/*
- * $Id: proc.c,v 1.7 2000/01/20 21:14:44 mj Exp $
+ * $Id: proc.c,v 1.8 2000/04/21 11:58:00 mj Exp $
*
* The PCI Library -- Configuration Access via /proc/bus/pci
*
#include <asm/unistd.h>
static _syscall5(int, pread, unsigned int, fd, void *, buf, size_t, size, u32, where_lo, u32, where_hi);
static _syscall5(int, pwrite, unsigned int, fd, void *, buf, size_t, size, u32, where_lo, u32, where_hi);
-static int do_read(struct pci_dev *d __attribute__((unused)), int fd, void *buf, size_t size, int where) { return pread(fd, buf, size, where, 0); }
-static int do_write(struct pci_dev *d __attribute__((unused)), int fd, void *buf, size_t size, int where) { return pwrite(fd, buf, size, where, 0); }
+static int do_read(struct pci_dev *d UNUSED, int fd, void *buf, size_t size, int where) { return pread(fd, buf, size, where, 0); }
+static int do_write(struct pci_dev *d UNUSED, int fd, void *buf, size_t size, int where) { return pwrite(fd, buf, size, where, 0); }
#define HAVE_DO_READ
#else
/*
- * $Id: lspci.c,v 1.35 2000/01/23 05:57:04 mj Exp $
+ * $Id: lspci.c,v 1.36 2000/04/21 11:58:00 mj Exp $
*
* Linux PCI Utilities -- List All PCI Devices
*
#define IO_FORMAT "%04lx"
#endif
+/*
+ * If we aren't being compiled by GCC, use malloc() instead of alloca().
+ * This increases our memory footprint, but only slightly since we don't
+ * use alloca() much.
+ */
+
+#ifndef __GNUC__
+#define alloca malloc
+#endif
+
/* Our view of the PCI bus */
struct device {
struct bridge *c;
for(c=b->child; c; c=c->next)
if (c->secondary <= p->bus && p->bus <= c->subordinate)
- return insert_dev(d, c);
+ {
+ insert_dev(d, c);
+ return;
+ }
bus = new_bus(b, p->bus);
}
/* Simple insertion at the end _does_ guarantee the correct order as the
/*
- * $Id: pciutils.h,v 1.12 1999/01/22 21:04:59 mj Exp $
+ * $Id: pciutils.h,v 1.13 2000/04/21 11:58:01 mj Exp $
*
* Linux PCI Utilities -- Declarations
*
#define PCIUTILS_VERSION PCILIB_VERSION
+#if !defined(__GNUC__)
+#define __attribute__(x)
+#define inline
+#endif
+
void __attribute__((noreturn)) die(char *msg, ...);
void *xmalloc(unsigned int howmuch);
int parse_generic_option(int i, struct pci_access *pacc, char *optarg);