]> mj.ucw.cz Git - pciutils.git/commitdiff
Merged in AIX port.
authorMartin Mares <mj@ucw.cz>
Fri, 21 Apr 2000 11:58:00 +0000 (11:58 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 5 May 2006 12:10:41 +0000 (14:10 +0200)
Makefile
lib/Makefile
lib/access.c
lib/configure
lib/generic.c
lib/internal.h
lib/pci.h
lib/proc.c
lspci.c
pciutils.h

index 5a9b117741c76c6902e6fc837a4237141eaf8985..045acae53f14def56a1b34e67e66e90cfe2bcfdd 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# $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>
 
@@ -6,18 +6,28 @@ OPT=-O2 -fomit-frame-pointer
 #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
@@ -41,16 +51,16 @@ common.o: common.c pciutils.h lib/libpci.a
        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
 
index 5c6c586a049c33ccbb826199f9470330aa9583de..808b7d73b611293417943d3035badd538acd0d03 100644 (file)
@@ -1,4 +1,4 @@
-# $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>
 
@@ -28,6 +28,10 @@ OBJS += fbsd-device.o
 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
@@ -45,6 +49,7 @@ proc.o: proc.c $(INCL)
 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)
index 697f938046914024281f27525a3463859cc827ec..b80969e023c08fbd29d340ffcf3352de5bdd00d8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *     $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
  *
@@ -39,6 +39,11 @@ static struct pci_methods *pci_methods[PCI_ACCESS_MAX] = {
 #else
   NULL,
 #endif
+#ifdef HAVE_PM_AIX_DEVICE
+  &pm_aix_device,
+#else
+  NULL,
+#endif
 #ifdef HAVE_PM_DUMP
   &pm_dump,
 #else
index e7ea209ce7cd16a4e472db7011b5140451e03cea..87b111d0d10718ebcd33fec6610c0eafd27f79ad 100755 (executable)
@@ -1,23 +1,39 @@
 #!/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"'
@@ -25,31 +41,36 @@ case $sys in
                                                ;;
                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
index f1d9e3037b502e2418d8d74d46df618bd234eb1a..03e9f72ab9688cbc2b96e92765f6c85d525527e5 100644 (file)
@@ -1,9 +1,9 @@
 /*
- *     $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.
  */
@@ -12,7 +12,7 @@
 
 #include "internal.h"
 
-static void
+void
 pci_generic_scan_bus(struct pci_access *a, byte *busmap, int bus)
 {
   int dev, multi, ht;
index b049f3d1c9bbea79ce9ae0730a5134e00d321543..ff86b2d4774337ee6956a0ec19b9aa9d69008f20 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *     $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
  *
@@ -71,6 +71,7 @@ struct pci_methods {
   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);
@@ -83,6 +84,11 @@ struct pci_dev *pci_alloc_dev(struct pci_access *);
 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
index e37f8e205a90079758ae588653df9f0494e4bea7..7427cf2f38e7faf9f8857ea629eac528d277c180 100644 (file)
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -1,5 +1,5 @@
 /*
- *     $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
  *
@@ -43,6 +43,16 @@ typedef u_int16_t u16;
 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
@@ -62,8 +72,9 @@ struct nl_entry;
 #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: */
index fc15efb37b8b1ea4ccf55a975cb2bbec0957d43e..d4d427a38a6f9ba584f8707bd6432bceeb98bd96 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *     $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
  *
@@ -48,8 +48,8 @@ static int pwrite(unsigned int fd, void *buf, size_t size, loff_t where)
 #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
diff --git a/lspci.c b/lspci.c
index 656e445ec0a32816fce2744d75b2cd791cb73561..b2ce10476ecdf108b4b9090eb9da395ea33213b9 100644 (file)
--- a/lspci.c
+++ b/lspci.c
@@ -1,5 +1,5 @@
 /*
- *     $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
  *
@@ -74,6 +74,16 @@ static struct pci_access *pacc;
 #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 {
@@ -1006,7 +1016,10 @@ insert_dev(struct device *d, struct bridge *b)
       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
index d2233538716121d69fd18d6b6d0a0c4b417f4812..ba709f5201ffb7829f85a52732e9da68bac25a22 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *     $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);