arm, arm1136, qong: add relocation support
RFC PATCH 4/19 arm, arm1136, qong: add relocation support
Signed-off-by Heiko Schocher <[email protected]>
--- arch/arm/config.mk | 3 + arch/arm/cpu/arm1136/start.S | 176 ++++++++++++++------ arch/arm/cpu/arm1136/u-boot.lds | 14 ++- arch/arm/include/asm/config.h | 3 - arch/arm/include/asm/global_data.h | 6 + arch/arm/include/asm/u-boot-arm.h | 8 +- arch/arm/lib/board.c | 315 ++++++++++++++++++++++++++++++------ arch/arm/lib/interrupts.c | 15 ++- board/davedenx/qong/config.mk | 4 +- board/davedenx/qong/qong.c | 92 ++++++----- common/cmd_bdinfo.c | 1 + common/cmd_bmp.c | 6 + common/cmd_i2c.c | 6 + include/configs/qong.h | 9 + nand_spl/nand_boot.c | 5 + nand_spl/nand_boot_fsl_nfc.c | 5 + 16 files changed, 519 insertions(+), 149 deletions(-)
arch/arm/config.mk +3 -0
@@ -33,6 +33,9 @@ STANDALONE_LOAD_ADDR = 0xc100000 endif endif +# needed for relocation +PLATFORM_RELFLAGS += -fPIC + PLATFORM_CPPFLAGS += -DCONFIG_ARM -D__ARM__ # Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
arch/arm/cpu/arm1136/start.S +125 -51
242 lines not on this page · raw message
arch/arm/cpu/arm1136/u-boot.lds +13 -1
@@ -47,11 +47,23 @@ SECTIONS .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } . = ALIGN(4); - .data : { *(.data) } + .data : { + *(.data) + __datarel_start = .; + *(.data.rel) + __datarelrolocal_start = .; + *(.data.rel.ro.local) + __datarellocal_start = .; + *(.data.rel.local) + __datarelro_start = .; + *(.data.rel.ro) + } + __got_start = .; . = ALIGN(4); .got : { *(.got) } + __got_end = .; . = .; __u_boot_cmd_start = .; .u_boot_cmd : { *(.u_boot_cmd) }
arch/arm/include/asm/config.h +0 -3
@@ -21,7 +21,4 @@#ifndef _ASM_CONFIG_H_#define _ASM_CONFIG_H_ -/* Relocation to SDRAM works on all ARM boards */ -#define CONFIG_RELOC_FIXUP_WORKS -#endif
arch/arm/include/asm/global_data.h +6 -0
@@ -53,6 +53,12 @@ typedef struct global_data {phys_size_t ram_size;/* RAM size */ unsigned long reset_status;/* reset status register@boot */ #endif +unsigned long relocaddr;/* Start address of U-Boot in RAM */ +phys_size_t ram_size;/* RAM size */ +unsigned long mon_len;/* monitor len */ +unsigned long irq_sp;/* irq stack pointer */ +unsigned long start_addr_sp;/* start_addr_stackpointer */ +unsigned long reloc_off;void **jt;/* jump table */ } gd_t;
arch/arm/include/asm/u-boot-arm.h +7 -1
@@ -30,10 +30,15 @@#define _U_BOOT_ARM_H_ 1/* for the following variables, see start.S */ -extern ulong _armboot_start;/* code start */ +extern ulong _TEXT_BASE;/* code start */ extern ulong _bss_start;/* code + data end == BSS start */ extern ulong _bss_end;/* BSS end */ +extern ulong _datarel_start; +extern ulong _datarelrolocal_start; +extern ulong _datarellocal_start; +extern ulong _datarelro_start;extern ulong IRQ_STACK_START ;/* top of IRQ stack */ +extern ulong IRQ_STACK_START_IN ;/* 8 bytes in IRQ stack */ extern ulong FIQ_STACK_START ;/* top of FIQ stack */ /* cpu/.../cpu.c */
@@ -47,6 +52,7 @@ int arch_misc_init(void);/* board/.../... */ int board_init (void );int dram_init (void ); +void dram_init_banksize (void );void setup_serial_tag (struct tag **params);void setup_revision_tag (struct tag **params);
arch/arm/lib/board.c +265 -50
395 lines not on this page · raw message
arch/arm/lib/interrupts.c +13 -2
@@ -38,15 +38,16 @@#include <common.h> #include <asm/proc-armv/ptrace.h> -#ifdef CONFIG_USE_IRQ DECLARE_GLOBAL_DATA_PTR ; +#ifdef CONFIG_USE_IRQ int interrupt_init (void ) {/* * setup up stacks if necessary */ -IRQ_STACK_START = _armboot_start -CONFIG_SYS_MALLOC_LEN -CONFIG_SYS_GBL_DATA_SIZE -4 ; +IRQ_STACK_START = gd->irq_sp -4 ; +IRQ_STACK_START_IN = gd->irq_sp +8 ;FIQ_STACK_START =IRQ_STACK_START -CONFIG_STACKSIZE_IRQ ;return arch_interrupt_init ();
@@ -81,6 +82,16 @@ int disable_interrupts (void) return (old & 0x80) == 0; }#else +int interrupt_init (void ) +{ +/* +* setup up stacks if necessary +*/ +IRQ_STACK_START_IN = gd->irq_sp +8 ; + +return 0 ; +} +void enable_interrupts (void ) {return ;
board/davedenx/qong/config.mk +3 -1
@@ -1 +1,3 @@ -TEXT_BASE = 0x8ff00000 +TEXT_BASE = 0xa0000000 + +# PLATFORM_CPPFLAGS += -DDEBUG
board/davedenx/qong/qong.c +52 -40
112 lines not on this page · raw message
common/cmd_bdinfo.c +1 -0
@@ -343,6 +343,7 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])printf ("ip_addr = %pI4\n" , &bd->bi_ip_addr);#endif printf ("baudrate = %d bps\n" , bd->bi_baudrate); +print_num ("irq_sp" , gd->irq_sp);/* irq stack pointer */ return 0 ; }
common/cmd_bmp.c +6 -0
@@ -137,6 +137,12 @@ static cmd_tbl_t cmd_bmp_sub[] = { U_BOOT_CMD_MKENT(display, 5, 0, do_bmp_display, "", ""), }; +#ifndef CONFIG_RELOC_FIXUP_WORKS +void bmp_reloc (void ) { +fixup_cmdtable (cmd_bmp_sub,ARRAY_SIZE (cmd_bmp_sub)); +} +#endif +/* * Subroutine: do_bmp *
common/cmd_i2c.c +6 -0
@@ -1287,6 +1287,12 @@ static cmd_tbl_t cmd_i2c_sub[] = { U_BOOT_CMD_MKENT(speed, 1, 1, do_i2c_bus_speed, "", ""), }; +#ifndef CONFIG_RELOC_FIXUP_WORKS +void i2c_reloc (void ) { +fixup_cmdtable (cmd_i2c_sub,ARRAY_SIZE (cmd_i2c_sub)); +} +#endif +static int do_i2c (cmd_tbl_t * cmdtp,int flag,int argc,char *const argv[]) {cmd_tbl_t *c;
include/configs/qong.h +9 -0
@@ -281,4 +281,13 @@ extern int qong_nand_rdy(void *chip);"mtdparts=physmap-flash.0:384k(U-Boot),128k(env1)," \"128k(env2),2432k(kernel),13m(ramdisk),-(user)" +/* additions for new relocation code, must added to all boards */ +#define CONFIG_SYS_SDRAM_BASE 0x80000000 +#define CONFIG_SYS_INIT_RAM_ADDR IRAM_BASE_ADDR +#define CONFIG_SYS_INIT_RAM_END IRAM_SIZE +#define CONFIG_SYS_GBL_DATA_OFFSET (CONFIG_SYS_INIT_RAM_END - CONFIG_SYS_GBL_DATA_SIZE) +#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET) + +#define CONFIG_BOARD_EARLY_INIT_F 1 +#endif /* __CONFIG_H */
nand_spl/nand_boot.c +5 -0
@@ -221,6 +221,11 @@ static int nand_load(struct mtd_info *mtd, unsigned int offs,return 0 ; } +void board_init_f (ulong bootflag) +{ +relocate_code (TEXT_BASE -TOTAL_MALLOC_LEN ,NULL ,TEXT_BASE ); +} +/* * The main entry for NAND booting. It's necessary that SDRAM is already * configured and available since this code loads the main U-Boot image
nand_spl/nand_boot_fsl_nfc.c +5 -0
@@ -265,6 +265,11 @@ static int nand_load(unsigned int from, unsigned int size, unsigned char *buf)return 0 ; } +void board_init_f (ulong bootflag) +{ +relocate_code (TEXT_BASE -TOTAL_MALLOC_LEN ,NULL ,TEXT_BASE ); +} +/* * The main entry for NAND booting. It's necessary that SDRAM is already * configured and available since this code loads the main U-Boot image
Signature · 5 lines
1.6.2.5 -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany