From 521af04d853361b49344b61892eb0618f9f713c5 Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Mon, 21 Sep 2009 11:20:36 -0500 Subject: Conditionally perform common relocation fixups Add #ifdefs where necessary to not perform relocation fixups. This allows boards/architectures which support relocation to trim a decent chunk of code. Note that this patch doesn't add #ifdefs to architecture-specific code which does not support relocation. Signed-off-by: Peter Tyser --- common/cmd_bootm.c | 4 +++- common/cmd_date.c | 4 ++++ common/dlmalloc.c | 2 ++ common/env_common.c | 4 ++++ common/hush.c | 4 ++++ common/image.c | 6 +++++- common/serial.c | 2 ++ common/stdio.c | 5 +++-- 8 files changed, 27 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 365ceebdf..8f8359856 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -561,7 +561,6 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /*******************************************************************/ /* bootm - boot application image from image in memory */ /*******************************************************************/ -static int relocated = 0; int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { @@ -569,6 +568,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ulong load_end = 0; int ret; boot_os_fn *boot_fn; +#ifndef CONFIG_RELOC_FIXUP_WORKS + static int relocated = 0; /* relocate boot function table */ if (!relocated) { @@ -578,6 +579,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) boot_os[i] += gd->reloc_off; relocated = 1; } +#endif /* determine if we have a sub command */ if (argc > 1) { diff --git a/common/cmd_date.c b/common/cmd_date.c index b69e93508..9f50f8956 100644 --- a/common/cmd_date.c +++ b/common/cmd_date.c @@ -35,7 +35,11 @@ const char *weekdays[] = { "Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", }; +#ifdef CONFIG_RELOC_FIXUP_WORKS +#define RELOC(a) a +#else #define RELOC(a) ((typeof(a))((unsigned long)(a) + gd->reloc_off)) +#endif int mk_date (char *, struct rtc_time *); diff --git a/common/dlmalloc.c b/common/dlmalloc.c index 241db8cd3..ca088a17d 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -1494,6 +1494,7 @@ static mbinptr av_[NAV * 2 + 2] = { IAV(120), IAV(121), IAV(122), IAV(123), IAV(124), IAV(125), IAV(126), IAV(127) }; +#ifndef CONFIG_RELOC_FIXUP_WORKS void malloc_bin_reloc (void) { unsigned long *p = (unsigned long *)(&av_[2]); @@ -1502,6 +1503,7 @@ void malloc_bin_reloc (void) *p++ += gd->reloc_off; } } +#endif ulong mem_malloc_start = 0; ulong mem_malloc_end = 0; diff --git a/common/env_common.c b/common/env_common.c index be64d1307..439a4a905 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -224,8 +224,10 @@ void set_default_env(void) void env_relocate (void) { +#ifndef CONFIG_RELOC_FIXUP_WORKS DEBUGF ("%s[%d] offset = 0x%lx\n", __FUNCTION__,__LINE__, gd->reloc_off); +#endif #ifdef CONFIG_AMIGAONEG3SE enable_nvram(); @@ -236,7 +238,9 @@ void env_relocate (void) * The environment buffer is embedded with the text segment, * just relocate the environment pointer */ +#ifndef CONFIG_RELOC_FIXUP_WORKS env_ptr = (env_t *)((ulong)env_ptr + gd->reloc_off); +#endif DEBUGF ("%s[%d] embedded ENV at %p\n", __FUNCTION__,__LINE__,env_ptr); #else /* diff --git a/common/hush.c b/common/hush.c index 528dd254a..06c5ff8df 100644 --- a/common/hush.c +++ b/common/hush.c @@ -3270,6 +3270,7 @@ int parse_file_outer(void) } #ifdef __U_BOOT__ +#ifndef CONFIG_RELOC_FIXUP_WORKS static void u_boot_hush_reloc(void) { unsigned long addr; @@ -3280,6 +3281,7 @@ static void u_boot_hush_reloc(void) r->literal = (char *)addr; } } +#endif int u_boot_hush_start(void) { @@ -3290,7 +3292,9 @@ int u_boot_hush_start(void) top_vars->next = 0; top_vars->flg_export = 0; top_vars->flg_read_only = 1; +#ifndef CONFIG_RELOC_FIXUP_WORKS u_boot_hush_reloc(); +#endif } return 0; } diff --git a/common/image.c b/common/image.c index d0f169d66..6eaf41eb1 100644 --- a/common/image.c +++ b/common/image.c @@ -513,7 +513,7 @@ char *get_table_entry_name (table_entry_t *table, char *msg, int id) { for (; table->id >= 0; ++table) { if (table->id == id) -#ifdef USE_HOSTCC +#if defined(USE_HOSTCC) || defined(CONFIG_RELOC_FIXUP_WORKS) return table->lname; #else return table->lname + gd->reloc_off; @@ -578,7 +578,11 @@ int get_table_entry_id (table_entry_t *table, fprintf (stderr, "\n"); #else for (t = table; t->id >= 0; ++t) { +#ifdef CONFIG_RELOC_FIXUP_WORKS + if (t->sname && strcmp(t->sname, name) == 0) +#else if (t->sname && strcmp(t->sname + gd->reloc_off, name) == 0) +#endif return (t->id); } debug ("Invalid %s Type: %s\n", table_name, name); diff --git a/common/serial.c b/common/serial.c index 41a24c2fa..b4db46b16 100644 --- a/common/serial.c +++ b/common/serial.c @@ -81,12 +81,14 @@ struct serial_device *default_serial_console(void) __attribute__((weak, alias("_ int serial_register (struct serial_device *dev) { +#ifndef CONFIG_RELOC_FIXUP_WORKS dev->init += gd->reloc_off; dev->setbrg += gd->reloc_off; dev->getc += gd->reloc_off; dev->tstc += gd->reloc_off; dev->putc += gd->reloc_off; dev->puts += gd->reloc_off; +#endif dev->next = serial_devices; serial_devices = dev; diff --git a/common/stdio.c b/common/stdio.c index 697df5a49..5e58dbe44 100644 --- a/common/stdio.c +++ b/common/stdio.c @@ -201,7 +201,8 @@ int stdio_deregister(char *devname) int stdio_init (void) { -#ifndef CONFIG_ARM /* already relocated for current ARM implementation */ +#if !defined(CONFIG_ARM) && !defined(CONFIG_RELOC_FIXUP_WORKS) + /* already relocated for current ARM implementation */ ulong relocation_offset = gd->reloc_off; int i; @@ -210,7 +211,7 @@ int stdio_init (void) stdio_names[i] = (char *) (((ulong) stdio_names[i]) + relocation_offset); } -#endif +#endif /* !ARM && !CONFIG_RELOC_FIXUP_WORKS */ /* Initialize the list */ INIT_LIST_HEAD(&(devs.list)); -- cgit v1.2.3 From 0630535e2d062dd73c1ceca5c6125c86d1127a49 Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Tue, 22 Sep 2009 09:27:55 -0500 Subject: arm/microblaze/nios/nios2/sh: Remove relocation fixups These architectures don't need relocation fixups, so reduce their codesize a bit by defining CONFIG_RELOC_FIXUP_WORKS. Also remove the reloc_off field from their global data structures as it is no longer needed. Note that the location of the standalone application jump table pointer in the global data structure is affected by this change, breaking execution of standalone applications compiled for previous versions of U-Boot. We will therefore increment XF_VERSION in the next commit, which also touches this area. Signed-off-by: Peter Tyser Signed-off-by: Wolfgang Denk --- common/stdio.c | 4 ++-- include/asm-arm/config.h | 3 +++ include/asm-arm/global_data.h | 1 - include/asm-microblaze/config.h | 3 +++ include/asm-microblaze/global_data.h | 1 - include/asm-nios/config.h | 3 +++ include/asm-nios/global_data.h | 1 - include/asm-nios2/config.h | 3 +++ include/asm-nios2/global_data.h | 1 - include/asm-sh/config.h | 3 +++ include/asm-sh/global_data.h | 1 - 11 files changed, 17 insertions(+), 7 deletions(-) (limited to 'common') diff --git a/common/stdio.c b/common/stdio.c index 5e58dbe44..870ddfd5e 100644 --- a/common/stdio.c +++ b/common/stdio.c @@ -201,7 +201,7 @@ int stdio_deregister(char *devname) int stdio_init (void) { -#if !defined(CONFIG_ARM) && !defined(CONFIG_RELOC_FIXUP_WORKS) +#if !defined(CONFIG_RELOC_FIXUP_WORKS) /* already relocated for current ARM implementation */ ulong relocation_offset = gd->reloc_off; int i; @@ -211,7 +211,7 @@ int stdio_init (void) stdio_names[i] = (char *) (((ulong) stdio_names[i]) + relocation_offset); } -#endif /* !ARM && !CONFIG_RELOC_FIXUP_WORKS */ +#endif /* !CONFIG_RELOC_FIXUP_WORKS */ /* Initialize the list */ INIT_LIST_HEAD(&(devs.list)); diff --git a/include/asm-arm/config.h b/include/asm-arm/config.h index 049c44eaf..b76fd8eb4 100644 --- a/include/asm-arm/config.h +++ b/include/asm-arm/config.h @@ -21,4 +21,7 @@ #ifndef _ASM_CONFIG_H_ #define _ASM_CONFIG_H_ +/* Relocation to SDRAM works on all ARM boards */ +#define CONFIG_RELOC_FIXUP_WORKS + #endif diff --git a/include/asm-arm/global_data.h b/include/asm-arm/global_data.h index 5c56ce328..8115a24b7 100644 --- a/include/asm-arm/global_data.h +++ b/include/asm-arm/global_data.h @@ -38,7 +38,6 @@ typedef struct global_data { unsigned long flags; unsigned long baudrate; unsigned long have_console; /* serial_init() was called */ - unsigned long reloc_off; /* Relocation Offset */ unsigned long env_addr; /* Address of Environment struct */ unsigned long env_valid; /* Checksum of Environment valid? */ unsigned long fb_base; /* base address of frame buffer */ diff --git a/include/asm-microblaze/config.h b/include/asm-microblaze/config.h index 049c44eaf..8a9064b3c 100644 --- a/include/asm-microblaze/config.h +++ b/include/asm-microblaze/config.h @@ -21,4 +21,7 @@ #ifndef _ASM_CONFIG_H_ #define _ASM_CONFIG_H_ +/* Relocation to SDRAM works on all Microblaze boards */ +#define CONFIG_RELOC_FIXUP_WORKS + #endif diff --git a/include/asm-microblaze/global_data.h b/include/asm-microblaze/global_data.h index 3f49c349c..ec7837f6b 100644 --- a/include/asm-microblaze/global_data.h +++ b/include/asm-microblaze/global_data.h @@ -39,7 +39,6 @@ typedef struct global_data { unsigned long flags; unsigned long baudrate; unsigned long have_console; /* serial_init() was called */ - unsigned long reloc_off; /* Relocation Offset */ unsigned long env_addr; /* Address of Environment struct */ unsigned long env_valid; /* Checksum of Environment valid? */ unsigned long fb_base; /* base address of frame buffer */ diff --git a/include/asm-nios/config.h b/include/asm-nios/config.h index 049c44eaf..2efe898b3 100644 --- a/include/asm-nios/config.h +++ b/include/asm-nios/config.h @@ -21,4 +21,7 @@ #ifndef _ASM_CONFIG_H_ #define _ASM_CONFIG_H_ +/* Relocation to SDRAM works on all NIOS boards */ +#define CONFIG_RELOC_FIXUP_WORKS + #endif diff --git a/include/asm-nios/global_data.h b/include/asm-nios/global_data.h index 4929a5b87..fa54ee4dd 100644 --- a/include/asm-nios/global_data.h +++ b/include/asm-nios/global_data.h @@ -31,7 +31,6 @@ typedef struct global_data { unsigned long cpu_clk; /* CPU clock in Hz! */ unsigned long have_console; /* serial_init() was called */ phys_size_t ram_size; /* RAM size */ - unsigned long reloc_off; /* Relocation Offset */ unsigned long env_addr; /* Address of Environment struct */ unsigned long env_valid; /* Checksum of Environment valid */ #if defined(CONFIG_POST) || defined(CONFIG_LOGBUFFER) diff --git a/include/asm-nios2/config.h b/include/asm-nios2/config.h index 049c44eaf..011d603a4 100644 --- a/include/asm-nios2/config.h +++ b/include/asm-nios2/config.h @@ -21,4 +21,7 @@ #ifndef _ASM_CONFIG_H_ #define _ASM_CONFIG_H_ +/* Relocation to SDRAM works on all NIOS2 boards */ +#define CONFIG_RELOC_FIXUP_WORKS + #endif diff --git a/include/asm-nios2/global_data.h b/include/asm-nios2/global_data.h index db71324d4..34aa96277 100644 --- a/include/asm-nios2/global_data.h +++ b/include/asm-nios2/global_data.h @@ -30,7 +30,6 @@ typedef struct global_data { unsigned long cpu_clk; /* CPU clock in Hz! */ unsigned long have_console; /* serial_init() was called */ phys_size_t ram_size; /* RAM size */ - unsigned long reloc_off; /* Relocation Offset */ unsigned long env_addr; /* Address of Environment struct */ unsigned long env_valid; /* Checksum of Environment valid */ #if defined(CONFIG_POST) || defined(CONFIG_LOGBUFFER) diff --git a/include/asm-sh/config.h b/include/asm-sh/config.h index 049c44eaf..978cc92f4 100644 --- a/include/asm-sh/config.h +++ b/include/asm-sh/config.h @@ -21,4 +21,7 @@ #ifndef _ASM_CONFIG_H_ #define _ASM_CONFIG_H_ +/* Relocation to SDRAM works on all sh boards */ +#define CONFIG_RELOC_FIXUP_WORKS + #endif diff --git a/include/asm-sh/global_data.h b/include/asm-sh/global_data.h index f8ade5ca6..c12b8558e 100644 --- a/include/asm-sh/global_data.h +++ b/include/asm-sh/global_data.h @@ -35,7 +35,6 @@ typedef struct global_data unsigned long cpu_clk; /* CPU clock in Hz! */ unsigned long have_console; /* serial_init() was called */ phys_size_t ram_size; /* RAM size */ - unsigned long reloc_off; /* Relocation Offset */ unsigned long env_addr; /* Address of Environment struct */ unsigned long env_valid; /* Checksum of Environment valid */ void **jt; /* Standalone app jump table */ -- cgit v1.2.3