Merge pull request 'Update Git revision for bios_extract' (#74) from nic3-14159/lbmk:update_bios_extract into master
Reviewed-on: https://codeberg.org/libreboot/lbmk/pulls/74fsdg20230625
commit
e6d4aeb272
|
@ -1,132 +0,0 @@
|
|||
From d187ceefacc4909c4a3fdb8098878cb9bcd2c198 Mon Sep 17 00:00:00 2001
|
||||
From: Nicholas Chin <nic.c3.14@gmail.com>
|
||||
Date: Fri, 5 May 2023 19:34:29 -0600
|
||||
Subject: [PATCH 1/3] dell_inspiron_1100_unpacker: Fix minor style issues
|
||||
|
||||
- Make indent width consistent
|
||||
- Use spaces around -= operator
|
||||
- Rename variable type to type_id to avoid shadowing the type method,
|
||||
though that method isn't ever used in this program
|
||||
|
||||
Signed-off-by: Nicholas Chin <nic.c3.14@gmail.com>
|
||||
Change-Id: I2d47501845591e228b6c5d61c36ca2edce91d36a
|
||||
---
|
||||
dell_inspiron_1100_unpacker.py | 84 +++++++++++++++++-----------------
|
||||
1 file changed, 42 insertions(+), 42 deletions(-)
|
||||
|
||||
diff --git a/dell_inspiron_1100_unpacker.py b/dell_inspiron_1100_unpacker.py
|
||||
index 3d5adf5..b12059b 100755
|
||||
--- a/dell_inspiron_1100_unpacker.py
|
||||
+++ b/dell_inspiron_1100_unpacker.py
|
||||
@@ -19,7 +19,7 @@ def memcpy(arr1, off1, arr2, off2, count):
|
||||
raise Exception("Trying to write out of bounds")
|
||||
off1 += 1
|
||||
off2 += 1
|
||||
- count -=1
|
||||
+ count -= 1
|
||||
|
||||
# looks like some lzss variation
|
||||
def dell_unpack(indata):
|
||||
@@ -64,58 +64,58 @@ def dell_unpack(indata):
|
||||
return dst.tostring()
|
||||
|
||||
mod_types = {
|
||||
- 0x01: "Main ROM",
|
||||
- 0x0C: "Microcode update",
|
||||
+ 0x01: "Main ROM",
|
||||
+ 0x0C: "Microcode update",
|
||||
}
|
||||
|
||||
print "Dell/Phoenix ROM BIOS PLUS unpacker"
|
||||
if len(sys.argv) < 2:
|
||||
- print "Usage: dell_unpack.py bios.bin [offset]"
|
||||
- sys.exit(1)
|
||||
+ print "Usage: dell_unpack.py bios.bin [offset]"
|
||||
+ sys.exit(1)
|
||||
fname = sys.argv[1]
|
||||
offs = 0
|
||||
f = open(fname, "rb").read()
|
||||
if len(sys.argv) > 2:
|
||||
- offs = int(sys.argv[2], 16)
|
||||
+ offs = int(sys.argv[2], 16)
|
||||
else:
|
||||
- offs = f.find("\xF0\x00Copyright 1985-\x02\x04\xF0\x0F8 Phoenix Technologies Ltd.")
|
||||
- if offs == -1:
|
||||
- print "Does not look like a Dell/Phoenix ROM BIOS PLUS"
|
||||
- sys.exit(2)
|
||||
- if f[offs-5] == '\x01':
|
||||
- hlen = 5 # 32-bit length
|
||||
- offs -= 5
|
||||
- fmt = "<BI"
|
||||
- elif f[offs-3] == '\x01':
|
||||
- hlen = 3 # 16-bit length
|
||||
- offs -= 3
|
||||
- fmt = "<BH"
|
||||
- else:
|
||||
- print "Unhandled format!"
|
||||
- sys.exit(1)
|
||||
- print "Found compressed module at %08X" % offs
|
||||
+ offs = f.find("\xF0\x00Copyright 1985-\x02\x04\xF0\x0F8 Phoenix Technologies Ltd.")
|
||||
+ if offs == -1:
|
||||
+ print "Does not look like a Dell/Phoenix ROM BIOS PLUS"
|
||||
+ sys.exit(2)
|
||||
+ if f[offs-5] == '\x01':
|
||||
+ hlen = 5 # 32-bit length
|
||||
+ offs -= 5
|
||||
+ fmt = "<BI"
|
||||
+ elif f[offs-3] == '\x01':
|
||||
+ hlen = 3 # 16-bit length
|
||||
+ offs -= 3
|
||||
+ fmt = "<BH"
|
||||
+ else:
|
||||
+ print "Unhandled format!"
|
||||
+ sys.exit(1)
|
||||
+ print "Found compressed module at %08X" % offs
|
||||
if offs > 0:
|
||||
fn = "EC.bin"
|
||||
print "%08X EC code, %08X %s" % (0, offs, fn)
|
||||
open(fn, "wb").write(f[:offs])
|
||||
while True:
|
||||
- type, leng = struct.unpack(fmt, f[offs:offs+hlen])
|
||||
- print "%08X type %02X" % (offs, type),
|
||||
- offs += hlen
|
||||
- if type == 0xFF:
|
||||
- print "<end of chain>"
|
||||
- break
|
||||
- data = f[offs:offs+leng]
|
||||
- offs += leng
|
||||
- if type != 0xC:
|
||||
- odata = dell_unpack(data)
|
||||
- else:
|
||||
- odata = data
|
||||
- print " %08X -> %08X" % (leng, len(odata)),
|
||||
- fn = "mod_%02X.bin" % type
|
||||
- print " %s" % fn,
|
||||
- if type in mod_types:
|
||||
- print "(%s)" % mod_types[type]
|
||||
- else:
|
||||
- print ""
|
||||
- open(fn, "wb").write(odata)
|
||||
+ type_id, leng = struct.unpack(fmt, f[offs:offs+hlen])
|
||||
+ print "%08X type %02X" % (offs, type_id),
|
||||
+ offs += hlen
|
||||
+ if type_id == 0xFF:
|
||||
+ print "<end of chain>"
|
||||
+ break
|
||||
+ data = f[offs:offs+leng]
|
||||
+ offs += leng
|
||||
+ if type_id != 0xC:
|
||||
+ odata = dell_unpack(data)
|
||||
+ else:
|
||||
+ odata = data
|
||||
+ print " %08X -> %08X" % (leng, len(odata)),
|
||||
+ fn = "mod_%02X.bin" % type_id
|
||||
+ print " %s" % fn,
|
||||
+ if type_id in mod_types:
|
||||
+ print "(%s)" % mod_types[type_id]
|
||||
+ else:
|
||||
+ print ""
|
||||
+ open(fn, "wb").write(odata)
|
||||
--
|
||||
2.40.1
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
From 34ecbda8cc75eecb747004520c9e0bd6de3c7723 Mon Sep 17 00:00:00 2001
|
||||
From: Nicholas Chin <nic.c3.14@gmail.com>
|
||||
Date: Fri, 5 May 2023 19:35:45 -0600
|
||||
Subject: [PATCH 2/3] dell_inspiron_1100_unpacker: Convert from python 2 to 3
|
||||
|
||||
TEST: The output of the script is the same as the python 2 version when
|
||||
run against the Inspiron 1100 BIOS
|
||||
|
||||
Signed-off-by: Nicholas Chin <nic.c3.14@gmail.com>
|
||||
Change-Id: I2ab9a72bc65121b1106e9867b7d58d1eefb0eb3d
|
||||
---
|
||||
dell_inspiron_1100_unpacker.py | 34 +++++++++++++++++-----------------
|
||||
1 file changed, 17 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/dell_inspiron_1100_unpacker.py b/dell_inspiron_1100_unpacker.py
|
||||
index b12059b..5e43813 100755
|
||||
--- a/dell_inspiron_1100_unpacker.py
|
||||
+++ b/dell_inspiron_1100_unpacker.py
|
||||
@@ -1,4 +1,4 @@
|
||||
-#!/usr/bin/env python2
|
||||
+#!/usr/bin/env python3
|
||||
# Dell/Phoenix ROM BIOS PLUS unpacker
|
||||
# 2012-09-12 version 0.1
|
||||
# 2012-10-10 version 0.2 added support for older BIOSes with 16-bit length (Dell Inspiron 1100)
|
||||
@@ -61,16 +61,16 @@ def dell_unpack(indata):
|
||||
dstoff += count
|
||||
srcoff += count
|
||||
|
||||
- return dst.tostring()
|
||||
+ return dst
|
||||
|
||||
mod_types = {
|
||||
0x01: "Main ROM",
|
||||
0x0C: "Microcode update",
|
||||
}
|
||||
|
||||
-print "Dell/Phoenix ROM BIOS PLUS unpacker"
|
||||
+print("Dell/Phoenix ROM BIOS PLUS unpacker")
|
||||
if len(sys.argv) < 2:
|
||||
- print "Usage: dell_unpack.py bios.bin [offset]"
|
||||
+ print("Usage: dell_unpack.py bios.bin [offset]")
|
||||
sys.exit(1)
|
||||
fname = sys.argv[1]
|
||||
offs = 0
|
||||
@@ -78,32 +78,32 @@ f = open(fname, "rb").read()
|
||||
if len(sys.argv) > 2:
|
||||
offs = int(sys.argv[2], 16)
|
||||
else:
|
||||
- offs = f.find("\xF0\x00Copyright 1985-\x02\x04\xF0\x0F8 Phoenix Technologies Ltd.")
|
||||
+ offs = f.find(b"\xF0\x00Copyright 1985-\x02\x04\xF0\x0F8 Phoenix Technologies Ltd.")
|
||||
if offs == -1:
|
||||
- print "Does not look like a Dell/Phoenix ROM BIOS PLUS"
|
||||
+ print("Does not look like a Dell/Phoenix ROM BIOS PLUS")
|
||||
sys.exit(2)
|
||||
- if f[offs-5] == '\x01':
|
||||
+ if f[offs-5] == 0x01:
|
||||
hlen = 5 # 32-bit length
|
||||
offs -= 5
|
||||
fmt = "<BI"
|
||||
- elif f[offs-3] == '\x01':
|
||||
+ elif f[offs-3] == 0x01:
|
||||
hlen = 3 # 16-bit length
|
||||
offs -= 3
|
||||
fmt = "<BH"
|
||||
else:
|
||||
- print "Unhandled format!"
|
||||
+ print("Unhandled format!")
|
||||
sys.exit(1)
|
||||
- print "Found compressed module at %08X" % offs
|
||||
+ print("Found compressed module at %08X" % offs)
|
||||
if offs > 0:
|
||||
fn = "EC.bin"
|
||||
- print "%08X EC code, %08X %s" % (0, offs, fn)
|
||||
+ print("%08X EC code, %08X %s" % (0, offs, fn))
|
||||
open(fn, "wb").write(f[:offs])
|
||||
while True:
|
||||
type_id, leng = struct.unpack(fmt, f[offs:offs+hlen])
|
||||
- print "%08X type %02X" % (offs, type_id),
|
||||
+ print("%08X type %02X" % (offs, type_id), end=" ")
|
||||
offs += hlen
|
||||
if type_id == 0xFF:
|
||||
- print "<end of chain>"
|
||||
+ print("<end of chain>")
|
||||
break
|
||||
data = f[offs:offs+leng]
|
||||
offs += leng
|
||||
@@ -111,11 +111,11 @@ while True:
|
||||
odata = dell_unpack(data)
|
||||
else:
|
||||
odata = data
|
||||
- print " %08X -> %08X" % (leng, len(odata)),
|
||||
+ print(" %08X -> %08X" % (leng, len(odata)), end=" ")
|
||||
fn = "mod_%02X.bin" % type_id
|
||||
- print " %s" % fn,
|
||||
+ print(" %s" % fn, end=" ")
|
||||
if type_id in mod_types:
|
||||
- print "(%s)" % mod_types[type_id]
|
||||
+ print("(%s)" % mod_types[type_id])
|
||||
else:
|
||||
- print ""
|
||||
+ print("")
|
||||
open(fn, "wb").write(odata)
|
||||
--
|
||||
2.40.1
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
From b3868ed71a390f925eb22b926b9c735f7b84b383 Mon Sep 17 00:00:00 2001
|
||||
From: Nicholas Chin <nic.c3.14@gmail.com>
|
||||
Date: Sat, 6 May 2023 11:14:45 -0600
|
||||
Subject: [PATCH 3/3] dell_inspiron_1100_unpacker: Add module type 0x52
|
||||
|
||||
The module with type 0x52 in the Latitude E6400 BIOS is the EC firmware,
|
||||
and is not compressed. The current behavior tries to decompress this
|
||||
module leading to an index out of bounds error at runtime, so add a new
|
||||
condition to avoid decompressing it. This assumes type 0x52 is always
|
||||
used for EC firmware.
|
||||
|
||||
The current behavior also assumes all the data before the first module
|
||||
is EC firmware, which was probably true for the Inspiron 1100, but for
|
||||
the E6400 the EC firmware is in module 0x52. However, for simplicity an
|
||||
exception is not made for this behavior, so the extracted EC.bin should
|
||||
just be treated as spurious data for the E6400.
|
||||
|
||||
TEST: Inspiron 1100 BIOS is still unpacked correctly, Latitude E6400
|
||||
BIOS unpacks without runtime errors.
|
||||
|
||||
Signed-off-by: Nicholas Chin <nic.c3.14@gmail.com>
|
||||
Change-Id: I3152150b7dea4d79840c61683692c65b1311cce2
|
||||
---
|
||||
dell_inspiron_1100_unpacker.py | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dell_inspiron_1100_unpacker.py b/dell_inspiron_1100_unpacker.py
|
||||
index 5e43813..3589550 100755
|
||||
--- a/dell_inspiron_1100_unpacker.py
|
||||
+++ b/dell_inspiron_1100_unpacker.py
|
||||
@@ -66,6 +66,7 @@ def dell_unpack(indata):
|
||||
mod_types = {
|
||||
0x01: "Main ROM",
|
||||
0x0C: "Microcode update",
|
||||
+ 0x52: "EC firmware"
|
||||
}
|
||||
|
||||
print("Dell/Phoenix ROM BIOS PLUS unpacker")
|
||||
@@ -107,7 +108,7 @@ while True:
|
||||
break
|
||||
data = f[offs:offs+leng]
|
||||
offs += leng
|
||||
- if type_id != 0xC:
|
||||
+ if type_id != 0xC and type_id != 0x52:
|
||||
odata = dell_unpack(data)
|
||||
else:
|
||||
odata = data
|
||||
--
|
||||
2.40.1
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
}
|
||||
|
||||
{bios_extract}{
|
||||
rev: effb120babde7e351c253f7c485848c8ce455dc0
|
||||
rev: 0a7bc1d71735ef97b00dfec0fd54a02fcc5d1bb0
|
||||
loc: bios_extract
|
||||
url: https://review.coreboot.org/bios_extract
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue