summaryrefslogtreecommitdiff
path: root/target/linux/adm5120-2.6/image/lzma-loader
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/adm5120-2.6/image/lzma-loader')
-rw-r--r--target/linux/adm5120-2.6/image/lzma-loader/Makefile35
-rw-r--r--target/linux/adm5120-2.6/image/lzma-loader/src/Makefile14
-rw-r--r--target/linux/adm5120-2.6/image/lzma-loader/src/config.h83
-rw-r--r--target/linux/adm5120-2.6/image/lzma-loader/src/decompress.c37
4 files changed, 146 insertions, 23 deletions
diff --git a/target/linux/adm5120-2.6/image/lzma-loader/Makefile b/target/linux/adm5120-2.6/image/lzma-loader/Makefile
index 0245e44ccd..74866e765e 100644
--- a/target/linux/adm5120-2.6/image/lzma-loader/Makefile
+++ b/target/linux/adm5120-2.6/image/lzma-loader/Makefile
@@ -8,13 +8,18 @@
include $(TOPDIR)/rules.mk
-LOADER := adm5120
-LOADER_NAME := loader-$(LOADER)
+LOADER := loader.bin
+LOADER_NAME := $(basename $(notdir $(LOADER)))
LOADER_DATA :=
+TARGET_DIR :=
-LOADER_BIN := $(KDIR)/$(LOADER_NAME).bin
-LOADER_GZ := $(KDIR)/$(LOADER_NAME).gz
-LOADER_ELF := $(KDIR)/$(LOADER_NAME).elf
+ifeq ($(TARGET_DIR),)
+TARGET_DIR := $(KDIR)
+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_TEXT_START := 0x80300000
@@ -22,7 +27,7 @@ LZMA_TEXT_START := 0x80300000
PKG_NAME := lzma-loader
PKG_BUILD_DIR := $(KDIR)/$(PKG_NAME)
-.PHONY : loader-compile
+.PHONY : loader-compile loader.bin loader.elf loader.gz
$(PKG_BUILD_DIR)/.prepared:
mkdir $(PKG_BUILD_DIR)
@@ -34,23 +39,25 @@ loader-compile: $(PKG_BUILD_DIR)/.prepared
LZMA_STARTUP_ORG=$(LZMA_STARTUP_ORG) \
LZMA_TEXT_START=$(LZMA_TEXT_START) \
LOADER_DATA=$(LOADER_DATA) \
+ CONFIG_BOARD=$(CONFIG_BOARD) \
+ CONFIG_PASS_KARGS=$(CONFIG_PASS_KARGS) \
clean all
-$(LOADER_GZ): $(PKG_BUILD_DIR)/loader.bin
- gzip -nc9 $< > $@
+loader.gz: $(PKG_BUILD_DIR)/loader.bin
+ gzip -nc9 $< > $(LOADER_GZ)
-$(LOADER_ELF) : $(PKG_BUILD_DIR)/loader.elf
- $(CP) $< $@
+loader.elf: $(PKG_BUILD_DIR)/loader.elf
+ $(CP) $< $(LOADER_ELF)
-$(LOADER_BIN) : $(PKG_BUILD_DIR)/loader.bin
- $(CP) $< $@
+loader.bin: $(PKG_BUILD_DIR)/loader.bin
+ $(CP) $< $(LOADER_BIN)
download:
prepare: $(PKG_BUILD_DIR)/.prepared
-compile: loader-compile $(LOADER_BIN) $(LOADER_GZ) $(LOADER_ELF)
+compile: loader-compile
install:
clean:
rm -rf $(PKG_BUILD_DIR)
- rm -f $(KDIR)/loader-*.gz $(KDIR)/loader-*.elf $(KDIR)/loader-*.bin
+
diff --git a/target/linux/adm5120-2.6/image/lzma-loader/src/Makefile b/target/linux/adm5120-2.6/image/lzma-loader/src/Makefile
index 0f4ffa63a9..a3749f2ee9 100644
--- a/target/linux/adm5120-2.6/image/lzma-loader/src/Makefile
+++ b/target/linux/adm5120-2.6/image/lzma-loader/src/Makefile
@@ -25,6 +25,8 @@ LOADADDR := 0x80001000
LZMA_TEXT_START := 0x80500000
LZMA_STARTUP_ORG:= 0
LOADER_DATA :=
+CONFIG_PASS_KARGS :=
+CONFIG_BOARD :=
CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld
@@ -55,6 +57,16 @@ else
CFLAGS += -D_LZMA_IN_CB
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
# Don't build dependencies, this may die if $(CC) isn't gcc
@@ -80,7 +92,7 @@ loader.elf: $(OBJECTS)
mrproper: clean
clean:
- rm -f *.gz *.elf *.bin *.o
+ rm -f *.elf *.bin *.o
diff --git a/target/linux/adm5120-2.6/image/lzma-loader/src/config.h b/target/linux/adm5120-2.6/image/lzma-loader/src/config.h
new file mode 100644
index 0000000000..5002b18192
--- /dev/null
+++ b/target/linux/adm5120-2.6/image/lzma-loader/src/config.h
@@ -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
diff --git a/target/linux/adm5120-2.6/image/lzma-loader/src/decompress.c b/target/linux/adm5120-2.6/image/lzma-loader/src/decompress.c
index ffc87ee0db..e2f9bee234 100644
--- a/target/linux/adm5120-2.6/image/lzma-loader/src/decompress.c
+++ b/target/linux/adm5120-2.6/image/lzma-loader/src/decompress.c
@@ -36,12 +36,13 @@
*
* 19-May-2007 Gabor Juhos
* endiannes related cleanups
- * add support for decompressing an embedded kernel
+ * add support for decompressing an embedded kernel
*
*/
#include <stddef.h>
+#include "config.h"
#include "LzmaDecode.h"
#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_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 long datalen;
@@ -167,6 +181,7 @@ static void print_hex(int val)
}
}
+#if !(LZMA_WRAPPER)
static unsigned char *find_kernel(void)
{
struct trx_header *hdr;
@@ -178,7 +193,7 @@ static unsigned char *find_kernel(void)
for (ret = ((unsigned char *) KSEG1ADDR(ADM5120_FLASH_START));
ret < ((unsigned char *)KSEG1ADDR(ADM5120_FLASH_END));
ret += TRX_ALIGN) {
-
+
if (read_le32(ret) == TRX_MAGIC) {
hdr = (struct trx_header *)ret;
break;
@@ -187,13 +202,13 @@ static unsigned char *find_kernel(void)
if (hdr == NULL) {
print_str("not found!\n");
- return NULL;
+ return NULL;
}
print_str("found at ");
print_hex((unsigned int)ret);
print_str(", kernel in partition ");
-
+
/* compressed kernel is in the partition 0 or 1 */
if ((read_le32(&hdr->offsets[1]) == 0) ||
(read_le32(&hdr->offsets[1]) > 65536)) {
@@ -203,9 +218,10 @@ static unsigned char *find_kernel(void)
ret += read_le32(&hdr->offsets[1]);
print_str("1\n");
}
-
+
return ret;
}
+#endif /* !(LZMA_WRAPPER) */
static void halt(void)
{
@@ -231,7 +247,8 @@ void decompress_entry(unsigned long reg_a0, unsigned long reg_a1,
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
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");
+#ifdef CONFIG_PASS_KARGS
+ reg_a0 = 0;
+ reg_a1 = 0;
+ reg_a2 = (unsigned long)env_vars;
+ reg_a3 = 0;
+#endif
/* Jump to load address */
((kernel_entry) LOADADDR)(reg_a0, reg_a1, reg_a2, reg_a3);
}
-
-