Patchwork bios_extract

login
register
about
Submitter Rudolf Marek
Date 2009-12-19 01:08:08
Message ID <4B2C2778.5070600@assembler.cz>
Download mbox | patch
Permalink /patch/669/
State Not Applicable
Headers show

Comments

Rudolf Marek - 2009-12-19 01:08:08
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

I think I can CC the coreboot list too. I wanted to extract the Asrock "AMI" ROM
found in the 939A785GMH/128M.

I had to add following changes to the ami.c

1) there is a flag for uncompressed module 0x90 instead of 0x80 dunno why
2) if the module size in rom > 0xffff some bytes before the structure are used
as size, the second number looks like crc maybe.
3) the type of 0x40 and 0x60 is AMD CIM-X but it has compress set, but those
modules are not.

Signed-off-by: Rudolf Marek <r.marek@assembler.cz>

Maybe you will need bit to re-arrange patch...

Rudolf
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkssJ3gACgkQ3J9wPJqZRNV4OACgnIfGVUivdz2K8HpQhPjCT86r
bagAniFQwJ7QKafPiFHc2vQC2SFyODOT
=87BW
-----END PGP SIGNATURE-----
Rudolf Marek - 2009-12-21 23:54:33
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> 1) there is a flag for uncompressed module 0x90 instead of 0x80 dunno why
> 2) if the module size in rom > 0xffff some bytes before the structure are used
> as size, the second number looks like crc maybe.

It turns out the extra header is there for all modules.

The unknown value is a simple 32bit sum over HEADER and BODY to sum up to 0 ;)

Dont know how it works for compressed modules nor how it works for modules with
not multiple of 4. It should be easy to get.

Rudolf



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkswCrkACgkQ3J9wPJqZRNXA7QCePP/LvJYyhL/wDOlxdraOB8OU
GrMAoNfwNV3Tgp4Z2wja16q4YcVJHV1g
=svpM
-----END PGP SIGNATURE-----
Luc Verhaegen - 2009-12-22 12:46:55
On Tue, Dec 22, 2009 at 12:54:33AM +0100, Rudolf Marek wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> > 1) there is a flag for uncompressed module 0x90 instead of 0x80 dunno why
> > 2) if the module size in rom > 0xffff some bytes before the structure are used
> > as size, the second number looks like crc maybe.
> 
> It turns out the extra header is there for all modules.
> 
> The unknown value is a simple 32bit sum over HEADER and BODY to sum up to 0 ;)
> 
> Dont know how it works for compressed modules nor how it works for modules with
> not multiple of 4. It should be easy to get.
> 
> Rudolf
I have seen these headers on compressed too i think. Will have another 
look at the 2MB module to check. In the meantime, we should add this 
info.

Luc Verhaegen.
Rudolf Marek - 2010-01-04 19:38:01
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

I noticed in the 939A785GMH/128M is a "hole" which starts at offset 128KB and is
64KB this place holds a firmware for the SB710 8051. Some tools as mmtool for
ami at least report the "hole", so this info must be written in the BIOS info maybe?

Rudolf
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAktCQ5kACgkQ3J9wPJqZRNXUHQCfaXLCnYEsZSrcPy5er4DFEq1X
FFIAoJ9OdsRP5ZkunE+Kq6XOJEvd3tVa
=g6hS
-----END PGP SIGNATURE-----

Patch

diff --git a/ami.c b/ami.c
index 88a00d4..50d412a 100644
--- a/ami.c
+++ b/ami.c
@@ -90,7 +90,15 @@  AMI95ModuleNames[] = {
     {0x38, "Lang1 as ROM"},
     {0x39, "Lang2 as ROM"},
     {0x3A, "Lang3 as ROM"},
+    {0x40, "AMD CIM-X NB binary"},
+    {0x60, "AMD CIM-X SB binary"},
     {0x70, "OSD Bitmaps"},
+    {0xf0, "Asrock Backup Util"},
+    {0xf9, "Asrock AMD AHCI DLL"},
+    {0xfa, "Asrock LOGO GIF"},
+    {0xfb, "Asrock LOGO JPG"},
+    {0xfc, "Asrock LOGO JPG"},
+    {0xfd, "Asrock LOGO PCX - Instant boot"},
     {0, NULL}
 };
 
@@ -118,6 +126,7 @@  AMI95Extract(unsigned char *BIOSImage, int BIOSLength, int BIOSOffset,
     char Date[9];
     int i;
 
+
     struct abc {
 	const char AMIBIOSC[8];
 	const char Version[4];
@@ -127,6 +136,11 @@  AMI95Extract(unsigned char *BIOSImage, int BIOSLength, int BIOSOffset,
 	const uint16_t BeginHi;
     } *abc;
 
+struct bigpart {
+	const uint32_t CSize;
+	const uint32_t Unknown;
+} *bigpart;
+
     struct part {
 	/* When Previous Part Address is 0xFFFFFFFF, then this is the last part. */
 	const uint16_t PrePartLo; /* Previous part low word */
@@ -139,6 +153,9 @@  AMI95Extract(unsigned char *BIOSImage, int BIOSLength, int BIOSOffset,
 	const uint32_t ExpSize; /* Expanded Length */
     } *part;
 
+
+printf("%x %x \n", AMIBOffset, ABCOffset);
+
     if (!ABCOffset) {
 	if ((BIOSImage[8] == '1') && (BIOSImage[9] == '0') &&
 	    (BIOSImage[11] == '1') && (BIOSImage[12] == '0'))
@@ -188,11 +205,15 @@  AMI95Extract(unsigned char *BIOSImage, int BIOSLength, int BIOSOffset,
 
 	part = (struct part *) (BIOSImage + (Offset - BIOSOffset));
 
-	if (part->IsComprs == 0x80)
+	if ((part->IsComprs == 0x80) || (part->IsComprs == 0x90))
 	    Compressed = FALSE;
 	else
 	    Compressed = TRUE;
 
+	/* even they claim they are compressed they arent */
+	if ((part->PartID == 0x40) || (part->PartID == 0x60))
+		Compressed = FALSE;
+
 	if (part->PartID == 0x20)
 	    sprintf(filename, "amipci_%02X_%02X.rom", Multiple++, part->PartID);
 	else
@@ -204,6 +225,7 @@  AMI95Extract(unsigned char *BIOSImage, int BIOSLength, int BIOSOffset,
 	    printf("0x%05X (%6d bytes)", Offset - BIOSOffset + 0x0C, le16toh(part->CSize));
 
 	printf(" -> %s", filename);
+
 	if (part->PartID != 0x20)
 	    printf("  ");
 	if (Compressed)
@@ -222,6 +244,11 @@  AMI95Extract(unsigned char *BIOSImage, int BIOSLength, int BIOSOffset,
 	else
 	    BufferSize = le16toh(part->CSize);
 
+	if ((BufferSize == 0xFFFF) && (!Compressed))  {
+		bigpart = (struct bigpart *) (BIOSImage + (Offset - BIOSOffset) - sizeof(struct bigpart));
+		BufferSize = bigpart->CSize;
+	}
+
 	Buffer = MMapOutputFile(filename, BufferSize);
 	if (!Buffer)
 	    return FALSE;