From 2f48f6378ec347cc56b1f66b5b6d0876ed67c6a2 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 8 Feb 1998 10:58:51 +0000 Subject: [PATCH] - Added a man page and updated README - Makefile: Recognize architecture by calling uname and pass it as ARCH_xxx to all the C sources. This should eliminate problems with 32-bit compilers on sparc64. - Partially implemented header type 2. - Released as version 1.0. --- ChangeLog | 19 ++++++++++ Makefile | 8 +++-- README | 36 +++++++++++++++++-- lspci.8 | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++ lspci.c | 60 +++++++++++++++++++------------ pciutils.lsm | 6 ++-- 6 files changed, 198 insertions(+), 31 deletions(-) create mode 100644 ChangeLog create mode 100644 lspci.8 diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..e18cf27 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,19 @@ +Sat Feb 7 15:15:46 1998 Martin Mares + + * README: Updated. + + * lspci.8: Created a man page. + + * Releasing as version 1.0. + +Tue Feb 3 20:56:00 1998 Martin Mares + + * Makefile: Recognize architecture by calling uname and pass it as ARCH_xxx + to all the C sources. This should eliminate problems with 32-bit compilers + on sparc64. + + * lspci.c (show_verbose): Recognize CardBus bridge header type. + (show_htype2): Stub routine. + (scan_config): Write sensible error message if the kernel denies reading of + upper part of the PCI config space. + diff --git a/Makefile b/Makefile index c1e45b1..323e700 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,10 @@ -# $Id: Makefile,v 1.4 1998/01/27 11:50:07 mj Exp $ +# $Id: Makefile,v 1.5 1998/02/08 10:58:52 mj Exp $ # Makefile for Linux PCI Utilities -# (c) 1997 Martin Mares +# (c) 1998 Martin Mares +ARCH=$(shell uname -m | sed -e 's/i.86/i386/' -e 's/sun4u/sparc64/' | tr 'a-z' 'A-Z') OPT=-O2 -fomit-frame-pointer -CFLAGS=$(OPT) -Wall -W -Wno-parentheses -Wstrict-prototypes -Wno-unused -Werror +CFLAGS=$(OPT) -Wall -W -Wno-parentheses -Wstrict-prototypes -Wno-unused -Werror -DARCH_$(ARCH) PREFIX=/ @@ -21,6 +22,7 @@ clean: install: all install -o root -g root -m 755 -s lspci $(PREFIX)/sbin install -o root -g root -m 644 pci.ids $(PREFIX)/etc + install -o root -g root -m 644 lspci.8 $(PREFIX)/man/man8 dist: clean sh -c 'X=`pwd` ; X=`basename $$X` ; cd .. ; tar czvvf /tmp/$$X.tar.gz $$X --exclude CVS --exclude tmp' diff --git a/README b/README index 8316678..5c47c72 100644 --- a/README +++ b/README @@ -1,2 +1,34 @@ -This is an experimental version of the Linux PCI Utilities package. -Maintained by Martin Mares +This package contains the Linux PCI Utilities, version 1.0. + +Copyright (c) 1998 Martin Mares + +All files in this package can be freely distributed and used according +to the terms of the GNU General Public License, either version 2 or +(at your opinion) any newer version. This is the same distribution +policy as for the Linux kernel itself -- see /usr/src/linux/COPYING +for details. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + The Linux PCI Utilities currently contain only one utility -- lspci, +indented for displaying of detailed information about all PCI busses and +devices in the system, replacing the original /proc/pci interface. See +the manual page (lspci.8) for more details. + + If you have any bug reports or suggestions, send them to the author. + + If you want, subscribe to linux-pci@atrey.karlin.mff.cuni.cz (send +"subscribe linux-pci Your Full Name" to listproc@atrey.karlin.mff.cuni.cz). +Release notes about new versions will be send to the list and problems with +the Linux PCI support will be probably discussed there, too. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +TODO: + + - Work-around the PIIX4 ACPI crash? + + - Better displaying of IRQ's generated by both PCI and CardBus bridges. + + - Full displaying of CardBus bridge configuration. (Has anyone seen + full specs of the CardBus bridge / header type 2?) diff --git a/lspci.8 b/lspci.8 new file mode 100644 index 0000000..91a483e --- /dev/null +++ b/lspci.8 @@ -0,0 +1,100 @@ +.TH lspci 8 "7 February 98" "pciutils-0.92" "Linux PCI Utilities" +.IX lspci +.SH NAME +lspci \- list all PCI devices +.SH SYNOPSIS +.B lspci +.RB [ options ] +.SH DESCRIPTION +.B lspci +is a utility for displaying information about all PCI busses in the system and +all devices connected to them. It requires Linux kernel 2.1.82 or newer and +supersedes the original /proc/pci interface found in earlier kernels. + +If you are going to report bugs in PCI device drivers or in +.I lspci +itself, please include output of "lspci -vvx". + +.SH OPTIONS +.TP +.B -v +Tells +.I lspci +to be verbose and display detailed information about all devices. +.TP +.B -vv +Tells +.I lspci +to be very verbose and display even more information (actually everything the +PCI device is able to tell). The exact meaning of these data is not explained +in this manual page, if you want to know more, consult +.B /usr/include/linux/pci.h +or the PCI specs. +.TP +.B -n +Show PCI vendor and device codes as numbers instead of looking them up in the +PCI ID database. +.TP +.B -x +Show hexadecimal dump of first 64 bytes of the PCI configuration space (the standard +header). Useful for debugging of drivers and +.I lspci +itself. +.TP +.B -xx +Show hexadecimal dump of whole PCI configuration space. Available only for root +as several PCI devices crash when you try to read undefined portions of the config +space (although this directly violates the PCI standard). +.TP +.B -b +Bus-centric view. Show all IRQ numbers and addresses as seen by the cards on the +PCI bus instead of as seen by the kernel. +.TP +.B -t +Show a tree-like diagram containing all busses, bridges, devices and connections +between them. +.TP +.B -B +Show only devices on specified bus. +.TP +.B -S +Show only devices in specified slot number. +.TP +.B -F +Show only specified function number of all devices (you can mix it with +.B -B +and +.B -S +to select single device). +.TP +.B -V +Show only devices having specified vendor ID. +.TP +.B -D +Show only devices having specified device ID. +.TP +.B -i +Use +.B + +as PCI ID database instead of /etc/pci.ids. +.TP +.B -p +Use +.B +as directory containing PCI bus information instead of /proc/bus/pci. + +.SH FILES +.TP +.B /etc/pci.ids +A list of all known PCI ID's (vendors, devices, classes and subclasses). +.TP +.B /proc/bus/pci +An interface to PCI bus configuration space provided by the kernel. Contains +per-bus subdirectories with per-card config space files and a +.I +devices +file containing a list of all PCI devices. + +.SH AUTHOR +The Linux PCI Utilities are maintained by Martin Mares . diff --git a/lspci.c b/lspci.c index 29d5f19..2dc6ae4 100644 --- a/lspci.c +++ b/lspci.c @@ -1,5 +1,5 @@ /* - * $Id: lspci.c,v 1.5 1998/01/27 11:50:08 mj Exp $ + * $Id: lspci.c,v 1.6 1998/02/08 10:58:54 mj Exp $ * * Linux PCI Utilities -- List All PCI Devices * @@ -47,7 +47,7 @@ Usage: lspci []\n\ /* Format strings used for IRQ numbers */ -#ifdef __sparc_v9__ +#ifdef ARCH_SPARC64 #define IRQ_FORMAT "%08x" #else #define IRQ_FORMAT "%d" @@ -148,7 +148,7 @@ scan_config(void) { struct device *d; char name[64]; - int fd; + int fd, res; int how_much = (show_hex > 1) ? 256 : 64; for(d=first_dev; d; d=d->next) @@ -159,11 +159,17 @@ scan_config(void) fprintf(stderr, "lspci: Unable to open %s: %m\n", name); exit(1); } - if (read(fd, d->config, how_much) != how_much) + res = read(fd, d->config, how_much); + if (res < 0) { fprintf(stderr, "lspci: Error reading %s: %m\n", name); exit(1); } + if (res != how_much) + { + fprintf(stderr, "lspci: Only %d bytes of config space available to you\n", res); + exit(1); + } close(fd); } } @@ -419,6 +425,11 @@ show_htype1(struct device *d) (brc & PCI_BRIDGE_CTL_FAST_BACK) ? '+' : '-'); } +static void +show_htype2(struct device *d) +{ +} + static void show_verbose(struct device *d) { @@ -432,34 +443,34 @@ show_verbose(struct device *d) byte max_lat, min_gnt; byte int_pin = get_conf_byte(d, PCI_INTERRUPT_PIN); byte int_line = get_conf_byte(d, PCI_INTERRUPT_LINE); - unsigned int irq, ex_htype; + unsigned int irq; word subsys_v, subsys_d; show_terse(d); - switch (class) - { - case PCI_CLASS_BRIDGE_PCI: - ex_htype = 1; - break; - default: - ex_htype = 0; - } - if (ex_htype != htype) - { - printf("\t!!! Header type %02x doesn't match class code %04x\n", htype, class); - return; - } - switch (htype) { - case 0: + case PCI_HEADER_TYPE_NORMAL: + if (class == PCI_CLASS_BRIDGE_PCI) + { + badhdr: + printf("\t!!! Header type %02x doesn't match class code %04x\n", htype, class); + return; + } max_lat = get_conf_byte(d, PCI_MAX_LAT); min_gnt = get_conf_byte(d, PCI_MIN_GNT); subsys_v = get_conf_word(d, PCI_SUBSYSTEM_VENDOR_ID); subsys_d = get_conf_word(d, PCI_SUBSYSTEM_ID); break; - case 1: + case PCI_HEADER_TYPE_BRIDGE: + if (class != PCI_CLASS_BRIDGE_PCI) + goto badhdr; + irq = int_line = int_pin = min_gnt = max_lat = 0; + subsys_v = subsys_d = 0; + break; + case PCI_HEADER_TYPE_CARDBUS: + if ((class >> 8) != PCI_BASE_CLASS_BRIDGE) + goto badhdr; irq = int_line = int_pin = min_gnt = max_lat = 0; subsys_v = subsys_d = 0; break; @@ -555,12 +566,15 @@ show_verbose(struct device *d) switch (htype) { - case 0: + case PCI_HEADER_TYPE_NORMAL: show_htype0(d); break; - case 1: + case PCI_HEADER_TYPE_BRIDGE: show_htype1(d); break; + case PCI_HEADER_TYPE_CARDBUS: + show_htype2(d); + break; } } diff --git a/pciutils.lsm b/pciutils.lsm index 20b8a16..7178cdd 100644 --- a/pciutils.lsm +++ b/pciutils.lsm @@ -1,7 +1,7 @@ Begin3 Title: Linux PCI Utilities -Version: 0.91 -Entered-date: 980127 +Version: 1.0 +Entered-date: 980207 Description: This package contains various utilities for inspecting and setting of devices connected to the PCI bus. Requires kernel version 2.1.82 or newer (supporting the /proc/bus/pci @@ -9,7 +9,7 @@ Description: This package contains various utilities for inspecting and Keywords: kernel, pci, proc, lspci Author: mj@atrey.karlin.mff.cuni.cz (Martin Mares) Maintained-by: mj@atrey.karlin.mff.cuni.cz (Martin Mares) -Primary-site: atrey.karlin.mff.cuni.cz pub/local/mj/pciutils-0.91.tar.gz +Primary-site: atrey.karlin.mff.cuni.cz pub/local/mj/linux/pciutils-1.0.tar.gz Alternate-site: sunsite.unc.edu pub/Linux/system/hardware Copying-policy: GPL End -- 2.39.5