From b513741185051a7348dabbcd152d573ac4014d74 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 24 Jan 1999 21:38:46 +0000 Subject: [PATCH] lspci now understands PCI capability lists. Currently, the only capability I know about is AGP, but the fact it's numbered 0x02 tries to tell that something else might be hiding behind the properties :) --- ChangeLog | 16 ++++++++++++++ README | 1 + lspci.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 75 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7081fd2..f65921d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +Sun Jan 24 22:10:36 1999 Martin Mares + + * lspci.c (show_verbose): Display `Cap' flag in device status. + + * lspci.c (show_htype0): Display capability lists whereever + available. The only capability name we recognize now is `AGP'. + Unfortunately, capabilities are stored in device-dependent + portion of the configuration space and are thus available + only to root unless you read a dump. + + * lspci.c (scan_devices): Use cache instead of buffering. + + * lib/buffer.c: Removed (obsoleted by the cache). + + * lib/access.c: Added general caching mechanism. + Sat Jan 23 21:30:54 1999 Martin Mares * pci.ids: Added few devices. diff --git a/README b/README index 390d6ff..b79a626 100644 --- a/README +++ b/README @@ -53,3 +53,4 @@ notes and other news: http://atrey.karlin.mff.cuni.cz/~mj/pciutils.html. TODO: - lspci: "scan hard" function - lib: "syscall" access method + - .lsm and .spec diff --git a/lspci.c b/lspci.c index 2b1c5e1..45390d9 100644 --- a/lspci.c +++ b/lspci.c @@ -1,5 +1,5 @@ /* - * $Id: lspci.c,v 1.19 1999/01/22 21:04:54 mj Exp $ + * $Id: lspci.c,v 1.20 1999/01/24 21:38:47 mj Exp $ * * Linux PCI Utilities -- List All PCI Devices * @@ -65,7 +65,7 @@ static struct pci_access *pacc; struct device { struct device *next; struct pci_dev *dev; - int config_cnt; + unsigned int config_cnt; byte config[256]; }; @@ -97,11 +97,31 @@ scan_devices(void) how_much = 128; } d->config_cnt = how_much; - pci_setup_buffer(p, d->config); + pci_setup_cache(p, d->config, d->config_cnt); pci_fill_info(p, PCI_FILL_IDENT | PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE); } } +static int +check_root(void) +{ + static int is_root = -1; + + if (is_root < 0) + is_root = !geteuid(); + return is_root; +} + +static int +config_fetch(struct device *d, unsigned int pos, unsigned int len) +{ + if (pos + len < d->config_cnt) + return 1; + if (pacc->method != PCI_ACCESS_DUMP && !check_root()) + return 0; + return pci_read_block(d->dev, pos, d->config + pos, len); +} + /* Config space accesses */ static inline byte @@ -294,6 +314,38 @@ show_htype0(struct device *d) if (rom & 1) printf("\tExpansion ROM at %08lx%s\n", rom & PCI_ROM_ADDRESS_MASK, (rom & PCI_ROM_ADDRESS_ENABLE) ? "" : " [disabled]"); + if (get_conf_word(d, PCI_STATUS) & PCI_STATUS_CAP_LIST) + { + int where = get_conf_byte(d, PCI_CAPABILITY_LIST); + while (where) + { + int id, next, ver; + 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); + if (id == 0xff) + { + printf("\n", where); + break; + } + switch (id) + { + case 2: + printf("AGP"); + break; + default: + printf("C%02x", id); + } + printf(" version %x.%x at %02x\n", ver/16, ver%16, where); + where = next; + } + } } static void @@ -508,7 +560,8 @@ show_verbose(struct device *d) (cmd & PCI_COMMAND_WAIT) ? '+' : '-', (cmd & PCI_COMMAND_SERR) ? '+' : '-', (cmd & PCI_COMMAND_FAST_BACK) ? '+' : '-'); - printf("\tStatus: 66Mhz%c UDF%c FastB2B%c ParErr%c DEVSEL=%s >TAbort%c SERR%c TAbort%c SERR%c config_cnt; i++) { -- 2.39.2