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@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)