summaryrefslogtreecommitdiff
path: root/tools/intel_bios_reader.c
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2010-09-08 14:39:12 -0400
committerAdam Jackson <ajax@redhat.com>2010-09-08 14:39:12 -0400
commit4f12d8acbaa3a253d8b21d04bbfe17ed9ede6158 (patch)
tree4a7fb22141d74f1f8999565391516d58c4bb92a4 /tools/intel_bios_reader.c
parentc09fa38c01e44581db37703bb6b8cf1b60b2d09f (diff)
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 <ajax@redhat.com>
Diffstat (limited to 'tools/intel_bios_reader.c')
-rw-r--r--tools/intel_bios_reader.c23
1 files 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 <rom file>\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();