Skip to content

Commit 4f55b46

Browse files
committed
bios_extract: Add support for Phoenix-compressed Compaq BIOS
1 parent b093a62 commit 4f55b46

File tree

2 files changed

+72
-65
lines changed

2 files changed

+72
-65
lines changed

bios_extract/src/bios_extract.c

+1
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ static struct {
198198
"PowerBIOS Setup\x00", NULL, AwardExtract}, { /* Siemens PowerBIOS */
199199
"Phoenix Technologies", "BCPSEGMENT", PhoenixExtract}, {
200200
"\x00IBM AT Compatible Phoenix NuBIOS", "BCPSEGMENT", PhoenixExtract}, { /* Phoenix copyrights scrubbed (Gateway Solo 2500) */
201+
" 102-System Board Failure", "BCPCMP", PhoenixExtract}, { /* Phoenix-compressed Compaq BIOS (Presario 4800) */
201202
"\xEE\x88SYSBIOS", "\xEE\x88", SystemSoftExtract}, {
202203
"\xEE\x88\x42IOS SCU", "\xEE\x88", SystemSoftExtract}, {
203204
"\xFF\x88SYSBIOS", "\xFF\x88", SystemSoftExtract}, { /* Insyde */

bios_extract/src/phoenix.c

+71-65
Original file line numberDiff line numberDiff line change
@@ -933,87 +933,93 @@ PhoenixExtract(unsigned char *BIOSImage, int BIOSLength, int BIOSOffset,
933933
InitRemainder(BIOSImage, BIOSLength);
934934
}
935935

936-
for (ID = (struct PhoenixID *)(BIOSImage + BCPSegmentOffset + 10);
937-
((void *)ID < (void *)(BIOSImage + BIOSLength)) && ID->Name[0];
938-
ID =
939-
(struct PhoenixID *)(((unsigned char *)ID) +
940-
le16toh(ID->Length))) {
936+
struct bcpCompress *bcpComp = NULL;
937+
if (!memcmp(BIOSImage + BCPSegmentOffset, "BCPSEGMENT", 10)) {
938+
for (ID = (struct PhoenixID *)(BIOSImage + BCPSegmentOffset + 10);
939+
((void *)ID < (void *)(BIOSImage + BIOSLength)) && ID->Name[0];
940+
ID =
941+
(struct PhoenixID *)(((unsigned char *)ID) +
942+
le16toh(ID->Length))) {
941943
#if 0
942-
printf
943-
("PhoenixID: Name %c%c%c%c%c%c, Flags 0x%04X, Length %d, Position %05X\n",
944-
ID->Name[0], ID->Name[1], ID->Name[2], ID->Name[3],
945-
ID->Name[4], ID->Name[5], le16toh(ID->Flags),
946-
le16toh(ID->Length), (unsigned int) (((unsigned char *) ID) - BIOSImage));
944+
printf
945+
("PhoenixID: Name %c%c%c%c%c%c, Flags 0x%04X, Length %d, Position %05X\n",
946+
ID->Name[0], ID->Name[1], ID->Name[2], ID->Name[3],
947+
ID->Name[4], ID->Name[5], le16toh(ID->Flags),
948+
le16toh(ID->Length), (unsigned int) (((unsigned char *) ID) - BIOSImage));
947949
#endif
948-
if (!le16toh(ID->Length))
949-
break;
950-
951-
if (!strncmp(ID->Name, "BCPSYS", 6)) {
952-
SYS = ID;
953-
if (FFV)
950+
if (!le16toh(ID->Length))
954951
break;
955-
} else if (!strncmp(ID->Name, "BCPFFV", 6)) {
956-
FFV = ID;
957-
if (SYS)
958-
break;
959-
}
960-
}
961952

962-
if (!SYS) {
963-
SYS = (struct PhoenixID *) memmem(BIOSImage, BIOSLength - 6, "BCPSYS", 6);
953+
if (!strncmp(ID->Name, "BCPSYS", 6)) {
954+
SYS = ID;
955+
if (FFV)
956+
break;
957+
} else if (!strncmp(ID->Name, "BCPFFV", 6)) {
958+
FFV = ID;
959+
if (SYS)
960+
break;
961+
}
962+
}
964963

965964
if (!SYS) {
966-
fprintf(stderr, "Error: Failed to locate BCPSYS offset.\n");
967-
return FALSE;
968-
}
969-
}
965+
SYS = (struct PhoenixID *) memmem(BIOSImage, BIOSLength - 6, "BCPSYS", 6);
970966

971-
/* Get some info */
972-
char Date[9], Time[9], Version[9];
967+
if (!SYS) {
968+
fprintf(stderr, "Error: Failed to locate BCPSYS offset.\n");
969+
return FALSE;
970+
}
971+
}
973972

974-
strncpy(Date, ((char *)SYS) + 0x0F, 8);
975-
Date[8] = 0;
976-
strncpy(Time, ((char *)SYS) + 0x18, 8);
977-
Time[8] = 0;
978-
strncpy(Version, ((char *)SYS) + 0x37, 8);
979-
Version[8] = 0;
973+
/* Get some info */
974+
char Date[9], Time[9], Version[9];
980975

981-
printf("Version \"%s\", created on %s at %s.\n", Version, Date, Time);
976+
strncpy(Date, ((char *)SYS) + 0x0F, 8);
977+
Date[8] = 0;
978+
strncpy(Time, ((char *)SYS) + 0x18, 8);
979+
Time[8] = 0;
980+
strncpy(Version, ((char *)SYS) + 0x37, 8);
981+
Version[8] = 0;
982982

983-
if (!FFV)
984-
FFV = (struct PhoenixID *) memmem(BIOSImage, BIOSLength - 6, "BCPFFV", 6);
983+
printf("Version \"%s\", created on %s at %s.\n", Version, Date, Time);
985984

986-
/* BCPCMP parsing */
985+
if (!FFV)
986+
FFV = (struct PhoenixID *) memmem(BIOSImage, BIOSLength - 6, "BCPFFV", 6);
987987

988-
unsigned char *bcpcmp = memmem(BIOSImage, BIOSLength - 6, "BCPCMP", 6);
989-
struct bcpCompress *bcpComp = NULL;
990-
if (bcpcmp) {
991-
uint32_t bcpoff = bcpcmp - BIOSImage;
992-
bcpComp = (struct bcpCompress *)(BIOSImage + bcpoff);
993-
phx.compression = bcpComp->alg;
994-
if ((bcpComp->head.major_revision == 0) && (bcpComp->head.minor_revision == 0))
995-
phx.commonCharacterLZSS = bcpComp->alt.commonCharacterLZSS;
996-
else
997-
phx.commonCharacterLZSS = bcpComp->main.commonCharacterLZSS;
998-
} else {
999-
/* BCPCMP can be missing (Hitachi Flora 3100 - 4.04 for Corollary C-bus) */
1000-
phx.compression = 0;
1001-
phx.commonCharacterLZSS = ' ';
1002-
}
988+
/* BCPCMP parsing */
1003989

1004-
if (SYS->Length >= 0x7b) {
1005-
Offset = le32toh(*((uint32_t *) (((char *)SYS) + 0x77)));
1006-
Offset &= (BIOSLength - 1);
1007-
if (!Offset) {
1008-
fprintf(stderr, "BCPSYS module offset is NULL.\n");
1009-
if (FFV)
1010-
PhoenixFFV(BIOSImage, BIOSLength, FFV);
990+
unsigned char *bcpcmp = memmem(BIOSImage, BIOSLength - 6, "BCPCMP", 6);
991+
if (bcpcmp) {
992+
uint32_t bcpoff = bcpcmp - BIOSImage;
993+
bcpComp = (struct bcpCompress *)(BIOSImage + bcpoff);
994+
phx.compression = bcpComp->alg;
995+
if ((bcpComp->head.major_revision == 0) && (bcpComp->head.minor_revision == 0))
996+
phx.commonCharacterLZSS = bcpComp->alt.commonCharacterLZSS;
997+
else
998+
phx.commonCharacterLZSS = bcpComp->main.commonCharacterLZSS;
999+
} else {
1000+
/* BCPCMP can be missing (Hitachi Flora 3100 - 4.04 for Corollary C-bus) */
1001+
phx.compression = 0;
1002+
phx.commonCharacterLZSS = ' ';
10111003
}
10121004

1013-
while (Offset) {
1014-
Offset = PhoenixModule(BIOSImage, BIOSLength, Offset);
1015-
Offset &= BIOSLength - 1;
1005+
if (SYS->Length >= 0x7b) {
1006+
Offset = le32toh(*((uint32_t *) (((char *)SYS) + 0x77)));
1007+
Offset &= (BIOSLength - 1);
1008+
if (!Offset) {
1009+
fprintf(stderr, "BCPSYS module offset is NULL.\n");
1010+
if (FFV)
1011+
PhoenixFFV(BIOSImage, BIOSLength, FFV);
1012+
}
1013+
1014+
while (Offset) {
1015+
Offset = PhoenixModule(BIOSImage, BIOSLength, Offset);
1016+
Offset &= BIOSLength - 1;
1017+
}
10161018
}
1019+
} else {
1020+
printf("Phoenix-compressed Compaq BIOS.\n");
1021+
phx.compression = 2;
1022+
phx.commonCharacterLZSS = ' ';
10171023
}
10181024

10191025
/* All scans below based on phoedeco */

0 commit comments

Comments
 (0)