diff --git a/.cvsignore b/.cvsignore index 0e76468..1b7b664 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1 +1 @@ -bios_extract-17ca1c5e6a8df6b5663e899504d197862c286d1e.tar.bz2 +bios_extract-6ed57e5682e50088766faaaa680767d16be537a2.tar.bz2 diff --git a/bios_extract--ami_endian.diff b/bios_extract--ami_endian.diff deleted file mode 100644 index 1782f85..0000000 --- a/bios_extract--ami_endian.diff +++ /dev/null @@ -1,81 +0,0 @@ -From c07e897df4b1d64307550049d08ebcbbe258e593 Mon Sep 17 00:00:00 2001 -From: Peter Lemenkov -Date: Sat, 1 Aug 2009 20:55:17 +0400 -Subject: [PATCH] Fix for endianness in AMI extraction routines. - -Subj. Since I finally found AMI bios images among other ~ 2.5 Gbytes -of proprietary bioses. - -Signed-off-by: Peter Lemenkov - -diff --git a/ami.c b/ami.c -index 108ef1e..88a00d4 100644 ---- a/ami.c -+++ b/ami.c -@@ -27,6 +27,7 @@ - #include - #include - #include -+#include - - #include "bios_extract.h" - #include "lh5_extract.h" -@@ -177,7 +178,7 @@ AMI95Extract(unsigned char *BIOSImage, int BIOSLength, int BIOSOffset, - } - - /* now dump the individual modules */ -- Offset = (abc->BeginHi << 4) + abc->BeginLo; -+ Offset = (le16toh(abc->BeginHi) << 4) + le16toh(abc->BeginLo); - - for (i = 0; i < 0x80; i++) { - char filename[64], *ModuleName; -@@ -198,15 +199,15 @@ AMI95Extract(unsigned char *BIOSImage, int BIOSLength, int BIOSOffset, - sprintf(filename, "amibody_%02x.rom", part->PartID); - - if (Compressed) -- printf("0x%05X (%6d bytes)", Offset - BIOSOffset + 0x14, part->ROMSize); -+ printf("0x%05X (%6d bytes)", Offset - BIOSOffset + 0x14, le32toh(part->ROMSize)); - else -- printf("0x%05X (%6d bytes)", Offset - BIOSOffset + 0x0C, part->CSize); -+ printf("0x%05X (%6d bytes)", Offset - BIOSOffset + 0x0C, le16toh(part->CSize)); - - printf(" -> %s", filename); - if (part->PartID != 0x20) - printf(" "); - if (Compressed) -- printf(" (%5d bytes)", part->ExpSize); -+ printf(" (%5d bytes)", le32toh(part->ExpSize)); - else - printf("\t\t"); - -@@ -217,25 +218,25 @@ AMI95Extract(unsigned char *BIOSImage, int BIOSLength, int BIOSOffset, - printf("\n"); - - if (Compressed) -- BufferSize = part->ExpSize; -+ BufferSize = le32toh(part->ExpSize); - else -- BufferSize = part->CSize; -+ BufferSize = le16toh(part->CSize); - - Buffer = MMapOutputFile(filename, BufferSize); - if (!Buffer) - return FALSE; - - if (Compressed) -- LH5Decode(BIOSImage + (Offset - BIOSOffset) + 0x14, part->ROMSize, -+ LH5Decode(BIOSImage + (Offset - BIOSOffset) + 0x14, le32toh(part->ROMSize), - Buffer, BufferSize); - else - memcpy(Buffer, BIOSImage + (Offset - BIOSOffset) + 0x0C, BufferSize); - - munmap(Buffer, BufferSize); - -- if ((part->PrePartHi == 0xFFFF) || (part->PrePartLo == 0xFFFF)) -+ if ((le16toh(part->PrePartHi) == 0xFFFF) || (le16toh(part->PrePartLo) == 0xFFFF)) - break; -- Offset = (part->PrePartHi << 4) + part->PrePartLo; -+ Offset = (le16toh(part->PrePartHi) << 4) + le16toh(part->PrePartLo); - } - - return TRUE; diff --git a/bios_extract--phoenix_and_lh5_endian.diff b/bios_extract--phoenix_and_lh5_endian.diff deleted file mode 100644 index a1c4acf..0000000 --- a/bios_extract--phoenix_and_lh5_endian.diff +++ /dev/null @@ -1,158 +0,0 @@ -From 989a6c675212d459619a3a1e1c53dd6040e65867 Mon Sep 17 00:00:00 2001 -From: Peter Lemenkov -Date: Sat, 1 Aug 2009 20:37:56 +0400 -Subject: [PATCH] New version of endian patch. - -I removed #ifdefs completely, since they already exists in , -so we may simply (and safely) use htole[16,32]/le[16,32]toh. I also fixed -nasty typo in my prevoius patch - I should use le[16,32]to h rather than -htole[16,32]. However this renders to correct results,also, since both of -them are actually just #defines around bswap_[16,32]. - -Also, I found one phoenix BIOS image and therefore was able to fix extraction -from it on PowerPC. See patch. - -Signed-off-by: Peter Lemenkov - -diff --git a/lh5_extract.c b/lh5_extract.c -index 60ecd48..b3e2d98 100644 ---- a/lh5_extract.c -+++ b/lh5_extract.c -@@ -32,6 +32,7 @@ - #include - #include - #include -+#include - - #include "lh5_extract.h" - -@@ -129,18 +130,18 @@ LH5HeaderParse(unsigned char *Buffer, int BufferSize, - return 0; - } - -- *packed_size = *(unsigned int *) (Buffer + 7); -- *original_size = *(unsigned int *) (Buffer + 11); -+ *packed_size = le32toh(*(unsigned int *) (Buffer + 7)); -+ *original_size = le32toh(*(unsigned int *) (Buffer + 11)); - - name_length = Buffer[21]; - *name = strndup((char *) Buffer + 22, name_length); - -- *crc = *(unsigned short *) (Buffer + 22 + name_length); -+ *crc = le16toh(*(unsigned short *) (Buffer + 22 + name_length)); - - offset = header_size + 2; - /* Skip extended headers */ - while (1) { -- unsigned short extend_size = *(unsigned short *) (Buffer + offset - 2); -+ unsigned short extend_size = le16toh(*(unsigned short *) (Buffer + offset - 2)); - - if (!extend_size) - break; -diff --git a/phoenix.c b/phoenix.c -index 8ee241c..c2fe10a 100644 ---- a/phoenix.c -+++ b/phoenix.c -@@ -26,6 +26,7 @@ - #include - #include - #include -+#include - - #include "bios_extract.h" - #include "lh5_extract.h" -@@ -108,10 +109,10 @@ PhoenixModule(unsigned char *BIOSImage, int BIOSLength, int Offset) - return 0; - } - -- if ((Offset + Module->HeadLen + 4 + Module->Packed1) > BIOSLength) { -+ if ((Offset + Module->HeadLen + 4 + le32toh(Module->Packed1)) > BIOSLength) { - fprintf(stderr, "Error: Module overruns buffer at 0x%05X\n", - Offset); -- return Module->Previous; -+ return le32toh(Module->Previous); - } - - ModuleName = PhoenixModuleNameGet(Module->Type); -@@ -134,47 +135,47 @@ PhoenixModule(unsigned char *BIOSImage, int BIOSLength, int Offset) - switch (Module->Compression) { - case 5: /* LH5 */ - printf("0x%05X (%6d bytes) -> %s\t(%d bytes)", Offset + Module->HeadLen + 4, -- Module->Packed1, filename, Module->ExpLen1); -+ le32toh(Module->Packed1), filename, le32toh(Module->ExpLen1)); - -- Buffer = MMapOutputFile(filename, Module->ExpLen1); -+ Buffer = MMapOutputFile(filename, le32toh(Module->ExpLen1)); - if (!Buffer) - break; - - LH5Decode(BIOSImage + Offset + Module->HeadLen + 4, -- Module->Packed1, Buffer, Module->ExpLen1); -+ le32toh(Module->Packed1), Buffer, le32toh(Module->ExpLen1)); - -- munmap(Buffer, Module->ExpLen1); -+ munmap(Buffer, le32toh(Module->ExpLen1)); - - break; - /* case 3 */ /* LZSS */ - case 0: /* not compressed at all */ - /* why do we not use the full header here? */ - printf("0x%05X (%6d bytes) -> %s", Offset + Module->HeadLen, -- Module->Packed1, filename); -+ le32toh(Module->Packed1), filename); - -- write(fd, BIOSImage + Offset + Module->HeadLen, Module->Packed1); -+ write(fd, BIOSImage + Offset + Module->HeadLen, le32toh(Module->Packed1)); - break; - default: - fprintf(stderr, "Unsupported compression type for %s: %d\n", - filename, Module->Compression); - printf("0x%05X (%6d bytes) -> %s\t(%d bytes)", Offset + Module->HeadLen + 4, -- Module->Packed1, filename, Module->ExpLen1); -+ le32toh(Module->Packed1), filename, le32toh(Module->ExpLen1)); - -- write(fd, BIOSImage + Offset + Module->HeadLen + 4, Module->Packed1); -+ write(fd, BIOSImage + Offset + Module->HeadLen + 4, le32toh(Module->Packed1)); - break; - } - - close(fd); - free(filename); - -- if (Module->Offset || Module->Segment) { -+ if (le16toh(Module->Offset) || le16toh(Module->Segment)) { - if (!Module->Compression) - printf("\t\t"); -- printf("\t [0x%04X:0x%04X]\n", Module->Segment << 12, Module->Offset); -+ printf("\t [0x%04X:0x%04X]\n", le16toh(Module->Segment) << 12, le16toh(Module->Offset)); - } else - printf("\n"); - -- return Module->Previous; -+ return le32toh(Module->Previous); - } - - /* -@@ -195,11 +196,11 @@ PhoenixExtract(unsigned char *BIOSImage, int BIOSLength, int BIOSOffset, - - for (ID = (struct PhoenixID *) (BIOSImage + BCPSegmentOffset + 10); - ((void *) ID < (void *) (BIOSImage + BIOSLength)) && ID->Name[0]; -- ID = (struct PhoenixID *) (((unsigned char *) ID) + ID->Length)) { -+ ID = (struct PhoenixID *) (((unsigned char *) ID) + le16toh(ID->Length))) { - #if 0 - printf("PhoenixID: Name %c%c%c%c%c%c, Flags 0x%04X, Length %d\n", - ID->Name[0], ID->Name[1], ID->Name[2], ID->Name[3], -- ID->Name[4], ID->Name[5], ID->Flags, ID->Length); -+ ID->Name[4], ID->Name[5], le16toh(ID->Flags), le16toh(ID->Length)); - #endif - if (!strncmp(ID->Name, "BCPSYS", 6)) - break; -@@ -224,7 +225,7 @@ PhoenixExtract(unsigned char *BIOSImage, int BIOSLength, int BIOSOffset, - printf("Version \"%s\", created on %s at %s.\n", Version, Date, Time); - } - -- Offset = *((uint32_t *) (((char *) ID) + 0x77)); -+ Offset = le32toh(*((uint32_t *) (((char *) ID) + 0x77))); - Offset &= (BIOSLength - 1); - if (!Offset) { - fprintf(stderr, "Error: retrieved invalid Modules offset.\n"); diff --git a/bios_extract--recognition_of_more_bios_types.diff b/bios_extract--recognition_of_more_bios_types.diff deleted file mode 100644 index 6290185..0000000 --- a/bios_extract--recognition_of_more_bios_types.diff +++ /dev/null @@ -1,29 +0,0 @@ -From 2fe1f3c5351ce7d757a0dd63607b67cdcbf235b3 Mon Sep 17 00:00:00 2001 -From: Peter Lemenkov -Date: Sat, 1 Aug 2009 21:08:01 +0400 -Subject: [PATCH] Identification of some more BIOS images. - -Subj. Actually, I'm sure this is an ugly patch. The proper way will be -the addition of some special search procedures and some commandline -switches to force using of specific extraction routines ( -f ami, -f award). - -Anyway, here is a working patch for decoding Asus bioses. - -Signed-off-by: Peter Lemenkov - -diff --git a/bios_extract.c b/bios_extract.c -index 7b81c72..104232a 100644 ---- a/bios_extract.c -+++ b/bios_extract.c -@@ -89,6 +89,11 @@ static struct { - {"Award BootBlock", "= Award Decompression Bios =", AwardExtract}, - {"Phoenix FirstBIOS", "BCPSEGMENT", PhoenixExtract}, - {"PhoenixBIOS 4.0", "BCPSEGMENT", PhoenixExtract}, -+ /* custom modified BIOS from Asus - they replace "AMIBOOT " with their own -+ * BIOS ID text */ -+ {"ROM", "AMIBIOSC", AMI95Extract}, -+ /* some award modules - not sure this is a good solution */ -+ {"Award", "Award", AwardExtract}, - {NULL, NULL, NULL}, - }; - diff --git a/bios_extract-0001-Identification-of-some-more-Award-BIOS-images.patch b/bios_extract-0001-Identification-of-some-more-Award-BIOS-images.patch new file mode 100644 index 0000000..fe1bebe --- /dev/null +++ b/bios_extract-0001-Identification-of-some-more-Award-BIOS-images.patch @@ -0,0 +1,26 @@ +From 3bf81db29ad350f3ccab94d3416526e685d71321 Mon Sep 17 00:00:00 2001 +From: Peter Lemenkov +Date: Sun, 2 Aug 2009 14:30:05 +0400 +Subject: [PATCH 1/3] Identification of some more Award BIOS images. + +Signed-off-by: Peter Lemenkov +--- + bios_extract.c | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/bios_extract.c b/bios_extract.c +index cd87ee8..6c65532 100644 +--- a/bios_extract.c ++++ b/bios_extract.c +@@ -92,6 +92,8 @@ static struct { + {"Phoenix FirstBIOS", "BCPSEGMENT", PhoenixExtract}, + {"PhoenixBIOS 4.0", "BCPSEGMENT", PhoenixExtract}, + {"Phoenix TrustedCore", "BCPSEGMENT", PhoenixTrustedExtract}, ++ /* some award modules - not sure this is a good solution */ ++ {"Award Modular BIOS", "Award Software Inc", AwardExtract}, + {NULL, NULL, NULL}, + }; + +-- +1.6.6.1 + diff --git a/bios_extract-0002-Fixed-issue-with-modules-filenames-containing-slash.patch b/bios_extract-0002-Fixed-issue-with-modules-filenames-containing-slash.patch new file mode 100644 index 0000000..622dbcc --- /dev/null +++ b/bios_extract-0002-Fixed-issue-with-modules-filenames-containing-slash.patch @@ -0,0 +1,36 @@ +From 319d5265d21f95599cb6ead2f3683fbd0fe2dac8 Mon Sep 17 00:00:00 2001 +From: Peter Lemenkov +Date: Thu, 4 Feb 2010 16:40:49 +0300 +Subject: [PATCH 2/3] Fixed issue with modules filenames, containing slash. + +Some modules have names, containing slash character(s), so we cannot +simply write them to disk w/o either replacing slash with something else +(backslash, for example) or until we create necessary directories. + +Signed-off-by: Peter Lemenkov +--- + bios_extract.c | 6 ++++++ + 1 files changed, 6 insertions(+), 0 deletions(-) + +diff --git a/bios_extract.c b/bios_extract.c +index 6c65532..4f0423d 100644 +--- a/bios_extract.c ++++ b/bios_extract.c +@@ -42,8 +42,14 @@ unsigned char * + MMapOutputFile(char *filename, int size) + { + unsigned char* Buffer; ++ char* tmp = NULL; + int fd; + ++ /* all slash signs '/' in filenames will be replaced by backslash sign '\' */ ++ tmp = filename; ++ while ((tmp = strchr(tmp, '/')) != NULL) ++ tmp[0] = '\\'; ++ + fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); + if (fd < 0) { + fprintf(stderr, "Error: unable to open %s: %s\n\n", +-- +1.6.6.1 + diff --git a/bios_extract-0003-Allow-CFLAGS-override.patch b/bios_extract-0003-Allow-CFLAGS-override.patch new file mode 100644 index 0000000..59b28c6 --- /dev/null +++ b/bios_extract-0003-Allow-CFLAGS-override.patch @@ -0,0 +1,24 @@ +From 15173400b14d0644b8348ab0300e13841f26493c Mon Sep 17 00:00:00 2001 +From: Peter Lemenkov +Date: Fri, 2 Apr 2010 17:48:08 +0400 +Subject: [PATCH 3/3] Allow CFLAGS override + +Signed-off-by: Peter Lemenkov +--- + Makefile | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/Makefile b/Makefile +index 0313dad..5484387 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,5 +1,5 @@ + MAKE = make +-CFLAGS = -g -fpack-struct -Wall -O0 ++CFLAGS ?= -g -fpack-struct -Wall -O0 + CC = gcc + + all: bios_extract bcpvpd ami_slab +-- +1.6.6.1 + diff --git a/bios_extract.spec b/bios_extract.spec index 99772e3..4966d9b 100644 --- a/bios_extract.spec +++ b/bios_extract.spec @@ -1,21 +1,21 @@ -%define git_commit 17ca1c5e6a8df6b5663e899504d197862c286d1e -%define git_commit_date 20090713 +%global git_commit 6ed57e5682e50088766faaaa680767d16be537a2 +%global git_commit_date 20100423 Name: bios_extract Version: 0 -Release: 0.4.%{git_commit_date}git%{?dist} +Release: 0.5.%{git_commit_date}git%{?dist} Summary: Tools to extract the different submodules of common legacy bioses Group: Applications/System License: GPLv2+ URL: http://cgit.freedesktop.org/~libv/bios_extract Source0: http://cgit.freedesktop.org/~libv/bios_extract/snapshot/%{name}-%{git_commit}.tar.bz2 -# fix for extraction of Award and Phoenix bios-images on BigEndian platforms (patch sent upstream) -Patch0: bios_extract--ami_endian.diff -# fix for extraction of AMI bios-images on BigEndian platforms (patch sent upstream) -Patch1: bios_extract--phoenix_and_lh5_endian.diff -# recognized more bios images (ASUS for example) (patch sent upstream) -Patch2: bios_extract--recognition_of_more_bios_types.diff +# recognized more Award bios images (patch will be sent upstream) +Patch1: bios_extract-0001-Identification-of-some-more-Award-BIOS-images.patch +# Fixed issue with incorrect filenames, containing slash(es). Patch was sent upstream. +Patch2: bios_extract-0002-Fixed-issue-with-modules-filenames-containing-slash.patch +# Fedora-specific. Patch was sent upstream. +Patch3: bios_extract-0003-Allow-CFLAGS-override.patch BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) %description @@ -24,19 +24,19 @@ Tools to extract the different submodules of common legacy bioses. %prep %setup -q -n %{name}-%{git_commit} -sed -i s/^CFLAGS.*$// Makefile -%patch0 -p1 -b .big_endian -%patch1 -p1 -b .ami_big_endian -%patch2 -p1 -b .more_images +%patch1 -p1 -b .more_award_types +%patch2 -p1 -b .replace_shash_with_backslash +%patch3 -p1 -b .cflags_override %build -CFLAGS="%{optflags}" make %{?_smp_mflags} +CFLAGS="%{optflags} -fpack-struct" make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT install -p -m 0755 -D %{name} $RPM_BUILD_ROOT%{_bindir}/%{name} +install -p -m 0755 -D ami_slab $RPM_BUILD_ROOT%{_bindir}/ami_slab install -p -m 0755 -D bcpvpd $RPM_BUILD_ROOT%{_bindir}/bcpvpd %clean @@ -47,10 +47,17 @@ rm -rf $RPM_BUILD_ROOT %defattr(-,root,root,-) %doc README %{_bindir}/%{name} +%{_bindir}/ami_slab %{_bindir}/bcpvpd %changelog +* Sat Apr 24 2010 Peter Lemenkov 0-0.5.20100423git +- Added more BIOS types +- Added ami_slab utility +- Added -fpack-struct to CFLAGS (required to properly parse some BIOS blobs) +- Patches rebased (and dropped uptreamed ones) + * Sat Aug 1 2009 Peter Lemenkov 0-0.4.20090713git - Fixed work on BigEndian platforms - More bios-types recognized diff --git a/import.log b/import.log index 4900567..3889b38 100644 --- a/import.log +++ b/import.log @@ -1,2 +1,3 @@ bios_extract-0-0_2_20090713git_fc11:HEAD:bios_extract-0-0.2.20090713git.fc11.src.rpm:1248367822 bios_extract-0-0_4_20090713git_fc11:HEAD:bios_extract-0-0.4.20090713git.fc11.src.rpm:1249153598 +bios_extract-0-0_5_20100423git_fc12:F-12:bios_extract-0-0.5.20100423git.fc12.src.rpm:1272129651 diff --git a/sources b/sources index 5f2adb9..9cd69d4 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -538704606cbd27a85a0f2aaa74592862 bios_extract-17ca1c5e6a8df6b5663e899504d197862c286d1e.tar.bz2 +40ec009e6a92c83f5390dbbf7d43f9fe bios_extract-6ed57e5682e50088766faaaa680767d16be537a2.tar.bz2