diff options
author | H. Peter Anvin <hpa@zytor.com> | 2010-02-06 22:54:06 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2010-02-06 23:09:51 -0800 |
commit | eb87986dff065af4acbede5abbbcde5ee39eae19 (patch) | |
tree | 2b98290af210452ba5a18bf2237f88b26208537d /com32/sysdump | |
parent | 6f19ff5ce811655353712647e82f0dee22805108 (diff) | |
download | syslinux-eb87986dff065af4acbede5abbbcde5ee39eae19.tar.gz |
sysdump: add PCI config space dumping
Dump PCI configuration space.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'com32/sysdump')
-rw-r--r-- | com32/sysdump/dmi.c | 1 | ||||
-rw-r--r-- | com32/sysdump/main.c | 1 | ||||
-rw-r--r-- | com32/sysdump/pci.c | 70 | ||||
-rw-r--r-- | com32/sysdump/sysdump.h | 1 |
4 files changed, 72 insertions, 1 deletions
diff --git a/com32/sysdump/dmi.c b/com32/sysdump/dmi.c index ad7c4523..a64e5c1e 100644 --- a/com32/sysdump/dmi.c +++ b/com32/sysdump/dmi.c @@ -5,7 +5,6 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> -#include <sys/cpu.h> #include "sysdump.h" #include "backend.h" diff --git a/com32/sysdump/main.c b/com32/sysdump/main.c index ffe3430c..f6aea9cf 100644 --- a/com32/sysdump/main.c +++ b/com32/sysdump/main.c @@ -37,6 +37,7 @@ static void dump_all(struct backend *be, const char *argv[], size_t len) dump_memory(be); dump_dmi(be); + dump_pci(be); dump_vesa_tables(be); cpio_close(be); diff --git a/com32/sysdump/pci.c b/com32/sysdump/pci.c new file mode 100644 index 00000000..debbbafe --- /dev/null +++ b/com32/sysdump/pci.c @@ -0,0 +1,70 @@ +/* + * Dump PCI device headers + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <sys/pci.h> +#include "sysdump.h" +#include "backend.h" + +static void dump_pci_device(struct backend *be, pciaddr_t a, uint8_t hdrtype) +{ + unsigned int bus = pci_bus(a); + unsigned int dev = pci_dev(a); + unsigned int func = pci_func(a); + uint8_t data[256]; + unsigned int i; + char filename[32]; + + hdrtype &= 0x7f; + + printf("Scanning PCI bus... %02x:%02x.%x\r", bus, dev, func); + + /* Assume doing a full device dump is actually safe... */ + for (i = 0; i < sizeof data; i += 4) + *(uint32_t *)(data+i) = pci_readl(a + i); + + snprintf(filename, sizeof filename, "pci/%02x:%02x.%x", + bus, dev, func); + cpio_writefile(be, filename, data, sizeof data); +} + +void dump_pci(struct backend *be) +{ + int cfgtype; + unsigned int nbus, ndev, nfunc, maxfunc; + pciaddr_t a; + uint32_t did; + uint8_t hdrtype; + + cfgtype = pci_set_config_type(PCI_CFG_AUTO); + if (cfgtype == PCI_CFG_NONE) + return; + + cpio_mkdir(be, "pci"); + + for (nbus = 0; nbus < MAX_PCI_BUSES; nbus++) { + for (ndev = 0; ndev < MAX_PCI_DEVICES; ndev++) { + maxfunc = 1; /* Assume a single-function device */ + + for (nfunc = 0; nfunc < maxfunc; nfunc++) { + a = pci_mkaddr(nbus, ndev, nfunc, 0); + did = pci_readl(a); + + if (did == 0xffffffff || did == 0xffff0000 || + did == 0x0000ffff || did == 0x00000000) + continue; + + hdrtype = pci_readb(a + 0x0e); + if (hdrtype & 0x80) + maxfunc = MAX_PCI_FUNC; /* Multifunction device */ + + dump_pci_device(be, a, hdrtype); + } + } + } + + printf("Scanning PCI bus... done \n"); +} diff --git a/com32/sysdump/sysdump.h b/com32/sysdump/sysdump.h index df9da311..4b58cf3f 100644 --- a/com32/sysdump/sysdump.h +++ b/com32/sysdump/sysdump.h @@ -5,6 +5,7 @@ struct backend; void dump_memory(struct backend *); void dump_dmi(struct backend *); +void dump_pci(struct backend *); void dump_vesa_tables(struct backend *); #endif /* SYSDUMP_H */ |