Patch to get pciutils compile with 2.1.85

Martin Mares (mj@ucw.cz)
Sun, 8 Feb 1998 18:34:34 +0100


Hi,

pciutils-1.0 don't compile with 2.1.85 as my latest include/linux/pci.h
is not yet there... Apply the following patch to the kernel or get a CVS
snapshot.

Have a nice fortnight

-- 
Martin `MJ' Mares   <mj@ucw.cz>   http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
"Beware of bugs in the above code; I have only proved it correct, not tried it."

diff -ruN /usr/src/linux-2.1/drivers/pci/oldproc.c drivers/pci/oldproc.c --- /usr/src/linux-2.1/drivers/pci/oldproc.c Mon Feb 2 13:40:23 1998 +++ drivers/pci/oldproc.c Thu Jan 15 13:35:48 1998 @@ -1,5 +1,5 @@ /* - * $Id: oldproc.c,v 1.4 1998/01/05 14:16:18 mj Exp $ + * $Id: oldproc.c,v 1.6 1998/01/15 12:29:00 jes Exp $ * * Backward-compatible procfs interface for PCI. * @@ -253,6 +253,8 @@ DEVICE( ASP, ASP_ABP940U, "ABP940U"), DEVICE( CERN, CERN_SPSB_PMC, "STAR/RD24 SCI-PCI (PMC)"), DEVICE( CERN, CERN_SPSB_PCI, "STAR/RD24 SCI-PCI (PMC)"), + DEVICE( CERN, CERN_HIPPI_DST, "HIPPI destination"), + DEVICE( CERN, CERN_HIPPI_SRC, "HIPPI source"), DEVICE( IMS, IMS_8849, "8849"), DEVICE( TEKRAM2, TEKRAM2_690c, "DC690c"), DEVICE( TUNDRA, TUNDRA_CA91C042,"CA91C042 Universe"), @@ -345,6 +347,7 @@ DEVICE( RP, RP8INTF, "RocketPort 8 Intf"), DEVICE( RP, RP16INTF, "RocketPort 16 Intf"), DEVICE( RP, RP32INTF, "RocketPort 32 Intf"), + DEVICE( ESSENTIAL, ROADRUNNER, "RoadRunner serial HIPPI"), DEVICE( CYCLADES, CYCLOM_Y_Lo, "Cyclom-Y below 1Mbyte"), DEVICE( CYCLADES, CYCLOM_Y_Hi, "Cyclom-Y above 1Mbyte"), DEVICE( CYCLADES, CYCLOM_Z_Lo, "Cyclom-Z below 1Mbyte"), diff -ruN /usr/src/linux-2.1/drivers/pci/pci.c drivers/pci/pci.c --- /usr/src/linux-2.1/drivers/pci/pci.c Mon Feb 2 13:40:23 1998 +++ drivers/pci/pci.c Mon Feb 2 15:17:54 1998 @@ -1,9 +1,9 @@ /* - * $Id: pci.c,v 1.55 1997/12/27 12:17:54 mj Exp $ + * $Id: pci.c,v 1.58 1998/02/02 14:15:47 mj Exp $ * * PCI services that are built on top of the BIOS32 service. * - * Copyright 1993, 1994, 1995, 1997 Drew Eckhardt, Frederic Potter, + * Copyright 1993 -- 1998 Drew Eckhardt, Frederic Potter, * David Mosberger-Tang, Martin Mares */ @@ -18,7 +18,7 @@ #include <asm/page.h> struct pci_bus pci_root; -struct pci_dev *pci_devices = 0; +struct pci_dev *pci_devices = NULL; #undef DEBUG @@ -112,9 +112,10 @@ pcibios_read_config_dword(bus->number, devfn, PCI_CLASS_REVISION, &class); class >>= 8; /* upper 3 bytes */ dev->class = class; + dev->hdr_type = hdr_type; switch (hdr_type & 0x7f) { /* header type */ - case 0: /* standard header */ + case PCI_HEADER_TYPE_NORMAL: /* standard header */ if (class >> 8 == PCI_CLASS_BRIDGE_PCI) goto bad; /* read irq level (may be changed during pcibios_fixup()): */ @@ -129,12 +130,20 @@ dev->base_address[reg] = (l == 0xffffffff) ? 0 : l; } break; - case 1: /* bridge header */ + case PCI_HEADER_TYPE_BRIDGE: /* bridge header */ if (class >> 8 != PCI_CLASS_BRIDGE_PCI) goto bad; for (reg = 0; reg < 2; reg++) { pcibios_read_config_dword(bus->number, devfn, PCI_BASE_ADDRESS_0 + (reg << 2), &l); dev->base_address[reg] = (l == 0xffffffff) ? 0 : l; + } + break; + case PCI_HEADER_TYPE_CARDBUS: /* CardBus bridge header */ + if (class >> 16 != PCI_BASE_CLASS_BRIDGE) + goto bad; + for (reg = 0; reg < 2; reg++) { + pcibios_read_config_dword(bus->number, devfn, PCI_CB_MEMORY_BASE_0 + (reg << 3), &l); + dev->base_address[reg] = (l = 0xffffffff) ? 0 : l; } break; default: /* unknown header */ diff -ruN /usr/src/linux-2.1/drivers/pci/proc.c drivers/pci/proc.c --- /usr/src/linux-2.1/drivers/pci/proc.c Mon Feb 2 13:40:23 1998 +++ drivers/pci/proc.c Mon Feb 2 15:20:48 1998 @@ -1,12 +1,11 @@ /* - * $Id: proc.c,v 1.1 1997/12/22 17:22:31 mj Exp $ + * $Id: proc.c,v 1.4 1998/02/02 14:18:42 mj Exp $ * * Procfs interface for the PCI bus. * - * Copyright (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz> + * Copyright (c) 1997, 1998 Martin Mares <mj@atrey.karlin.mff.cuni.cz> */ -#include <linux/config.h> #include <linux/types.h> #include <linux/kernel.h> #include <linux/bios32.h> @@ -50,14 +49,27 @@ int pos = *ppos; unsigned char bus = dev->bus->number; unsigned char dfn = dev->devfn; - int cnt; + int cnt, size; - if (pos >= PCI_CFG_SPACE_SIZE) + /* + * Normal users can read only the standardized portion of the + * configuration space as several chips lock up when trying to read + * undefined locations (think of Intel PIIX4 as a typical example). + */ + + if (fsuser()) + size = PCI_CFG_SPACE_SIZE; + else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) + size = 128; + else + size = 64; + + if (pos >= size) return 0; - if (nbytes >= PCI_CFG_SPACE_SIZE) - nbytes = PCI_CFG_SPACE_SIZE; - if (pos + nbytes > PCI_CFG_SPACE_SIZE) - nbytes = PCI_CFG_SPACE_SIZE - pos; + if (nbytes >= size) + nbytes = size; + if (pos + nbytes > size) + nbytes = size - pos; cnt = nbytes; if (!access_ok(VERIFY_WRITE, buf, cnt)) --- /usr/src/linux-2.1/include/linux/pci.h Mon Feb 2 13:40:26 1998 +++ include/linux/pci.h Mon Feb 2 15:17:51 1998 @@ -1,5 +1,5 @@ /* - * $Id: pci.h,v 1.51 1997/12/27 13:55:23 mj Exp $ + * $Id: pci.h,v 1.55 1998/02/02 14:15:41 mj Exp $ * * PCI defines and function prototypes * Copyright 1994, Drew Eckhardt @@ -68,6 +68,10 @@ #define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */ #define PCI_LATENCY_TIMER 0x0d /* 8 bits */ #define PCI_HEADER_TYPE 0x0e /* 8 bits */ +#define PCI_HEADER_TYPE_NORMAL 0 +#define PCI_HEADER_TYPE_BRIDGE 1 +#define PCI_HEADER_TYPE_CARDBUS 2 + #define PCI_BIST 0x0f /* 8 bits */ #define PCI_BIST_CODE_MASK 0x0f /* Return result */ #define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */ @@ -149,6 +153,36 @@ #define PCI_BRIDGE_CTL_BUS_RESET 0x40 /* Secondary bus reset */ #define PCI_BRIDGE_CTL_FAST_BACK 0x80 /* Fast Back2Back enabled on secondary interface */ +/* Header type 2 (CardBus bridges) -- detailed info welcome */ +#define PCI_CB_CARDBUS_BASE 0x10 /* CardBus Socket/ExCa base address */ +#define PCI_CB_CARDBUS_BASE_TYPE_MASK 0xfff +#define PCI_CB_CARDBUS_BASE_MASK ~0xfff +#define PCI_CB_CAPABILITIES 0x14 /* Offset of list of capabilities in cfg space */ +/* 0x15 reserved */ +#define PCI_CB_SEC_STATUS 0x16 /* Secondary status */ +#define PCI_CB_BUS_NUMBER 0x18 /* PCI bus number */ +#define PCI_CB_CARDBUS_NUMBER 0x19 /* CardBus bus number */ +#define PCI_CB_SUBORDINATE_BUS 0x1a /* Subordinate bus number */ +#define PCI_CB_CARDBUS_LATENCY 0x1b /* CardBus latency timer */ +#define PCI_CB_MEMORY_BASE_0 0x1c +#define PCI_CB_MEMORY_LIMIT_0 0x20 +#define PCI_CB_MEMORY_BASE_1 0x24 +#define PCI_CB_MEMORY_LIMIT_1 0x28 +#define PCI_CB_IO_BASE_0 0x2c +#define PCI_CB_IO_BASE_0_HI 0x2e +#define PCI_CB_IO_LIMIT_0 0x30 +#define PCI_CB_IO_LIMIT_0_HI 0x32 +#define PCI_CB_IO_BASE_1 0x34 +#define PCI_CB_IO_BASE_1_HI 0x36 +#define PCI_CB_IO_LIMIT_1 0x38 +#define PCI_CB_IO_LIMIT_1_HI 0x3a +/* 0x3c-0x3d are same as for htype 0 */ +/* 0x3e-0x3f are same as for htype 1 */ +#define PCI_CB_SUBSYSTEM_ID 0x40 +#define PCI_CB_SUBSYSTEM_VENDOR_ID 0x42 +#define PCI_CB_LEGACY_MODE_BASE 0x44 /* 16-bit PC Card legacy mode base address (ExCa) */ +/* 0x48-0x7f reserved */ + /* Device classes and subclasses */ #define PCI_CLASS_NOT_DEFINED 0x0000 @@ -577,6 +611,8 @@ #define PCI_VENDOR_ID_CERN 0x10dc #define PCI_DEVICE_ID_CERN_SPSB_PMC 0x0001 #define PCI_DEVICE_ID_CERN_SPSB_PCI 0x0002 +#define PCI_DEVICE_ID_CERN_HIPPI_DST 0x0021 +#define PCI_DEVICE_ID_CERN_HIPPI_SRC 0x0022 #define PCI_VENDOR_ID_NVIDIA 0x10de @@ -742,6 +778,9 @@ #define PCI_DEVICE_ID_CYCLOM_Z_Lo 0x0200 #define PCI_DEVICE_ID_CYCLOM_Z_Hi 0x0201 +#define PCI_VENDOR_ID_ESSENTIAL 0x120f +#define PCI_DEVICE_ID_ROADRUNNER 0x0001 + #define PCI_VENDOR_ID_3DFX 0x121a #define PCI_DEVICE_ID_3DFX_VOODOO 0x0001 @@ -903,6 +942,7 @@ unsigned short vendor; unsigned short device; unsigned int class; /* 3 bytes: (base,sub,prog-if) */ + unsigned int hdr_type; /* PCI header type */ unsigned int master : 1; /* set if device is master capable */ /* * In theory, the irq level can be read from configuration - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu