summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuc Verhaegen <libv@skynet.be>2009-07-13 11:46:37 +0200
committerLuc Verhaegen <libv@skynet.be>2009-07-13 11:46:37 +0200
commit5c343ad78251ac0323e119645d58559dfd494b6d (patch)
tree6adda11405c68aeb238eec19eaf9f9ecf0a3568f
parent1558735183683e474eab151af7bdb65afbee36de (diff)
Add award support.
-rw-r--r--Makefile2
-rw-r--r--award.c71
-rw-r--r--bios_extract.c1
-rw-r--r--bios_extract.h4
4 files changed, 77 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 3339148..367a7c9 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ CC = gcc
all: bios_extract bcpvpd
-BIOS_EXTRACT_OBJS = lh5_extract.o phoenix.o ami.o bios_extract.o
+BIOS_EXTRACT_OBJS = lh5_extract.o ami.o award.o phoenix.o bios_extract.o
bios_extract: $(BIOS_EXTRACT_OBJS)
$(CC) $(CFLAGS) $(BIOS_EXTRACT_OBJS) -o bios_extract
diff --git a/award.c b/award.c
new file mode 100644
index 0000000..479cfce
--- /dev/null
+++ b/award.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2009 Luc Verhaegen <libv@skynet.be>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#define _GNU_SOURCE 1 /* for memmem */
+
+#include <stdio.h>
+#include <inttypes.h>
+#include <string.h>
+#include <sys/mman.h>
+
+#include "bios_extract.h"
+#include "lh5_extract.h"
+
+/*
+ *
+ */
+Bool
+AwardExtract(unsigned char *BIOSImage, int BIOSLength, int BIOSOffset,
+ uint32_t Offset1, uint32_t BCPSegmentOffset)
+{
+ unsigned char *p, *Buffer;
+ int HeaderSize;
+ unsigned int BufferSize, PackedSize;
+ char *filename;
+ unsigned short crc;
+
+ printf("Found Award BIOS.\n");
+
+ p = BIOSImage;
+ while (p) {
+ p = memmem(p, BIOSLength - (p - BIOSImage), "-lh5-", 5);
+ if (!p)
+ break;
+ p -= 2;
+ HeaderSize = LH5HeaderParse(p, BIOSLength - (p - BIOSImage),
+ &BufferSize, &PackedSize, &filename, &crc);
+ if (!HeaderSize)
+ return FALSE;
+
+ printf("0x%05X (%6d bytes) -> %s \t(%6d bytes)\n",
+ (unsigned int) (p - BIOSImage), HeaderSize + PackedSize,
+ filename, BufferSize);
+
+ Buffer = MMapOutputFile(filename, BufferSize);
+ if (!Buffer)
+ return FALSE;
+
+ LH5Decode(p + HeaderSize, PackedSize, Buffer, BufferSize);
+
+ munmap(Buffer, BufferSize);
+
+ p += HeaderSize + PackedSize;
+ }
+
+ return TRUE;
+}
diff --git a/bios_extract.c b/bios_extract.c
index 316dd76..21c8473 100644
--- a/bios_extract.c
+++ b/bios_extract.c
@@ -83,6 +83,7 @@ static struct {
uint32_t Offset1, uint32_t Offset2);
} BIOSIdentification[] = {
{"AMIBOOT ROM", "AMIBIOSC", AMI95Extract},
+ {"Award BootBlock", "= Award Decompression Bios =", AwardExtract},
{"Phoenix FirstBIOS", "BCPSEGMENT", PhoenixExtract},
{"PhoenixBIOS 4.0", "BCPSEGMENT", PhoenixExtract},
{NULL, NULL, NULL},
diff --git a/bios_extract.h b/bios_extract.h
index 1c7df9a..c8bc764 100644
--- a/bios_extract.h
+++ b/bios_extract.h
@@ -34,4 +34,8 @@ Bool AMI95Extract(unsigned char *BIOSImage, int BIOSLength, int BIOSOffset,
Bool PhoenixExtract(unsigned char *BIOSImage, int BIOSLength, int BIOSOffset,
uint32_t Offset1, uint32_t Offset2);
+/* award.c */
+Bool AwardExtract(unsigned char *BIOSImage, int BIOSLength, int BIOSOffset,
+ uint32_t Offset1, uint32_t Offset2);
+
#endif /* BIOS_EXTRACT_H */