[LinuxBIOS] r452 - in LinuxBIOSv3: arch/x86 include lib

svn at openbios.org svn at openbios.org
Thu Jul 12 22:03:02 CEST 2007


Author: oxygene
Date: 2007-07-12 22:03:02 +0200 (Thu, 12 Jul 2007)
New Revision: 452

Modified:
   LinuxBIOSv3/arch/x86/Makefile
   LinuxBIOSv3/arch/x86/stage1.c
   LinuxBIOSv3/include/lar.h
   LinuxBIOSv3/lib/elfboot.c
   LinuxBIOSv3/lib/lar.c
   LinuxBIOSv3/lib/lzma.c
   LinuxBIOSv3/lib/nrv2b.c
Log:
- fix build of ulzma
- support decompression in the lar loader
- support compressed payloads in stage1
  (copies payloads to 0x60000 unconditionally)
- hook up decompressors in Makefile
- disable compression for option_table and initram

Signed-off-by: Patrick Georgi <patrick at georgi-clan.de>
Acked-by: Stefan Reinauer <stepan at coresystems.de>


Modified: LinuxBIOSv3/arch/x86/Makefile
===================================================================
--- LinuxBIOSv3/arch/x86/Makefile	2007-07-12 16:43:13 UTC (rev 451)
+++ LinuxBIOSv3/arch/x86/Makefile	2007-07-12 20:03:02 UTC (rev 452)
@@ -37,6 +37,27 @@
 
 ROM_SIZE := $(shell expr $(CONFIG_LINUXBIOS_ROMSIZE_KB) \* 1024)
 
+LARFILES := nocompress:normal/initram normal/stage2 nocompress:normal/option_table
+ifneq ($(CONFIG_PAYLOAD_NONE),y)
+LARFILES += normal/payload
+endif
+
+DECOMPRESSORS :=
+ifeq ($(CONFIG_COMPRESSION_LZMA),y)
+DECOMPRESSORS += lzma.o
+endif
+ifeq ($(CONFIG_COMPRESSION_NRV2B),y)
+DECOMPRESSORS += nrv2b.o
+endif
+
+COMPRESSFLAG :=
+ifeq ($(CONFIG_DEFAULT_COMPRESSION_LZMA),y)
+COMPRESSFLAG := -C lzma
+endif
+ifeq ($(CONFIG_DEFAULT_COMPRESSION_NRV2B),y)
+COMPRESSFLAG := -C nrv2b
+endif
+
 $(obj)/linuxbios.rom: $(obj)/linuxbios.bootblock $(obj)/util/lar/lar lzma nrv2b $(obj)/linuxbios.initram $(obj)/linuxbios.stage2 $(obj)/option_table
 	$(Q)rm -rf $(obj)/lar.tmp
 	$(Q)mkdir $(obj)/lar.tmp
@@ -57,7 +78,9 @@
 	fi
 endif
 	$(Q)printf "  LAR     $(subst $(shell pwd)/,,$(@))\n"
-	$(Q)cd $(obj)/lar.tmp && ../util/lar/lar -c ../linuxbios.rom . \
+	$(Q)cd $(obj)/lar.tmp && ../util/lar/lar $(COMPRESSFLAG) -c \
+		../linuxbios.rom \
+		$(LARFILES) \
 		-s $(ROM_SIZE) -b $(obj)/linuxbios.bootblock
 	$(Q)# QEMU wants bios.bin:
 	$(Q)# Run "qemu -L build/ -serial stdio -hda /dev/zero".
@@ -75,7 +98,7 @@
 #
 
 STAGE0_LIB_OBJ       = uart8250.o mem.o elfboot.o lar.o delay.o vtxprintf.o \
-		       vsprintf.o console.o
+		       vsprintf.o console.o $(DECOMPRESSORS)
 STAGE0_ARCH_X86_OBJ  = stage1.o serial.o archelfboot.o speaker.o \
 		       udelay_io.o mc146818rtc.o
 

Modified: LinuxBIOSv3/arch/x86/stage1.c
===================================================================
--- LinuxBIOSv3/arch/x86/stage1.c	2007-07-12 16:43:13 UTC (rev 451)
+++ LinuxBIOSv3/arch/x86/stage1.c	2007-07-12 20:03:02 UTC (rev 452)
@@ -25,6 +25,8 @@
 #include <lib.h>
 #include <mc146818rtc.h>
 
+#define UNCOMPRESS_AREA 0x60000
+
 /* these prototypes should go into headers */
 void uart_init(void);
 void die(const char *msg);
@@ -230,13 +232,18 @@
 
 	ret = find_file(&archive, "normal/payload", &result);
 	if (ret) {
-		printk(BIOS_WARNING, "No such file '%s'.\n", "normal/payload");
+		printk(BIOS_ERR, "No such file '%s'.\n", "normal/payload");
 		die("FATAL: No payload found.\n");
 	}
+	ret = copy_file(&archive, "normal/payload", (void *)UNCOMPRESS_AREA);
+	if (ret) {
+		printk(BIOS_ERR, "'%s' found, but could not load it.\n", "normal/payload");
+		die("FATAL: No usable payload found.\n");
+	}
 
-	ret =  elfboot_mem(mem, result.start, result.len);
+	ret =  elfboot_mem(mem, (void *)UNCOMPRESS_AREA, result.reallen);
 
-	printk(BIOS_DEBUG, "elfboot_mem returns %d\n", ret);
+	printk(BIOS_ERR, "elfboot_mem returns %d\n", ret);
 
 	die ("FATAL: Last stage returned to LinuxBIOS.\n");
 }

Modified: LinuxBIOSv3/include/lar.h
===================================================================
--- LinuxBIOSv3/include/lar.h	2007-07-12 16:43:13 UTC (rev 451)
+++ LinuxBIOSv3/include/lar.h	2007-07-12 20:03:02 UTC (rev 452)
@@ -68,6 +68,8 @@
 struct mem_file {
 	void *start;
 	int len;
+	u32 reallen;
+	u32 compression;
 };
 
 /* Prototypes. */

Modified: LinuxBIOSv3/lib/elfboot.c
===================================================================
--- LinuxBIOSv3/lib/elfboot.c	2007-07-12 16:43:13 UTC (rev 451)
+++ LinuxBIOSv3/lib/elfboot.c	2007-07-12 20:03:02 UTC (rev 452)
@@ -185,6 +185,8 @@
 			continue;
 		}
 		printk(BIOS_DEBUG, "Found ELF candidate at offset %d\n", i);
+			header_offset = i;
+			break;
 		/* Sanity check the elf header */
 		if ((ehdr->e_type == ET_EXEC) &&
 			elf_check_arch(ehdr) &&

Modified: LinuxBIOSv3/lib/lar.c
===================================================================
--- LinuxBIOSv3/lib/lar.c	2007-07-12 16:43:13 UTC (rev 451)
+++ LinuxBIOSv3/lib/lar.c	2007-07-12 20:03:02 UTC (rev 452)
@@ -53,6 +53,8 @@
 		if (strcmp(fullname, filename) == 0) {
 			result->start = walk + ntohl(header->offset);
 			result->len = ntohl(header->len);
+			result->reallen = ntohl(header->reallen);
+			result->compression = ntohl(header->compression);
 			return 0;
 		}
 		// skip file
@@ -74,9 +76,31 @@
 		return 1;
 	}
 
-	memcpy(where, result.start, result.len);
-
-	return 0;
+	printk(BIOS_SPEW, "LAR: Compression algorithm #%i used\n", result.compression);
+	/* no compression */
+	if (result.compression == 0) {
+		memcpy(where, result.start, result.len);
+		return 0;
+	}
+#ifdef CONFIG_COMPRESSION_LZMA
+	/* lzma */
+	unsigned long ulzma(unsigned char * src, unsigned char * dst);
+	if (result.compression == 1) {
+		ulzma(result.start, where);
+		return 0;
+	}
+#endif
+#ifdef CONFIG_COMPRESSION_NRV2B
+	/* nrv2b */
+	unsigned long unrv2b(u8 * src, u8 * dst, unsigned long *ilen_p);
+	if (result.compression == 2) {
+		int tmp;
+		unrv2b(result.start, where, &tmp);
+		return 0;
+	}
+#endif
+	printk(BIOS_INFO, "LAR: Compression algorithm #%i not supported!\n", result.compression);
+	return 1;
 }
 
 int run_file(struct mem_file *archive, char *filename, void *where)

Modified: LinuxBIOSv3/lib/lzma.c
===================================================================
--- LinuxBIOSv3/lib/lzma.c	2007-07-12 16:43:13 UTC (rev 451)
+++ LinuxBIOSv3/lib/lzma.c	2007-07-12 20:03:02 UTC (rev 452)
@@ -7,9 +7,11 @@
 */
 
 #include "lzmadecode.c"
+#include "string.h"
+#include "console.h"
 
 
-static unsigned long ulzma(unsigned char * src, unsigned char * dst)
+unsigned long ulzma(u8 *src, u8 *dst)
 {
 	unsigned char properties[LZMA_PROPERTIES_SIZE];
 	UInt32 outSize;

Modified: LinuxBIOSv3/lib/nrv2b.c
===================================================================
--- LinuxBIOSv3/lib/nrv2b.c	2007-07-12 16:43:13 UTC (rev 451)
+++ LinuxBIOSv3/lib/nrv2b.c	2007-07-12 20:03:02 UTC (rev 452)
@@ -1,3 +1,4 @@
+#include <types.h>
 // This GETBIT is supposed to work on little endian 
 // 32bit systems. The algorithm will definitely need
 // some fixing on other systems, but it might not be
@@ -28,7 +29,8 @@
 #if ENDIAN == 0 && BITSIZE == 32
 #define GETBIT(bb, src, ilen) GETBIT_LE32(bb, src, ilen)
 #endif
-static unsigned long unrv2b(u8 * src, u8 * dst, unsigned long *ilen_p)
+
+unsigned long unrv2b(u8 *src, u8 *dst, unsigned long *ilen_p)
 {
 	unsigned long ilen = 0, olen = 0, last_m_off = 1;
 	u32 bb = 0;





More information about the coreboot mailing list