From 1c31d620ede1b47e3113aefa4e4b66d3191b166a Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Thu, 28 Jan 1999 20:16:40 +0000 Subject: [PATCH] Capability list parser now recognizes all AGP and all PCI Power Management registers. Added bridge checks to bus mapping code. Released the whole thing as 1.99.4. --- ChangeLog | 15 +++- Makefile | 6 +- README | 2 +- lib/header.h | 53 +++++++++++- lspci.c | 227 ++++++++++++++++++++++++++++++++++++++------------ pciutils.lsm | 8 +- pciutils.spec | 2 +- 7 files changed, 248 insertions(+), 65 deletions(-) diff --git a/ChangeLog b/ChangeLog index 19c3edd..0e11501 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Thu Jan 28 20:54:16 1999 Martin Mares + + * Released as 1.99.4. + + * lspci.c: Capability list parser now recognizes both AGP + registers and PCI Power Management registers (the latter + is mainly guesswork based on DEC/Intel 21153 bridge specs + since I don't have the PCI Power Management document). + + * lspci.c: Replaced numerous occurences of (x & flag) ? '+' : '-' + by FLAG macro. + + * lspci.c: Added bridge checks to bus mapping code. + Wed Jan 27 14:59:16 1999 Martin Mares * lspci.c: Implemented bus mapping mode (-M). @@ -15,7 +29,6 @@ Mon Jan 25 23:46:13 1999 Martin Mares Mon Jan 25 21:28:49 1999 Martin Mares - * Makefile: Added target `release' which substitutes new version number to .spec, .lsm and README. Also rewrote target `dist'. diff --git a/Makefile b/Makefile index c009be4..c8b8f11 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.12 1999/01/25 20:51:06 mj Exp $ +# $Id: Makefile,v 1.13 1999/01/28 20:16:42 mj Exp $ # Makefile for Linux PCI Utilities # (c) 1998--1999 Martin Mares @@ -9,9 +9,9 @@ CFLAGS=$(OPT) -Wall -W -Wno-parentheses -Wstrict-prototypes -Werror ROOT=/ PREFIX=/usr -VERSION=1.99.3 +VERSION=1.99.4 SUFFIX=-alpha -DATE=99-01-25 +DATE=99-01-28 export diff --git a/README b/README index 97bdc60..3f53ea7 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -This package contains the Linux PCI Utilities, version 1.99.3-alpha. +This package contains the Linux PCI Utilities, version 1.99.4-alpha. Copyright (c) 1997--1999 Martin Mares diff --git a/lib/header.h b/lib/header.h index 9340970..2b0f608 100644 --- a/lib/header.h +++ b/lib/header.h @@ -1,5 +1,5 @@ /* - * $Id: header.h,v 1.1 1999/01/24 21:48:12 mj Exp $ + * $Id: header.h,v 1.2 1999/01/28 20:16:53 mj Exp $ * * The PCI Library -- PCI Header Structure (extracted from ) * @@ -177,10 +177,55 @@ /* Capability lists */ #define PCI_CAP_LIST_ID 0 /* Capability ID */ -#define PCI_CAP_ID_AGP 0x02 +#define PCI_CAP_ID_PM 0x01 /* Power Management */ +#define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */ #define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */ -#define PCI_CAP_LIST_REVISION 2 /* Revision of this capability (BCD) */ -/* 3 reserved */ +#define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */ +#define PCI_CAP_SIZEOF 4 + +/* Power Management Registers */ + +#define PCI_PM_CAP_VER_MASK 0x0007 /* Version */ +#define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */ +#define PCI_PM_CAP_AUX_POWER 0x0010 /* Auxilliary power support */ +#define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */ +#define PCI_PM_CAP_D1 0x0200 /* D1 power state support */ +#define PCI_PM_CAP_D2 0x0400 /* D2 power state support */ +#define PCI_PM_CAP_PME 0x0800 /* PME pin supported */ +#define PCI_PM_CTRL 4 /* PM control and status register */ +#define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */ +#define PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */ +#define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (??) */ +#define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (??) */ +#define PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */ +#define PCI_PM_PPB_EXTENSIONS 6 /* PPB support extensions (??) */ +#define PCI_PM_PPB_B2_B3 0x40 /* Stop clock when in D3hot (??) */ +#define PCI_PM_BPCC_ENABLE 0x80 /* Bus power/clock control enable (??) */ +#define PCI_PM_DATA_REGISTER 7 /* (??) */ +#define PCI_PM_SIZEOF 8 + +/* AGP registers */ + +#define PCI_AGP_VERSION 2 /* BCD version number */ +#define PCI_AGP_RFU 3 /* Rest of capability flags */ +#define PCI_AGP_STATUS 4 /* Status register */ +#define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */ +#define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */ +#define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */ +#define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */ +#define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */ +#define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */ +#define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */ +#define PCI_AGP_COMMAND 8 /* Control register */ +#define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */ +#define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */ +#define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */ +#define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */ +#define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */ +#define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */ +#define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 4x rate */ +#define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 4x rate */ +#define PCI_AGP_SIZEOF 12 /* * The PCI interface treats multi-function devices as independent diff --git a/lspci.c b/lspci.c index e5ff280..c18a1b9 100644 --- a/lspci.c +++ b/lspci.c @@ -1,5 +1,5 @@ /* - * $Id: lspci.c,v 1.21 1999/01/27 14:52:55 mj Exp $ + * $Id: lspci.c,v 1.22 1999/01/28 20:16:46 mj Exp $ * * Linux PCI Utilities -- List All PCI Devices * @@ -207,6 +207,8 @@ sort_them(void) /* Normal output */ +#define FLAG(x,y) ((x & y) ? '+' : '-') + static void show_terse(struct device *d) { @@ -317,6 +319,61 @@ show_bases(struct device *d, int cnt) } } +static void +show_pm(struct device *d, int where, int cap) +{ + int t; + + printf("Power Management version %d\n", cap & PCI_PM_CAP_VER_MASK); + if (verbose < 2) + return; + printf("\t\tFlags: PMEClk%c AuxPwr%c DSI%c D1%c D2%c PME%c\n", + FLAG(cap, PCI_PM_CAP_PME_CLOCK), + FLAG(cap, PCI_PM_CAP_AUX_POWER), + FLAG(cap, PCI_PM_CAP_DSI), + FLAG(cap, PCI_PM_CAP_D1), + FLAG(cap, PCI_PM_CAP_D2), + FLAG(cap, PCI_PM_CAP_PME)); + config_fetch(d, where + PCI_PM_CTRL, PCI_PM_SIZEOF - PCI_PM_CTRL); + t = get_conf_word(d, where + PCI_PM_CTRL); + printf("\t\tStatus: D%d PME-Enable%c DSel=%x DScale=%x PME%c\n", + t & PCI_PM_CTRL_STATE_MASK, + FLAG(t, PCI_PM_CTRL_PME_ENABLE), + (t & PCI_PM_CTRL_DATA_SEL_MASK) >> 9, + (t & PCI_PM_CTRL_DATA_SCALE_MASK) >> 13, + FLAG(t, PCI_PM_CTRL_PME_STATUS)); +} + +static void +show_agp(struct device *d, int where, int cap) +{ + u32 t; + + t = cap & 0xff; + printf("AGP version %x.%x\n", cap/16, cap%16); + if (verbose < 2) + return; + config_fetch(d, where + PCI_AGP_STATUS, PCI_AGP_SIZEOF - PCI_AGP_STATUS); + t = get_conf_long(d, where + PCI_AGP_STATUS); + printf("\t\tStatus: RQ=%d SBA%c 64bit%c FW%c Rate=%s%s%s\n", + (t & PCI_AGP_STATUS_RQ_MASK) >> 24U, + FLAG(t, PCI_AGP_STATUS_SBA), + FLAG(t, PCI_AGP_STATUS_64BIT), + FLAG(t, PCI_AGP_STATUS_FW), + (t & PCI_AGP_STATUS_RATE4) ? "4" : "", + (t & PCI_AGP_STATUS_RATE2) ? "2" : "", + (t & PCI_AGP_STATUS_RATE1) ? "1" : ""); + printf("\t\tCommand: RQ=%d SBA%c AGP%c 64bit%c FW%c Rate=%s%s%s\n", + (t & PCI_AGP_COMMAND_RQ_MASK) >> 24U, + FLAG(t, PCI_AGP_COMMAND_SBA), + FLAG(t, PCI_AGP_COMMAND_AGP), + FLAG(t, PCI_AGP_COMMAND_64BIT), + FLAG(t, PCI_AGP_COMMAND_FW), + (t & PCI_AGP_COMMAND_RATE4) ? "4" : "", + (t & PCI_AGP_COMMAND_RATE2) ? "2" : "", + (t & PCI_AGP_COMMAND_RATE1) ? "1" : ""); +} + static void show_htype0(struct device *d) { @@ -331,30 +388,33 @@ show_htype0(struct device *d) int where = get_conf_byte(d, PCI_CAPABILITY_LIST); while (where) { - int id, next, ver; + int id, next, cap; printf("\tCapabilities: "); if (!config_fetch(d, where, 4)) { puts(""); break; } - id = get_conf_byte(d, where); - next = get_conf_byte(d, where+1); - ver = get_conf_byte(d, where+2); + id = get_conf_byte(d, where + PCI_CAP_LIST_ID); + next = get_conf_byte(d, where + PCI_CAP_LIST_NEXT); + cap = get_conf_word(d, where + PCI_CAP_FLAGS); + printf("[%02x] ", where); if (id == 0xff) { - printf("\n", where); + printf("\n"); break; } switch (id) { - case 2: - printf("AGP"); + case PCI_CAP_ID_PM: + show_pm(d, where, cap); + break; + case PCI_CAP_ID_AGP: + show_agp(d, where, cap); break; default: - printf("C%02x", id); + printf("#%02x [%04x]", id, cap); } - printf(" version %x.%x at %02x\n", ver/16, ver%16, where); where = next; } } @@ -435,13 +495,13 @@ show_htype1(struct device *d) if (verbose > 1) printf("\tBridgeCtl: Parity%c SERR%c NoISA%c VGA%c MAbort%c >Reset%c FastB2B%c\n", - (brc & PCI_BRIDGE_CTL_PARITY) ? '+' : '-', - (brc & PCI_BRIDGE_CTL_SERR) ? '+' : '-', - (brc & PCI_BRIDGE_CTL_NO_ISA) ? '+' : '-', - (brc & PCI_BRIDGE_CTL_VGA) ? '+' : '-', - (brc & PCI_BRIDGE_CTL_MASTER_ABORT) ? '+' : '-', - (brc & PCI_BRIDGE_CTL_BUS_RESET) ? '+' : '-', - (brc & PCI_BRIDGE_CTL_FAST_BACK) ? '+' : '-'); + FLAG(brc, PCI_BRIDGE_CTL_PARITY), + FLAG(brc, PCI_BRIDGE_CTL_SERR), + FLAG(brc, PCI_BRIDGE_CTL_NO_ISA), + FLAG(brc, PCI_BRIDGE_CTL_VGA), + FLAG(brc, PCI_BRIDGE_CTL_MASTER_ABORT), + FLAG(brc, PCI_BRIDGE_CTL_BUS_RESET), + FLAG(brc, PCI_BRIDGE_CTL_FAST_BACK)); } static void @@ -490,14 +550,14 @@ show_htype2(struct device *d) printf("\tSecondary status: SERR\n"); if (verbose > 1) printf("\tBridgeCtl: Parity%c SERR%c ISA%c VGA%c MAbort%c >Reset%c 16bInt%c PostWrite%c\n", - (brc & PCI_CB_BRIDGE_CTL_PARITY) ? '+' : '-', - (brc & PCI_CB_BRIDGE_CTL_SERR) ? '+' : '-', - (brc & PCI_CB_BRIDGE_CTL_ISA) ? '+' : '-', - (brc & PCI_CB_BRIDGE_CTL_VGA) ? '+' : '-', - (brc & PCI_CB_BRIDGE_CTL_MASTER_ABORT) ? '+' : '-', - (brc & PCI_CB_BRIDGE_CTL_CB_RESET) ? '+' : '-', - (brc & PCI_CB_BRIDGE_CTL_16BIT_INT) ? '+' : '-', - (brc & PCI_CB_BRIDGE_CTL_POST_WRITES) ? '+' : '-'); + FLAG(brc, PCI_CB_BRIDGE_CTL_PARITY), + FLAG(brc, PCI_CB_BRIDGE_CTL_SERR), + FLAG(brc, PCI_CB_BRIDGE_CTL_ISA), + FLAG(brc, PCI_CB_BRIDGE_CTL_VGA), + FLAG(brc, PCI_CB_BRIDGE_CTL_MASTER_ABORT), + FLAG(brc, PCI_CB_BRIDGE_CTL_CB_RESET), + FLAG(brc, PCI_CB_BRIDGE_CTL_16BIT_INT), + FLAG(brc, PCI_CB_BRIDGE_CTL_POST_WRITES)); if (exca) printf("\t16-bit legacy interface ports at %04x\n", exca); } @@ -562,30 +622,30 @@ show_verbose(struct device *d) if (verbose > 1) { printf("\tControl: I/O%c Mem%c BusMaster%c SpecCycle%c MemWINV%c VGASnoop%c ParErr%c Stepping%c SERR%c FastB2B%c\n", - (cmd & PCI_COMMAND_IO) ? '+' : '-', - (cmd & PCI_COMMAND_MEMORY) ? '+' : '-', - (cmd & PCI_COMMAND_MASTER) ? '+' : '-', - (cmd & PCI_COMMAND_SPECIAL) ? '+' : '-', - (cmd & PCI_COMMAND_INVALIDATE) ? '+' : '-', - (cmd & PCI_COMMAND_VGA_PALETTE) ? '+' : '-', - (cmd & PCI_COMMAND_PARITY) ? '+' : '-', - (cmd & PCI_COMMAND_WAIT) ? '+' : '-', - (cmd & PCI_COMMAND_SERR) ? '+' : '-', - (cmd & PCI_COMMAND_FAST_BACK) ? '+' : '-'); + FLAG(cmd, PCI_COMMAND_IO), + FLAG(cmd, PCI_COMMAND_MEMORY), + FLAG(cmd, PCI_COMMAND_MASTER), + FLAG(cmd, PCI_COMMAND_SPECIAL), + FLAG(cmd, PCI_COMMAND_INVALIDATE), + FLAG(cmd, PCI_COMMAND_VGA_PALETTE), + FLAG(cmd, PCI_COMMAND_PARITY), + FLAG(cmd, PCI_COMMAND_WAIT), + FLAG(cmd, PCI_COMMAND_SERR), + FLAG(cmd, PCI_COMMAND_FAST_BACK)); printf("\tStatus: Cap%c 66Mhz%c UDF%c FastB2B%c ParErr%c DEVSEL=%s >TAbort%c SERR%c dev; - int prim = get_conf_byte(d, np); b->next = bi->bridges; bi->bridges = b; + b->this = get_conf_byte(d, np); + b->dev = p->dev; + b->func = p->func; b->first = get_conf_byte(d, ns); b->last = get_conf_byte(d, nl); printf("## %02x.%02x:%d is a bridge from %02x to %02x-%02x\n", - p->bus, p->dev, p->func, prim, b->first, b->last); - if (prim != p->bus) + p->bus, p->dev, p->func, b->this, b->first, b->last); + if (b->this != p->bus) printf("!!! Bridge points to invalid primary bus.\n"); if (b->first > b->last) { @@ -1076,6 +1138,68 @@ do_map_bus(int bus) } } +static void +do_map_bridges(int bus, int min, int max) +{ + struct bus_info *bi = bus_info + bus; + struct bus_bridge *b; + + bi->guestbook = 1; + for(b=bi->bridges; b; b=b->next) + { + if (bus_info[b->first].guestbook) + b->bug = 1; + else if (b->first < min || b->last > max) + b->bug = 2; + else + { + bus_info[b->first].via = b; + do_map_bridges(b->first, b->first, b->last); + } + } +} + +static void +map_bridges(void) +{ + int i; + + printf("\nSummary of buses:\n\n"); + for(i=0; i<256; i++) + if (bus_info[i].exists && !bus_info[i].guestbook) + do_map_bridges(i, 0, 255); + for(i=0; i<256; i++) + { + struct bus_info *bi = bus_info + i; + struct bus_bridge *b = bi->via; + + if (bi->exists) + { + printf("%02x: ", i); + if (b) + printf("Entered via %02x:%02x.%d\n", b->this, b->dev, b->func); + else if (!i) + printf("Primary host bus\n"); + else + printf("Secondary host bus (?)\n"); + } + for(b=bi->bridges; b; b=b->next) + { + printf("\t%02x.%d Bridge to %02x-%02x", b->dev, b->func, b->first, b->last); + switch (b->bug) + { + case 1: + printf(" "); + break; + case 2: + printf(" "); + break; + } + putchar('\n'); + } + } +} + static void map_the_bus(void) { @@ -1094,6 +1218,7 @@ map_the_bus(void) for(bus=0; bus<256; bus++) do_map_bus(bus); } + map_bridges(); } /* Main */ diff --git a/pciutils.lsm b/pciutils.lsm index 05b20c0..b737769 100644 --- a/pciutils.lsm +++ b/pciutils.lsm @@ -1,7 +1,7 @@ Begin3 Title: Linux PCI Utilities -Version: 1.99.3 -Entered-date: 990125 +Version: 1.99.4 +Entered-date: 990128 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, setpci 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/linux/pci/pciutils-1.99.3.tar.gz -Alternate-site: sunsite.unc.edu pub/Linux/hardware/pciutils-1.99.3.tar.gz +Primary-site: atrey.karlin.mff.cuni.cz pub/linux/pci/pciutils-1.99.4.tar.gz +Alternate-site: sunsite.unc.edu pub/Linux/hardware/pciutils-1.99.4.tar.gz Copying-policy: GPL End diff --git a/pciutils.spec b/pciutils.spec index e295ed1..ca9874a 100644 --- a/pciutils.spec +++ b/pciutils.spec @@ -1,5 +1,5 @@ Name: pciutils -Version: 1.99.3 +Version: 1.99.4 Release: 1 Source: ftp://atrey.karlin.mff.cuni.cz/pub/linux/pci/%{name}-%{version}.tar.gz Copyright: GNU GPL -- 2.39.2