[coreboot-gerrit] Change in coreboot[master]: [util/vgabios_extract] Do intial commit

Thomas Weißschuh (Code Review) gerrit at coreboot.org
Sat Dec 30 15:02:12 CET 2017


Thomas Weißschuh has uploaded this change for review. ( https://review.coreboot.org/23046


Change subject: [util/vgabios_extract] Do intial commit
......................................................................

[util/vgabios_extract] Do intial commit

This util extracts the VGA BIOS from an UEFI dump.

Depends on the 3rd party Python library uefi-firmware-parser.
(https://github.com/theopolis/uefi-firmware-parser)

Change-Id: I8f67160a0a6e9035f81f29b1675272e9c992b143
Signed-off-by: Thomas Weißschuh <thomas at t-8ch.de>
---
A util/vgabios_extract/vgabios_extract.py
1 file changed, 60 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/46/23046/1

diff --git a/util/vgabios_extract/vgabios_extract.py b/util/vgabios_extract/vgabios_extract.py
new file mode 100755
index 0000000..1c32b93
--- /dev/null
+++ b/util/vgabios_extract/vgabios_extract.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python2
+
+from __future__ import print_function
+
+import uefi_firmware
+
+
+def extract_vga_bios(blob):
+    volumes = uefi_firmware.search_firmware_volumes(blob)
+
+    objects = []
+
+    for v in volumes:
+        x = uefi_firmware.AutoParser(blob[v - 40:])
+
+        if x.type() == 'unknown':
+            continue
+
+        objects.extend(x.parse().objects)
+
+    while len(objects):
+        o = objects.pop()
+
+        if not o:
+            continue
+
+        subobjects = filter(lambda x: x is not None, o.objects)
+
+        if subobjects:
+            objects.extend(subobjects)
+            continue
+
+        if b'VGA Compatible BIOS' in o.content:
+            return o
+
+
+if __name__ == '__main__':
+    import argparse
+    import sys
+
+    print(sys.argv)
+
+    parser = argparse.ArgumentParser()
+    parser.add_argument('input', type=str)
+    parser.add_argument('output', type=str)
+
+    args = parser.parse_args()
+
+    with open(args.input, 'rb') as f:
+        blob = f.read()
+
+    o = extract_vga_bios(blob)
+
+    if o is not None:
+        print('Found VGA Bios in {}'.format(o.guid_label), file=sys.stderr)
+        with open(args.output, 'wb') as f:
+            f.write(o.content)
+    else:
+        print('Did not find anything')
+        sys.exit(1)

-- 
To view, visit https://review.coreboot.org/23046
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f67160a0a6e9035f81f29b1675272e9c992b143
Gerrit-Change-Number: 23046
Gerrit-PatchSet: 1
Gerrit-Owner: Thomas Weißschuh <thomas at t-8ch.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20171230/e8c06cbb/attachment.html>


More information about the coreboot-gerrit mailing list