from now on, the lzma loader is able to pass parameters to the kernel

SVN-Revision: 7723
This commit is contained in:
Gabor Juhos 2007-06-25 08:47:10 +00:00
parent 8c41e51e92
commit fcc5a6e252
6 changed files with 255 additions and 86 deletions

View file

@ -7,18 +7,14 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/image.mk include $(INCLUDE_DIR)/image.mk
IMGNAME = $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)
LOADER_MAKE = $(MAKE) -C lzma-loader KDIR=$(KDIR) LOADER_MAKE = $(MAKE) -C lzma-loader KDIR=$(KDIR)
define PrepareLoader define Image/Build/Loader
$(LOADER_MAKE) LOADER=$(1) LOADER_DATA="" \ $(LOADER_MAKE) LOADER=loader-$(1).$(2) LOADER_DATA="" \
LZMA_TEXT_START=$(2) LZMA_STARTUP_ORG=$(3) \ LZMA_TEXT_START=$(3) LZMA_STARTUP_ORG=$(4) \
compile CONFIG_PASS_KARGS=$(5) CONFIG_BOARD=$(6) \
compile loader.$(2)
endef
define PrepareLZMAKernel
$(LOADER_MAKE) LOADER=vmlinux-lzma-$(1) LOADER_DATA=$(KDIR)/vmlinux.lzma \
LZMA_TEXT_START=$(2) LZMA_STARTUP_ORG=$(3) \
compile
endef endef
define Build/Clean define Build/Clean
@ -27,13 +23,6 @@ endef
define Image/Prepare define Image/Prepare
cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
$(call PrepareLoader,generic,0x80500000,0)
$(call PrepareLoader,admboot,0x80500000,0x6D8)
else
$(call PrepareLZMAKernel,generic,0x80500000,0)
$(call PrepareLZMAKernel,admboot,0x80500000,0x6D8)
endif
endef endef
define trxalign/jffs2-128k define trxalign/jffs2-128k
@ -46,36 +35,57 @@ define trxalign/squashfs
-a 1024 -a 1024
endef endef
define Image/Build/TRX
$(STAGING_DIR)/bin/trx -o $(1) -f $(3) -f $(KDIR)/vmlinux.lzma \
$(call trxalign/$(2)) -f $(KDIR)/root.$(2)
endef
define Image/Build/TRXNoloader
$(STAGING_DIR)/bin/trx -o $(1) -f $(KDIR)/vmlinux.lzma \
$(call trxalign/$(2)) -f $(KDIR)/root.$(2)
endef
define Image/Build/Compex define Image/Build/Compex
$(CP) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).trx $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(3)-$(2).trx $(call Image/Build/Loader,$(2),gz,0x80500000,0,y,$(2))
$(call Image/Build/TRX,$(IMGNAME)-$(3)-$(2).trx,$(1),$(KDIR)/loader-$(2).gz)
endef endef
define Image/Build/Edimax define Image/Build/Edimax
$(call Image/Build/Loader,$(2),gz,0x80500000,0x6D8,y,$(2))
$(call Image/Build/TRXNoloader,$(IMGNAME)-$(3)-$(2).trx,$(1))
$(STAGING_DIR)/bin/mkcsysimg -B $(4) -d -w \ $(STAGING_DIR)/bin/mkcsysimg -B $(4) -d -w \
-r $(KDIR)/loader-admboot.gz \ -r $(KDIR)/loader-$(2).gz \
-x $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1)-noloader.trx \ -x $(IMGNAME)-$(3)-$(2).trx \
$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(3)-$(2).bin $(IMGNAME)-$(3)-$(2).bin
endef
define Image/Build/Infineon
$(call Image/Build/Loader,$(2),gz,0x80500000,0x6D8,y,$(2))
$(call Image/Build/TRXNoloader,$(IMGNAME)-$(3)-$(2).trx,$(1))
dd if=$(KDIR)/loader-$(2).gz of=$(IMGNAME)-$(3)-$(2).img bs=64k conv=sync
cat $(IMGNAME)-$(3)-$(2).trx >>$(IMGNAME)-$(3)-$(2).img
endef endef
define Image/Build/MyLoader define Image/Build/MyLoader
$(CP) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1)-noloader.trx $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(3)-$(2).trx $(call Image/Build/Loader,$(2),gz,0x80500000,0)
$(call Image/Build/TRXNoloader,$(IMGNAME)-$(3)-$(2).trx,$(1))
$(STAGING_DIR)/bin/mkmylofw -B $(4) \ $(STAGING_DIR)/bin/mkmylofw -B $(4) \
-p0x20000:0x10000:ahp:0x80001000 \ -p0x20000:0x10000:ahp:0x80001000 \
-p0x30000:0 \ -p0x30000:0 \
-b0x20000:0x10000:h:$(KDIR)/loader-generic.gz \ -b0x20000:0x10000:h:$(KDIR)/loader-$(2).gz \
-b0x30000:0::$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(3)-$(2).trx \ -b0x30000:0::$(IMGNAME)-$(3)-$(2).trx \
$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(3)-$(2).bin $(IMGNAME)-$(3)-$(2).bin
endef endef
define Image/Build/RouterBoard define Image/Build/RouterBoard
$(CP) $(KDIR)/vmlinux.elf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux $(CP) $(KDIR)/vmlinux.elf $(IMGNAME)-vmlinux
endef endef
define Image/Build define Image/Build
$(STAGING_DIR)/bin/trx -o $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).trx -f $(KDIR)/loader-generic.gz -f $(KDIR)/vmlinux.lzma $(call trxalign/$(1)) -f $(KDIR)/root.$(1) # this line is here intentionally
$(STAGING_DIR)/bin/trx -o $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1)-noloader.trx -f $(KDIR)/vmlinux.lzma $(call trxalign/$(1)) -f $(KDIR)/root.$(1) ifneq ($(1),jffs2-256k)
ifneq ($(1),jffs2-128K) ifneq ($(1),jffs2-128k)
$(call Image/Build/Compex,$(1),wp54g-wrt,$(patsubst jffs2-%,jffs2,$(1))) $(call Image/Build/Compex,$(1),wp54g-wrt,$(patsubst jffs2-%,jffs2,$(1)),WP54G-WRT)
$(call Image/Build/Edimax,$(1),br-6104k,$(patsubst jffs2-%,jffs2,$(1)),BR-6104K) $(call Image/Build/Edimax,$(1),br-6104k,$(patsubst jffs2-%,jffs2,$(1)),BR-6104K)
$(call Image/Build/Edimax,$(1),br-6104kp,$(patsubst jffs2-%,jffs2,$(1)),BR-6104KP) $(call Image/Build/Edimax,$(1),br-6104kp,$(patsubst jffs2-%,jffs2,$(1)),BR-6104KP)
$(call Image/Build/Edimax,$(1),br-6114wg,$(patsubst jffs2-%,jffs2,$(1)),BR-6114WG) $(call Image/Build/Edimax,$(1),br-6114wg,$(patsubst jffs2-%,jffs2,$(1)),BR-6114WG)
@ -89,6 +99,10 @@ ifneq ($(1),jffs2-128K)
$(call Image/Build/Edimax,$(1),ps-3205uwg,$(patsubst jffs2-%,jffs2,$(1)),PS-3205UWg) $(call Image/Build/Edimax,$(1),ps-3205uwg,$(patsubst jffs2-%,jffs2,$(1)),PS-3205UWg)
$(call Image/Build/Edimax,$(1),br-6524wg,$(patsubst jffs2-%,jffs2,$(1)),BR-6524WG) $(call Image/Build/Edimax,$(1),br-6524wg,$(patsubst jffs2-%,jffs2,$(1)),BR-6524WG)
$(call Image/Build/Edimax,$(1),br-6524wp,$(patsubst jffs2-%,jffs2,$(1)),BR-6524WP) $(call Image/Build/Edimax,$(1),br-6524wp,$(patsubst jffs2-%,jffs2,$(1)),BR-6524WP)
$(call Image/Build/Infineon,$(1),easy-5120,$(patsubst jffs2-%,jffs2,$(1)))
$(call Image/Build/Infineon,$(1),easy-5120-rt,$(patsubst jffs2-%,jffs2,$(1)))
$(call Image/Build/Infineon,$(1),easy-5120p-ata,$(patsubst jffs2-%,jffs2,$(1)))
$(call Image/Build/Infineon,$(1),easy-83000,$(patsubst jffs2-%,jffs2,$(1)))
$(call Image/Build/MyLoader,$(1),np27g,$(patsubst jffs2-%,jffs2,$(1)),NP27G) $(call Image/Build/MyLoader,$(1),np27g,$(patsubst jffs2-%,jffs2,$(1)),NP27G)
$(call Image/Build/MyLoader,$(1),np28g,$(patsubst jffs2-%,jffs2,$(1)),NP28G) $(call Image/Build/MyLoader,$(1),np28g,$(patsubst jffs2-%,jffs2,$(1)),NP28G)
$(call Image/Build/MyLoader,$(1),np28ghs,$(patsubst jffs2-%,jffs2,$(1)),NP28GHS) $(call Image/Build/MyLoader,$(1),np28ghs,$(patsubst jffs2-%,jffs2,$(1)),NP28GHS)
@ -97,24 +111,48 @@ ifneq ($(1),jffs2-128K)
$(call Image/Build/MyLoader,$(1),wpp54g,$(patsubst jffs2-%,jffs2,$(1)),WPP54G) $(call Image/Build/MyLoader,$(1),wpp54g,$(patsubst jffs2-%,jffs2,$(1)),WPP54G)
$(call Image/Build/MyLoader,$(1),wpp54ag,$(patsubst jffs2-%,jffs2,$(1)),WPP54AG) $(call Image/Build/MyLoader,$(1),wpp54ag,$(patsubst jffs2-%,jffs2,$(1)),WPP54AG)
endif endif
endif
ifeq ($(1),tgz) ifeq ($(1),tgz)
$(call Image/Build/RouterBoard) $(call Image/Build/RouterBoard)
endif endif
endef endef
define Image/Build/LZMAKernel define Image/Build/LZMAKernel
$(CP) $(KDIR)/loader-vmlinux-lzma-$(2).$(3) \ $(LOADER_MAKE) TARGET_DIR=$(BIN_DIR) \
$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux-lzma-$(1).$(3) LOADER=openwrt-$(BOARD)-$(KERNEL)-ramfs-lzma-$(1).$(2) \
LOADER_DATA=$(KDIR)/vmlinux.lzma \
LZMA_TEXT_START=$(3) LZMA_STARTUP_ORG=$(4) \
CONFIG_PASS_KARGS=$(5) CONFIG_BOARD=$(6) \
compile loader.$(2)
endef
define Image/Build/LZMAKernel/Compex
$(call Image/Build/LZMAKernel,$(1),$(2),0x80500000,0,y,$(1))
endef
define Image/Build/LZMAKernel/Generic
$(call Image/Build/LZMAKernel,$(1),$(2),0x80500000,0)
endef
define Image/Build/LZMAKernel/Admboot
$(call Image/Build/LZMAKernel,$(1),$(2),0x80500000,0x6D8,y,$(1))
endef endef
define Image/Build/Initramfs define Image/Build/Initramfs
$(call Image/Build/LZMAKernel,generic,generic,elf) $(call Image/Build/LZMAKernel/Generic,generic,bin)
$(call Image/Build/LZMAKernel,rb-100,generic,elf) $(call Image/Build/LZMAKernel/Generic,rb-100,elf)
$(call Image/Build/LZMAKernel,np27g,generic,bin) $(call Image/Build/LZMAKernel/Generic,np27g,bin)
$(call Image/Build/LZMAKernel,wp54g,generic,bin) $(call Image/Build/LZMAKernel/Generic,wp54g,bin)
$(call Image/Build/LZMAKernel,br-6104k,admboot,gz) $(call Image/Build/LZMAKernel/Compex,wp54g-wrt,bin)
$(call Image/Build/LZMAKernel,cas-771,admboot,gz) $(call Image/Build/LZMAKernel/Admboot,br-6104k,gz)
$(call Image/Build/LZMAKernel/Admboot,easy-5120,gz)
$(call Image/Build/LZMAKernel/Admboot,easy-83000,gz)
$(call Image/Build/LZMAKernel/Admboot,cas-630,gz)
$(call Image/Build/LZMAKernel/Admboot,cas-670,gz)
$(call Image/Build/LZMAKernel/Admboot,cas-700,gz)
$(call Image/Build/LZMAKernel/Admboot,cas-771,gz)
$(call Image/Build/LZMAKernel/Admboot,cas-790,gz)
$(call Image/Build/LZMAKernel/Admboot,cas-861,gz)
endef endef
$(eval $(call BuildImage)) $(eval $(call BuildImage))

View file

@ -8,13 +8,18 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
LOADER := adm5120 LOADER := loader.bin
LOADER_NAME := loader-$(LOADER) LOADER_NAME := $(basename $(notdir $(LOADER)))
LOADER_DATA := LOADER_DATA :=
TARGET_DIR :=
LOADER_BIN := $(KDIR)/$(LOADER_NAME).bin ifeq ($(TARGET_DIR),)
LOADER_GZ := $(KDIR)/$(LOADER_NAME).gz TARGET_DIR := $(KDIR)
LOADER_ELF := $(KDIR)/$(LOADER_NAME).elf endif
LOADER_BIN := $(TARGET_DIR)/$(LOADER_NAME).bin
LOADER_GZ := $(TARGET_DIR)/$(LOADER_NAME).gz
LOADER_ELF := $(TARGET_DIR)/$(LOADER_NAME).elf
LZMA_STARTUP_ORG:= 0 LZMA_STARTUP_ORG:= 0
LZMA_TEXT_START := 0x80300000 LZMA_TEXT_START := 0x80300000
@ -22,7 +27,7 @@ LZMA_TEXT_START := 0x80300000
PKG_NAME := lzma-loader PKG_NAME := lzma-loader
PKG_BUILD_DIR := $(KDIR)/$(PKG_NAME) PKG_BUILD_DIR := $(KDIR)/$(PKG_NAME)
.PHONY : loader-compile .PHONY : loader-compile loader.bin loader.elf loader.gz
$(PKG_BUILD_DIR)/.prepared: $(PKG_BUILD_DIR)/.prepared:
mkdir $(PKG_BUILD_DIR) mkdir $(PKG_BUILD_DIR)
@ -34,23 +39,25 @@ loader-compile: $(PKG_BUILD_DIR)/.prepared
LZMA_STARTUP_ORG=$(LZMA_STARTUP_ORG) \ LZMA_STARTUP_ORG=$(LZMA_STARTUP_ORG) \
LZMA_TEXT_START=$(LZMA_TEXT_START) \ LZMA_TEXT_START=$(LZMA_TEXT_START) \
LOADER_DATA=$(LOADER_DATA) \ LOADER_DATA=$(LOADER_DATA) \
CONFIG_BOARD=$(CONFIG_BOARD) \
CONFIG_PASS_KARGS=$(CONFIG_PASS_KARGS) \
clean all clean all
$(LOADER_GZ): $(PKG_BUILD_DIR)/loader.bin loader.gz: $(PKG_BUILD_DIR)/loader.bin
gzip -nc9 $< > $@ gzip -nc9 $< > $(LOADER_GZ)
$(LOADER_ELF) : $(PKG_BUILD_DIR)/loader.elf loader.elf: $(PKG_BUILD_DIR)/loader.elf
$(CP) $< $@ $(CP) $< $(LOADER_ELF)
$(LOADER_BIN) : $(PKG_BUILD_DIR)/loader.bin loader.bin: $(PKG_BUILD_DIR)/loader.bin
$(CP) $< $@ $(CP) $< $(LOADER_BIN)
download: download:
prepare: $(PKG_BUILD_DIR)/.prepared prepare: $(PKG_BUILD_DIR)/.prepared
compile: loader-compile $(LOADER_BIN) $(LOADER_GZ) $(LOADER_ELF) compile: loader-compile
install: install:
clean: clean:
rm -rf $(PKG_BUILD_DIR) rm -rf $(PKG_BUILD_DIR)
rm -f $(KDIR)/loader-*.gz $(KDIR)/loader-*.elf $(KDIR)/loader-*.bin

View file

@ -25,6 +25,8 @@ LOADADDR := 0x80001000
LZMA_TEXT_START := 0x80500000 LZMA_TEXT_START := 0x80500000
LZMA_STARTUP_ORG:= 0 LZMA_STARTUP_ORG:= 0
LOADER_DATA := LOADER_DATA :=
CONFIG_PASS_KARGS :=
CONFIG_BOARD :=
CC := $(CROSS_COMPILE)gcc CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld LD := $(CROSS_COMPILE)ld
@ -55,6 +57,16 @@ else
CFLAGS += -D_LZMA_IN_CB CFLAGS += -D_LZMA_IN_CB
endif endif
ifneq ($(strip $(CONFIG_PASS_KARGS)),)
CFLAGS += -DCONFIG_PASS_KARGS
endif
BOARD_DEF := $(strip $(CONFIG_BOARD))
BOARD_DEF := $(shell echo $(BOARD_DEF) | tr a-z A-Z | tr -d -)
ifneq ($(BOARD_DEF),)
CFLAGS += -DCONFIG_BOARD_$(BOARD_DEF)
endif
all: loader.bin all: loader.bin
# Don't build dependencies, this may die if $(CC) isn't gcc # Don't build dependencies, this may die if $(CC) isn't gcc
@ -80,7 +92,7 @@ loader.elf: $(OBJECTS)
mrproper: clean mrproper: clean
clean: clean:
rm -f *.gz *.elf *.bin *.o rm -f *.elf *.bin *.o

View file

@ -0,0 +1,83 @@
/*
* Cellvision/SparkLAN boards
*/
#if defined(CONFIG_BOARD_CAS630)
# define CONFIG_BOARD_NAME "CAS-630"
#endif
#if defined(CONFIG_BOARD_CAS670)
# define CONFIG_BOARD_NAME "CAS-670"
#endif
#if defined(CONFIG_BOARD_CAS700)
# define CONFIG_BOARD_NAME "CAS-700"
#endif
#if defined(CONFIG_BOARD_CAS790)
# define CONFIG_BOARD_NAME "CAS-790"
#endif
#if defined(CONFIG_BOARD_CAS771)
# define CONFIG_BOARD_NAME "CAS-771"
#endif
#if defined(CONFIG_BOARD_CAS861)
# define CONFIG_BOARD_NAME "CAS-861"
#endif
#if defined(CONFIG_BOARD_NFS101U)
# define CONFIG_BOARD_NAME "NFS-101U"
#endif
#if defined(CONFIG_BOARD_NFS202U)
# define CONFIG_BOARD_NAME "NFS-202U"
#endif
/*
* Edimax boards
*/
#if defined(CONFIG_BOARD_BR6104K)
# define CONFIG_BOARD_NAME "BR-6104K"
#endif
#if defined(CONFIG_BOARD_BR6104KP)
# define CONFIG_BOARD_NAME "BR-6104KP"
#endif
/*
* Infineon boards
*/
#if defined(CONFIG_BOARD_EASY5120)
# define CONFIG_BOARD_NAME "EASY 5120"
#endif
#if defined(CONFIG_BOARD_EASY5120RT)
# define CONFIG_BOARD_NAME "EASY 5120-RT"
#endif
#if defined(CONFIG_BOARD_EASY5120PATA)
# define CONFIG_BOARD_NAME "EASY 5120P-ATA"
#endif
#if defined(CONFIG_BOARD_EASY83000)
# define CONFIG_BOARD_NAME "EASY 83000"
#endif
/*
* ZyXEL boards
*/
#if defined(CONFIG_BOARD_P334WT)
# define CONFIG_BOARD_NAME "P-334WT"
#endif
#if defined(CONFIG_BOARD_P335)
# define CONFIG_BOARD_NAME "P-335"
#endif
/*
* Default values
*/
#ifndef CONFIG_BOARD_NAME
# define CONFIG_BOARD_NAME "ADM5120"
#endif

View file

@ -36,12 +36,13 @@
* *
* 19-May-2007 Gabor Juhos * 19-May-2007 Gabor Juhos
* endiannes related cleanups * endiannes related cleanups
* add support for decompressing an embedded kernel * add support for decompressing an embedded kernel
* *
*/ */
#include <stddef.h> #include <stddef.h>
#include "config.h"
#include "LzmaDecode.h" #include "LzmaDecode.h"
#define ADM5120_FLASH_START 0x1fc00000 /* Flash start */ #define ADM5120_FLASH_START 0x1fc00000 /* Flash start */
@ -109,6 +110,19 @@ extern unsigned char _lzma_data_end[];
extern void board_init(void); extern void board_init(void);
extern void board_putc(int ch); extern void board_putc(int ch);
struct env_var {
char *name;
char *value;
};
#ifdef CONFIG_PASS_KARGS
#define ENVV(n,v) {.name = (n), .value = (v)}
struct env_var env_vars[] = {
ENVV("board_name", CONFIG_BOARD_NAME),
ENVV(NULL, NULL)
};
#endif
unsigned char *data; unsigned char *data;
unsigned long datalen; unsigned long datalen;
@ -167,6 +181,7 @@ static void print_hex(int val)
} }
} }
#if !(LZMA_WRAPPER)
static unsigned char *find_kernel(void) static unsigned char *find_kernel(void)
{ {
struct trx_header *hdr; struct trx_header *hdr;
@ -178,7 +193,7 @@ static unsigned char *find_kernel(void)
for (ret = ((unsigned char *) KSEG1ADDR(ADM5120_FLASH_START)); for (ret = ((unsigned char *) KSEG1ADDR(ADM5120_FLASH_START));
ret < ((unsigned char *)KSEG1ADDR(ADM5120_FLASH_END)); ret < ((unsigned char *)KSEG1ADDR(ADM5120_FLASH_END));
ret += TRX_ALIGN) { ret += TRX_ALIGN) {
if (read_le32(ret) == TRX_MAGIC) { if (read_le32(ret) == TRX_MAGIC) {
hdr = (struct trx_header *)ret; hdr = (struct trx_header *)ret;
break; break;
@ -187,13 +202,13 @@ static unsigned char *find_kernel(void)
if (hdr == NULL) { if (hdr == NULL) {
print_str("not found!\n"); print_str("not found!\n");
return NULL; return NULL;
} }
print_str("found at "); print_str("found at ");
print_hex((unsigned int)ret); print_hex((unsigned int)ret);
print_str(", kernel in partition "); print_str(", kernel in partition ");
/* compressed kernel is in the partition 0 or 1 */ /* compressed kernel is in the partition 0 or 1 */
if ((read_le32(&hdr->offsets[1]) == 0) || if ((read_le32(&hdr->offsets[1]) == 0) ||
(read_le32(&hdr->offsets[1]) > 65536)) { (read_le32(&hdr->offsets[1]) > 65536)) {
@ -203,9 +218,10 @@ static unsigned char *find_kernel(void)
ret += read_le32(&hdr->offsets[1]); ret += read_le32(&hdr->offsets[1]);
print_str("1\n"); print_str("1\n");
} }
return ret; return ret;
} }
#endif /* !(LZMA_WRAPPER) */
static void halt(void) static void halt(void)
{ {
@ -231,7 +247,8 @@ void decompress_entry(unsigned long reg_a0, unsigned long reg_a1,
board_init(); board_init();
print_str("\n\nLZMA loader for ADM5120, Copyright (C) 2007 OpenWrt.org\n\n"); print_str("\n\nLZMA loader for " CONFIG_BOARD_NAME
", Copyright (C) 2007 OpenWrt.org\n\n");
#if LZMA_WRAPPER #if LZMA_WRAPPER
data = _lzma_data_start; data = _lzma_data_start;
@ -301,8 +318,12 @@ void decompress_entry(unsigned long reg_a0, unsigned long reg_a1,
print_str("launching kernel...\n\n"); print_str("launching kernel...\n\n");
#ifdef CONFIG_PASS_KARGS
reg_a0 = 0;
reg_a1 = 0;
reg_a2 = (unsigned long)env_vars;
reg_a3 = 0;
#endif
/* Jump to load address */ /* Jump to load address */
((kernel_entry) LOADADDR)(reg_a0, reg_a1, reg_a2, reg_a3); ((kernel_entry) LOADADDR)(reg_a0, reg_a1, reg_a2, reg_a3);
} }

View file

@ -7,18 +7,14 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/image.mk include $(INCLUDE_DIR)/image.mk
IMGNAME = $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)
LOADER_MAKE = $(MAKE) -C lzma-loader KDIR=$(KDIR) LOADER_MAKE = $(MAKE) -C lzma-loader KDIR=$(KDIR)
define CompileLoader define Image/Build/Loader
$(LOADER_MAKE) LOADER=$(1) LOADER_DATA="" \ $(LOADER_MAKE) LOADER=loader-$(1).$(2) LOADER_DATA="" \
LZMA_TEXT_START=$(2) LZMA_STARTUP_ORG=$(3) \ LZMA_TEXT_START=$(3) LZMA_STARTUP_ORG=$(4) \
compile CONFIG_PASS_KARGS=$(5) CONFIG_BOARD=$(6) \
endef compile loader.$(2)
define CompileLZMAKernel
$(LOADER_MAKE) LOADER=vmlinux-lzma-$(1) LOADER_DATA=$(KDIR)/vmlinux.lzma \
LZMA_TEXT_START=$(2) LZMA_STARTUP_ORG=$(3) \
compile
endef endef
define Build/Clean define Build/Clean
@ -27,11 +23,6 @@ endef
define Image/Prepare define Image/Prepare
cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
$(call CompileLoader,zyxel,0x80500000,0)
else
$(call CompileLZMAKernel,zyxel,0x80500000,0)
endif
endef endef
define trxalign/jffs2-128k define trxalign/jffs2-128k
@ -44,25 +35,42 @@ define trxalign/squashfs
-a 1024 -a 1024
endef endef
define Image/Build/TRX
$(STAGING_DIR)/bin/trx -o $(1) -f $(3) -f $(KDIR)/vmlinux.lzma \
$(call trxalign/$(2)) -f $(KDIR)/root.$(2)
endef
define Image/Build/TRXNoloader
$(STAGING_DIR)/bin/trx -o $(1) -f $(KDIR)/vmlinux.lzma \
$(call trxalign/$(2)) -f $(KDIR)/root.$(2)
endef
define Image/Build/ZyXEL define Image/Build/ZyXEL
$(CP) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1)-noloader.trx $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(3)-$(2).trx $(call Image/Build/Loader,loader-$(2),gz,0x80500000,0)
$(call Image/Build/TRXNoloader,$(IMGNAME)-$(3)-$(2).trx,$(1))
#TODO: firmware generation tool needed
endef endef
define Image/Build define Image/Build
$(STAGING_DIR)/bin/trx -o $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1)-noloader.trx -f $(KDIR)/vmlinux.lzma $(call trxalign/$(1)) -f $(KDIR)/root.$(1) #FIXME: No firmware images yet
ifneq ($(1),jffs2-128K)
#FIXME: firware images yet
endif
endef endef
define Image/Build/LZMAKernel define Image/Build/LZMAKernel
$(CP) $(KDIR)/loader-vmlinux-lzma-$(2).$(3) \ $(LOADER_MAKE) TARGET_DIR=$(BIN_DIR) \
$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux-lzma-$(1).$(3) LOADER=openwrt-$(BOARD)-$(KERNEL)-ramfs-lzma-$(1).$(2) \
LOADER_DATA=$(KDIR)/vmlinux.lzma \
LZMA_TEXT_START=$(3) LZMA_STARTUP_ORG=$(4) \
CONFIG_PASS_KARGS=$(5) CONFIG_BOARD=$(6) \
compile loader.$(2)
endef
define Image/Build/LZMAKernel/ZyXEL
$(call Image/Build/LZMAKernel,$(1),$(2),0x80500000,0,y,$(1))
endef endef
define Image/Build/Initramfs define Image/Build/Initramfs
$(call Image/Build/LZMAKernel,p-334wt,zyxel,bin) $(call Image/Build/LZMAKernel/Generic,p-334wt,bin)
$(call Image/Build/LZMAKernel,p-335wt,zyxel,bin) $(call Image/Build/LZMAKernel/Generic,p-335,bin)
endef endef
$(eval $(call BuildImage)) $(eval $(call BuildImage))