mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 23:24:38 +00:00
relocation: fixup cmdtable
fixup_cmdtable() did all work for fixing up the cmdtable, if CONFIG_RELOC_FIXUP_WORKS is not defined. CONFIG_RELOC_FIXUP_WORKS is missing for i386! I talked with Graeme Russ, and he will fix this soon. Portions of this work were supported by funding from the CE Linux Forum. Signed-off-by: Heiko Schocher <hs@denx.de>
This commit is contained in:
parent
7e4a9e6dc8
commit
620f1f6a64
6 changed files with 56 additions and 92 deletions
|
@ -273,30 +273,13 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
|
||||||
|
|
||||||
monitor_flash_len = _edata - _text;
|
monitor_flash_len = _edata - _text;
|
||||||
|
|
||||||
|
#if !defined(CONFIG_RELOC_FIXUP_WORKS)
|
||||||
/*
|
/*
|
||||||
* We have to relocate the command table manually
|
* We have to relocate the command table manually
|
||||||
*/
|
*/
|
||||||
for (cmdtp = &__u_boot_cmd_start;
|
fixup_cmdtable(&__u_boot_cmd_start,
|
||||||
cmdtp != &__u_boot_cmd_end; cmdtp++) {
|
(ulong)(&__u_boot_cmd_end - &__u_boot_cmd_start));
|
||||||
unsigned long addr;
|
#endif /* !defined(CONFIG_RELOC_FIXUP_WORKS) */
|
||||||
|
|
||||||
addr = (unsigned long)cmdtp->cmd + gd->reloc_off;
|
|
||||||
cmdtp->cmd = (typeof(cmdtp->cmd))addr;
|
|
||||||
|
|
||||||
addr = (unsigned long)cmdtp->name + gd->reloc_off;
|
|
||||||
cmdtp->name = (typeof(cmdtp->name))addr;
|
|
||||||
|
|
||||||
if (cmdtp->usage) {
|
|
||||||
addr = (unsigned long)cmdtp->usage + gd->reloc_off;
|
|
||||||
cmdtp->usage = (typeof(cmdtp->usage))addr;
|
|
||||||
}
|
|
||||||
#ifdef CONFIG_SYS_LONGHELP
|
|
||||||
if (cmdtp->help) {
|
|
||||||
addr = (unsigned long)cmdtp->help + gd->reloc_off;
|
|
||||||
cmdtp->help = (typeof(cmdtp->help))addr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/* there are some other pointer constants we must deal with */
|
/* there are some other pointer constants we must deal with */
|
||||||
#ifndef CONFIG_ENV_IS_NOWHERE
|
#ifndef CONFIG_ENV_IS_NOWHERE
|
||||||
|
|
|
@ -433,33 +433,14 @@ void board_init_r (gd_t *id, ulong dest_addr)
|
||||||
|
|
||||||
monitor_flash_len = (ulong)&__init_end - dest_addr;
|
monitor_flash_len = (ulong)&__init_end - dest_addr;
|
||||||
|
|
||||||
|
#if !defined(CONFIG_RELOC_FIXUP_WORKS)
|
||||||
/*
|
/*
|
||||||
* We have to relocate the command table manually
|
* We have to relocate the command table manually
|
||||||
*/
|
*/
|
||||||
for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) {
|
fixup_cmdtable(&__u_boot_cmd_start,
|
||||||
ulong addr;
|
(ulong)(&__u_boot_cmd_end - &__u_boot_cmd_start));
|
||||||
addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
|
#endif /* !defined(CONFIG_RELOC_FIXUP_WORKS) */
|
||||||
#if 0
|
|
||||||
printf ("Command \"%s\": 0x%08lx => 0x%08lx\n",
|
|
||||||
cmdtp->name, (ulong) (cmdtp->cmd), addr);
|
|
||||||
#endif
|
|
||||||
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 CONFIG_SYS_LONGHELP
|
|
||||||
if (cmdtp->help) {
|
|
||||||
addr = (ulong)(cmdtp->help) + gd->reloc_off;
|
|
||||||
cmdtp->help = (char *)addr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
/* there are some other pointer constants we must deal with */
|
/* there are some other pointer constants we must deal with */
|
||||||
#ifndef CONFIG_ENV_IS_NOWHERE
|
#ifndef CONFIG_ENV_IS_NOWHERE
|
||||||
env_name_spec += gd->reloc_off;
|
env_name_spec += gd->reloc_off;
|
||||||
|
|
|
@ -304,34 +304,14 @@ void board_init_r (gd_t *id, ulong dest_addr)
|
||||||
|
|
||||||
monitor_flash_len = (ulong)&uboot_end_data - dest_addr;
|
monitor_flash_len = (ulong)&uboot_end_data - dest_addr;
|
||||||
|
|
||||||
|
#if !defined(CONFIG_RELOC_FIXUP_WORKS)
|
||||||
/*
|
/*
|
||||||
* We have to relocate the command table manually
|
* We have to relocate the command table manually
|
||||||
*/
|
*/
|
||||||
for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) {
|
fixup_cmdtable(&__u_boot_cmd_start,
|
||||||
ulong addr;
|
(ulong)(&__u_boot_cmd_end - &__u_boot_cmd_start));
|
||||||
|
#endif /* !defined(CONFIG_RELOC_FIXUP_WORKS) */
|
||||||
|
|
||||||
addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
|
|
||||||
#if 0
|
|
||||||
printf ("Command \"%s\": 0x%08lx => 0x%08lx\n",
|
|
||||||
cmdtp->name, (ulong) (cmdtp->cmd), addr);
|
|
||||||
#endif
|
|
||||||
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 CONFIG_SYS_LONGHELP
|
|
||||||
if (cmdtp->help) {
|
|
||||||
addr = (ulong)(cmdtp->help) + gd->reloc_off;
|
|
||||||
cmdtp->help = (char *)addr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
/* there are some other pointer constants we must deal with */
|
/* there are some other pointer constants we must deal with */
|
||||||
#ifndef CONFIG_ENV_IS_NOWHERE
|
#ifndef CONFIG_ENV_IS_NOWHERE
|
||||||
env_name_spec += gd->reloc_off;
|
env_name_spec += gd->reloc_off;
|
||||||
|
|
|
@ -252,33 +252,13 @@ void board_init_f(ulong bootflag)
|
||||||
post_run(NULL, POST_ROM | post_bootmode_get(0));
|
post_run(NULL, POST_ROM | post_bootmode_get(0));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(CONFIG_RELOC_FIXUP_WORKS)
|
||||||
/*
|
/*
|
||||||
* We have to relocate the command table manually
|
* We have to relocate the command table manually
|
||||||
*/
|
*/
|
||||||
for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) {
|
fixup_cmdtable(&__u_boot_cmd_start,
|
||||||
ulong addr;
|
(ulong)(&__u_boot_cmd_end - &__u_boot_cmd_start));
|
||||||
addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
|
#endif /* !defined(CONFIG_RELOC_FIXUP_WORKS) */
|
||||||
#if DEBUG_COMMANDS
|
|
||||||
printf("Command \"%s\": 0x%08lx => 0x%08lx\n",
|
|
||||||
cmdtp->name, (ulong) (cmdtp->cmd), addr);
|
|
||||||
#endif
|
|
||||||
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 CONFIG_SYS_LONGHELP
|
|
||||||
if (cmdtp->help) {
|
|
||||||
addr = (ulong) (cmdtp->help) + gd->reloc_off;
|
|
||||||
cmdtp->help = (char *)addr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_CMD_AMBAPP) && defined(CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP)
|
#if defined(CONFIG_CMD_AMBAPP) && defined(CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP)
|
||||||
puts("AMBA:\n");
|
puts("AMBA:\n");
|
||||||
|
|
|
@ -465,3 +465,40 @@ int cmd_get_data_size(char* arg, int default_size)
|
||||||
return default_size;
|
return default_size;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(CONFIG_RELOC_FIXUP_WORKS)
|
||||||
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
|
void fixup_cmdtable(cmd_tbl_t *cmdtp, int size)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (gd->reloc_off == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++) {
|
||||||
|
ulong addr;
|
||||||
|
|
||||||
|
addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
|
||||||
|
#if DEBUG_COMMANDS
|
||||||
|
printf("Command \"%s\": 0x%08lx => 0x%08lx\n",
|
||||||
|
cmdtp->name, (ulong) (cmdtp->cmd), addr);
|
||||||
|
#endif
|
||||||
|
cmdtp->cmd =
|
||||||
|
(int (*)(struct cmd_tbl_s *, int, int, char * const []))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 CONFIG_SYS_LONGHELP
|
||||||
|
if (cmdtp->help) {
|
||||||
|
addr = (ulong)(cmdtp->help) + gd->reloc_off;
|
||||||
|
cmdtp->help = (char *)addr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
cmdtp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -125,4 +125,7 @@ cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage}
|
||||||
|
|
||||||
#endif /* CONFIG_SYS_LONGHELP */
|
#endif /* CONFIG_SYS_LONGHELP */
|
||||||
|
|
||||||
|
#if !defined(CONFIG_RELOC_FIXUP_WORKS)
|
||||||
|
void fixup_cmdtable(cmd_tbl_t *cmdtp, int size);
|
||||||
|
#endif
|
||||||
#endif /* __COMMAND_H */
|
#endif /* __COMMAND_H */
|
||||||
|
|
Loading…
Reference in a new issue