[U-Boot] [RFC][PATCH 3/3] New i386 board (includes code relocation)
Graeme Russ
graeme.russ at gmail.com
Mon Sep 29 15:06:38 CEST 2008
Added relocation code
Removed temporary testing code
Signed-off-by: Graeme Russ <graeme.russ at gmail.com>
--
diff --git a/board/eNET/eNET.c b/board/eNET/eNET.c
index 1b4af58..5355fb6 100644
--- a/board/eNET/eNET.c
+++ b/board/eNET/eNET.c
@@ -45,40 +45,6 @@ DECLARE_GLOBAL_DATA_PTR;
#define PRINTF(fmt,args...)
#endif
-
-extern int do_autoscript (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_bdinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_iminfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-/* extern int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); */
-extern int do_coninfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_itest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_load_serial_bin (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_mem_md (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_mem_mm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_mem_nm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_mem_mw (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_mem_cp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_mem_base (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_printenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_setenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_saveenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_run (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_imgextract (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_version (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_echo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-extern int do_help (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-
-
void hw_watchdog_reset(void)
{
u16 wd_state;
@@ -95,8 +61,6 @@ void hw_watchdog_reset(void)
}
}
-/* ------------------------------------------------------------------------- */
-
void init_sc520_enet (void)
{
@@ -595,44 +559,6 @@ int last_stage_init(void)
major = minor = 0;
printf("Serck Controls eNET\n");
- printf("last_stage_init() at %08lx\n", (ulong)last_stage_init);
-
- printf("autoscript => do_autoscript() @ 0x%08lx\n", (ulong)do_autoscript);
- printf("bdinfo => do_bdinfo() @ 0x%08lx\n", (ulong)do_bdinfo);
- printf("go => do_go() @ 0x%08lx\n", (ulong)do_go);
- printf("reset => do_reset() @ 0x%08lx\n", (ulong)do_reset);
- printf("bootm => do_bootm() @ 0x%08lx\n", (ulong)do_bootm);
- printf("boot => do_bootd() @ 0x%08lx\n", (ulong)do_bootd);
- printf("bootd => do_bootd() @ 0x%08lx\n", (ulong)do_bootd);
- printf("iminfo => do_iminfo() @ 0x%08lx\n", (ulong)do_iminfo);
-/* printf("imls => do_imls() @ 0x%08lx\n", (ulong)do_imls); */
- printf("imls => do_imls() @ <undefined>\n");
- printf("coninfo => do_coninfo() @ 0x%08lx\n", (ulong)do_coninfo);
- printf("itest => do_itest() @ 0x%08lx\n", (ulong)do_itest);
- printf("loads => do_load_serial() @ 0x%08lx\n", (ulong)do_load_serial);
- printf("loadb => do_load_serial_bin() @ 0x%08lx\n", (ulong)do_load_serial_bin);
- printf("loady => do_load_serial_bin() @ 0x%08lx\n", (ulong)do_load_serial_bin);
- printf("md => do_mem_md() @ 0x%08lx\n", (ulong)do_mem_md);
- printf("mm => do_mem_mm() @ 0x%08lx\n", (ulong)do_mem_mm);
- printf("nm => do_mem_nm() @ 0x%08lx\n", (ulong)do_mem_nm);
- printf("mw => do_mem_mw() @ 0x%08lx\n", (ulong)do_mem_mw);
- printf("cp => do_mem_cp() @ 0x%08lx\n", (ulong)do_mem_cp);
- printf("cmp => do_mem_cmp() @ 0x%08lx\n", (ulong)do_mem_cmp);
- printf("crc32 => do_mem_crc() @ 0x%08lx\n", (ulong)do_mem_crc);
- printf("base => do_mem_base() @ 0x%08lx\n", (ulong)do_mem_base);
- printf("loop => do_mem_loop() @ 0x%08lx\n", (ulong)do_mem_loop);
- printf("mtest => do_mem_mtest() @ 0x%08lx\n", (ulong)do_mem_mtest);
- printf("sleep => do_sleep() @ 0x%08lx\n", (ulong)do_sleep);
- printf("printenv => do_printenv() @ 0x%08lx\n", (ulong)do_printenv);
- printf("setenv => do_setenv() @ 0x%08lx\n", (ulong)do_setenv);
- printf("saveenv => do_saveenv() @ 0x%08lx\n", (ulong)do_saveenv);
- printf("run => do_run() @ 0x%08lx\n", (ulong)do_run);
- printf("imxtract => do_imgextract() @ 0x%08lx\n", (ulong)do_imgextract);
- printf("version => do_version() @ 0x%08lx\n", (ulong)do_version);
- printf("echo => do_echo() @ 0x%08lx\n", (ulong)do_echo);
- printf("help => do_help() @ 0x%08lx\n", (ulong)do_help);
- printf("? => do_help() @ 0x%08lx\n", (ulong)do_help);
-
return 0;
}
diff --git a/cpu/i386/start.S b/cpu/i386/start.S
index 84888aa..6330dd8 100644
--- a/cpu/i386/start.S
+++ b/cpu/i386/start.S
@@ -174,8 +174,41 @@ bss_fail:
bss_ok:
- wbinvd
+ /* indicate progress */
+ movw $0x06, %ax
+ movl $.progress6, %ebp
+ jmp show_boot_progress_asm
+.progress6:
+ /* copy text section to ram, size must be 4-byte aligned */
+ movl $CFG_RELOC_ADDR, %edi /* destination address */
+ movl $TEXT_BASE, %esi /* source address */
+ movl $_i386boot_text_size, %ecx /* number of bytes to copy */
+ movl %ecx, %eax
+ andl $3, %eax
+ jz text_copy /* Already 4-byte aligned */
+ subl $4, %eax /* Add extra bytes to size */
+ addl %eax, %ecx
+text_copy:
+ shrl $2, %ecx /* copy 4 byte each time */
+ cld
+ cmpl $0, %ecx
+ je text_ok
+text_segment:
+ movsl
+ loop text_segment
+ jmp text_ok
+text_fail:
+ /* indicate (lack of) progress */
+ movw $0x86, %ax
+ movl $.progress5a, %ebp
+ jmp show_boot_progress_asm
+.progress5a:
+ jmp die
+
+text_ok:
+
+ wbinvd
/* indicate progress */
movw $0x05, %ax
@@ -183,7 +216,10 @@ bss_ok:
jmp show_boot_progress_asm
.progress4:
- call start_i386boot /* Enter, U-boot! */
+ /* Jump to the RAM copy of start_i386boot */
+ movl $start_i386boot, %ebp
+ addl $(CFG_RELOC_ADDR - TEXT_BASE), %ebp
+ call *%ebp /* Enter, U-boot! */
/* indicate (lack of) progress */
movw $0x85, %ax
diff --git a/examples/82559_eeprom.c b/examples/82559_eeprom.c
index 047d3aa..5e2eee9 100644
--- a/examples/82559_eeprom.c
+++ b/examples/82559_eeprom.c
@@ -19,7 +19,6 @@
*/
#define _PPC_STRING_H_ /* avoid unnecessary str/mem functions */
-/* #define _LINUX_STRING_H_ */ /* avoid unnecessary str/mem functions */
#include <common.h>
#include <exports.h>
diff --git a/lib_i386/board.c b/lib_i386/board.c
index f3da0a2..b7ab1a7 100644
--- a/lib_i386/board.c
+++ b/lib_i386/board.c
@@ -57,7 +57,7 @@ extern long _i386boot_bios_size;
* which is somewhat inconveient ... */
ulong i386boot_start = (ulong)&_i386boot_start; /* code start (in flash) defined in start.S */
ulong i386boot_end = (ulong)&_i386boot_end; /* code end (in flash) */
-ulong i386boot_romdata_start = (ulong)&_i386boot_romdata_start; /* datasegment in flash (also code+rodata end) */
+ulong i386boot_romdata_start = (ulong)&_i386boot_romdata_start; /* data segment in flash (also code+rodata end) */
ulong i386boot_romdata_dest = (ulong)&_i386boot_romdata_dest; /* data location segment in ram */
ulong i386boot_romdata_size = (ulong)&_i386boot_romdata_size; /* size of data segment */
ulong i386boot_bss_start = (ulong)&_i386boot_bss_start; /* bss start */
@@ -139,7 +139,6 @@ static int display_banner (void)
i386boot_bss_start+i386boot_bss_size,
i386boot_bss_start+i386boot_bss_size+CFG_STACK_SIZE-1);
-
return (0);
}
@@ -163,13 +162,13 @@ static int display_dram_config (void)
return (0);
}
-
+#if 0
static void display_flash_config (ulong size)
{
puts ("Flash: ");
print_size (size, "\n");
}
-
+#endif
/*
* Breath some life into the board...
@@ -217,9 +216,9 @@ gd_t *gd;
void start_i386boot (void)
{
+ cmd_tbl_t *cmdtp;
char *s;
int i;
- ulong size;
static gd_t gd_data;
static bd_t bd_data;
init_fnc_t **init_fnc_ptr;
@@ -246,18 +245,42 @@ void start_i386boot (void)
}
show_boot_progress(0x23);
+ gd->reloc_off = CFG_RELOC_ADDR - TEXT_BASE;
+
+ for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) {
+ ulong addr;
+ addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
+ cmdtp->cmd =
+ (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
+
+ addr = (ulong)(cmdtp->name) + gd->reloc_off;
+ cmdtp->name = (char *)addr;
+
+ if (cmdtp->usage) {
+ addr = (ulong)(cmdtp->usage) + gd->reloc_off;
+ cmdtp->usage = (char *)addr;
+ }
+#ifdef CFG_LONGHELP
+ if (cmdtp->help) {
+ addr = (ulong)(cmdtp->help) + gd->reloc_off;
+ cmdtp->help = (char *)addr;
+ }
+#endif
+ }
+
+#if 0
/* configure available FLASH banks */
size = flash_init();
display_flash_config(size);
show_boot_progress(0x24);
-
+#endif
show_boot_progress(0x25);
/* initialize environment */
env_relocate ();
show_boot_progress(0x26);
-
+#if 0
/* IP Address */
bd_data.bi_ip_addr = getenv_IPaddr ("ipaddr");
@@ -277,6 +300,7 @@ void start_i386boot (void)
s = (*e) ? e + 1 : e;
}
}
+#endif
#if defined(CONFIG_PCI)
/*
More information about the U-Boot
mailing list