From 4f12d8acbaa3a253d8b21d04bbfe17ed9ede6158 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Wed, 8 Sep 2010 14:39:12 -0400 Subject: [PATCH] bios_reader: Fix to work on non-Intel machines Actually, fix to work on _any_ machine where the ROM file doesn't match the GPU. Just extract the device ID from the ROM itself rather than look at the running system. Signed-off-by: Adam Jackson --- tools/intel_bios_reader.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c index 70fa19a9..5e139999 100644 --- a/tools/intel_bios_reader.c +++ b/tools/intel_bios_reader.c @@ -660,6 +660,23 @@ static void dump_edp(void) free(block); } +static int +get_device_id(unsigned char *bios) +{ + int device; + int offset = (bios[0x19] << 8) + bios[0x18]; + + if (bios[offset] != 'P' || + bios[offset+1] != 'C' || + bios[offset+2] != 'I' || + bios[offset+3] != 'R') + return -1; + + device = (bios[offset+7] << 8) + bios[offset+6]; + + return device; +} + int main(int argc, char **argv) { int fd; @@ -669,7 +686,6 @@ int main(int argc, char **argv) struct stat finfo; struct bdb_block *block; char signature[17]; - struct pci_device *pci_dev; if (argc != 2) { printf("usage: %s \n", argv[0]); @@ -729,8 +745,9 @@ int main(int argc, char **argv) } printf("\n"); - pci_dev = intel_get_pci_device(); - devid = pci_dev->device_id; + devid = get_device_id(pI830->VBIOS); + if (devid == -1) + printf("Warning: could not find PCI device ID!\n"); dump_general_features(); dump_general_definitions();