diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2008-06-04 11:43:10 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2008-06-04 11:54:03 +0200 |
commit | 596c8450727ff2c9e2a8053e83280682d813c82f (patch) | |
tree | b1623de1d69f75765cffd8db50083a6faa64c8b4 | |
parent | 9e6ee5e79516f5af5366bd95fab801a692728373 (diff) | |
download | barebox-596c8450727ff2c9e2a8053e83280682d813c82f.tar.gz barebox-596c8450727ff2c9e2a8053e83280682d813c82f.tar.xz |
[memory layout]: streamline memory layout
Memory layout can now be specified via kconfig options. Two
possibilities exist: default layout means the layout is stack
/ malloc heap / U-Boot. The user can also specify fixed addresses
for each TEXT_BASE / stack / malloc heap.
-rw-r--r-- | Documentation/porting.txt | 13 | ||||
-rw-r--r-- | arch/arm/Kconfig | 2 | ||||
-rw-r--r-- | arch/arm/cpu/cpu.c | 14 | ||||
-rw-r--r-- | arch/arm/cpu/start-arm.S | 43 | ||||
-rw-r--r-- | arch/arm/lib/arm.c | 5 | ||||
-rw-r--r-- | arch/m68k/lib/m68k-meminit.c | 5 | ||||
-rw-r--r-- | arch/ppc/lib/board.c | 3 | ||||
-rw-r--r-- | board/eco920/config.h | 8 | ||||
-rw-r--r-- | board/imx27ads/config.h | 7 | ||||
-rw-r--r-- | board/ipe337/config.h | 7 | ||||
-rw-r--r-- | board/netx/config.h | 6 | ||||
-rw-r--r-- | board/pcm030/config.h | 1 | ||||
-rw-r--r-- | board/pcm037/config.h | 4 | ||||
-rw-r--r-- | board/pcm038/config.h | 5 | ||||
-rw-r--r-- | board/scb9328/config.h | 4 | ||||
-rw-r--r-- | commands/bootm.c | 3 | ||||
-rw-r--r-- | common/Kconfig | 56 | ||||
-rw-r--r-- | include/asm-arm/u-boot-arm.h | 2 | ||||
-rw-r--r-- | include/asm-generic/memory_layout.h | 19 |
19 files changed, 116 insertions, 91 deletions
diff --git a/Documentation/porting.txt b/Documentation/porting.txt index 7cc3bc298a..5b5407031e 100644 --- a/Documentation/porting.txt +++ b/Documentation/porting.txt @@ -92,15 +92,10 @@ console_initcall(scb9328_console_init); this is SoC dependend. See Documentation/timekeeping.txt for further information. -- Adjust start.S. These files share a lot of common code, so they should be - reworked in general. On Arm you have to fix CFG_MALLOC_LEN. Most start.S - under cpu/arm* do a "sub r0, r0, #CFG_MALLOC_LEN". If you increase - the malloc space the value CFG_MALLOC_LEN does not fit into the instruction. - See cpu/arm920t/start.S how it is done. - On PowerpC there is at least the Problem that the relocation offset is - defined at compile time. It is easily possible to determine the address - U-Boot is currently starting from at runtime and thus allowing it U-Boot - to be started at any address. Look at the relocation code and replace +- Adjust start.S. On PowerpC there is at least the Problem that the relocation + offset is defined at compile time. It is easily possible to determine the + address U-Boot is currently starting from at runtime and thus allowing it + U-Boot to be started at any address. Look at the relocation code and replace TEXT_BASE with the following calculation of the runtime address: bl calc_source /* Calculate Source Address */ diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index e6df3318ff..9012c4857b 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -39,6 +39,8 @@ config ARM bool select HAS_KALLSYMS select HAS_MODULES + select HAVE_CONFIGURABLE_MEMORY_LAYOUT + select HAVE_CONFIGURABLE_TEXT_BASE default y config ARM920T diff --git a/arch/arm/cpu/cpu.c b/arch/arm/cpu/cpu.c index c6a13f43c6..babcd10a10 100644 --- a/arch/arm/cpu/cpu.c +++ b/arch/arm/cpu/cpu.c @@ -155,20 +155,6 @@ int cleanup_before_linux (void) * required. */ -#ifdef CONFIG_USE_IRQ -static int cpu_init (void) -{ - /* - * setup up stacks if necessary - */ - IRQ_STACK_START = _u_boot_start - CFG_MALLOC_LEN - CFG_GBL_DATA_SIZE - 4; - FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ; - return 0; -} - -core_initcall(cpu_init); -#endif - /** * @page arm_for_linux Preparing for Linux to run * diff --git a/arch/arm/cpu/start-arm.S b/arch/arm/cpu/start-arm.S index a4a18c64dc..a2eb19c9e2 100644 --- a/arch/arm/cpu/start-arm.S +++ b/arch/arm/cpu/start-arm.S @@ -40,6 +40,7 @@ .section ".text_entry","ax" #include <config.h> +#include <asm-generic/memory_layout.h> /************************************************************************* * Jump vector table as in table 3.1 in [1] @@ -86,15 +87,28 @@ _TEXT_BASE: _u_boot_start: .word _start -/************************************************************************* - * FIXME - *************************************************************************/ +#ifndef CONFIG_STACKSIZE_IRQ +#define CONFIG_STACKSIZE_IRQ 0 +#endif +#ifndef CONFIG_STACKSIZE_FIQ +#define CONFIG_STACKSIZE_FIQ 0 +#endif -_MALLOC_START: - .word _start - CFG_MALLOC_LEN +_MALLOC_BASE: + .word MALLOC_BASE _STACK_START: - .word _start - CFG_MALLOC_LEN - CONFIG_STACKSIZE + .word STACK_BASE + STACK_SIZE - 4 + +#ifdef CONFIG_USE_IRQ +/* IRQ stack memory */ +IRQ_STACK_START: + .word STACK_BASE + CONFIG_STACKSIZE_IRQ - 4 + +/* IRQ stack memory */ +FIQ_STACK_START: + .word STACK_BASE + CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ - 4 +#endif /* * These are defined in the board-specific linker script. @@ -107,18 +121,6 @@ _bss_start: _bss_end: .word _end -#ifdef CONFIG_USE_IRQ -/* IRQ stack memory (calculated at run-time) */ -.globl IRQ_STACK_START -IRQ_STACK_START: - .word 0x0badc0de - -/* IRQ stack memory (calculated at run-time) */ -.globl FIQ_STACK_START -FIQ_STACK_START: - .word 0x0badc0de -#endif - /************************************************************************* * the actual reset code *************************************************************************/ @@ -179,10 +181,7 @@ copy_loop: /* Set up the stack */ stack_setup: - ldr r0, _MALLOC_START /* upper 128 KiB: relocated uboot */ -#ifdef CONFIG_USE_IRQ - sub r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ) -#endif + ldr r0, _STACK_START sub sp, r0, #12 /* leave 3 words for abort-stack */ clear_bss: diff --git a/arch/arm/lib/arm.c b/arch/arm/lib/arm.c index 0df99d742c..fe8ee93885 100644 --- a/arch/arm/lib/arm.c +++ b/arch/arm/lib/arm.c @@ -2,12 +2,13 @@ #include <init.h> #include <mem_malloc.h> #include <asm/u-boot-arm.h> +#include <asm-generic/memory_layout.h> #include <reloc.h> int arm_mem_malloc_init(void) { - mem_malloc_init((void *)(_u_boot_start - CFG_MALLOC_LEN), - (void *)_u_boot_start); + mem_malloc_init((void *)MALLOC_BASE, + (void *)(MALLOC_BASE + MALLOC_SIZE)); return 0; } diff --git a/arch/m68k/lib/m68k-meminit.c b/arch/m68k/lib/m68k-meminit.c index b7905c2851..8dfaa9c479 100644 --- a/arch/m68k/lib/m68k-meminit.c +++ b/arch/m68k/lib/m68k-meminit.c @@ -26,6 +26,7 @@ #include <mem_malloc.h> #include <asm/u-boot-m68k.h> #include <reloc.h> +#include <asm-generic/memory_layout.h> /** Initialize mem allocator on M68k/Coldfire */ @@ -33,8 +34,8 @@ int m68k_mem_malloc_init(void) { /* Pass start and end address of managed memory */ - mem_malloc_init((void *)(&_u_boot_start - CFG_MALLOC_LEN), - (void *)&_u_boot_start); + mem_malloc_init((void *)MALLOC_BASE, + (void *)(MALLOC_BASE + MALLOC_SIZE)); return 0; } diff --git a/arch/ppc/lib/board.c b/arch/ppc/lib/board.c index 44522007d8..bd82a73f51 100644 --- a/arch/ppc/lib/board.c +++ b/arch/ppc/lib/board.c @@ -30,6 +30,7 @@ #include <init.h> #include <net.h> #include <reloc.h> +#include <asm-generic/memory_layout.h> char *strmhz (char *buf, long hz) { @@ -71,7 +72,7 @@ void board_init_r (ulong end_of_ram) debug("malloc_end: 0x%08x\n", malloc_end); debug("TEXT_BASE after relocation: 0x%08x\n", _text_base); - mem_malloc_init((void *)(malloc_end - CFG_MALLOC_LEN), (void *)malloc_end); + mem_malloc_init((void *)(malloc_end - MALLOC_SIZE), (void *)malloc_end); /* * Setup trap handlers diff --git a/board/eco920/config.h b/board/eco920/config.h index c023517719..9aa7dde98e 100644 --- a/board/eco920/config.h +++ b/board/eco920/config.h @@ -68,12 +68,6 @@ #define SDRC_MR_VAL3 0x00000000 /* Normal Mode */ #define SDRC_TR_VAL 0x000002E0 /* Write refresh rate */ -/* - * Size of malloc() pool - */ -#define CFG_MALLOC_LEN (512*1024) -#define CFG_GBL_DATA_SIZE 128 /* size in bytes reserved for initial data */ - #define CONFIG_BAUDRATE 115200 /* @@ -127,8 +121,6 @@ #define CLOCK_TICK_RATE AT91C_MASTER_CLOCK/2 /* AT91C_TC0_CMR is implicitly set to */ /* AT91C_TC_TIMER_DIV1_CLOCK */ -#define CONFIG_STACKSIZE (32 * 1024) /* regular stack */ - #define CONFIG_MISC_INIT_R 1 /* call misc_init_r() on init */ #define CFG_SPLASH 1 #define CFG_S1D13706FB 1 diff --git a/board/imx27ads/config.h b/board/imx27ads/config.h index 362fe9d29f..169ac0c9c3 100644 --- a/board/imx27ads/config.h +++ b/board/imx27ads/config.h @@ -21,11 +21,4 @@ #ifndef __CONFIG_H #define __CONFIG_H -/* FIXME: ugly....should be simply part of the BSP file */ - -#include <asm/mach-types.h> - -#define CFG_MALLOC_LEN (4096 << 10) -#define CONFIG_STACKSIZE ( 120 << 10) /* stack size */ - #endif /* __CONFIG_H */ diff --git a/board/ipe337/config.h b/board/ipe337/config.h index 7799345f21..aa25d0792d 100644 --- a/board/ipe337/config.h +++ b/board/ipe337/config.h @@ -3,13 +3,6 @@ #define __CONFIG_H /* - * Board Layout - */ -#define CONFIG_MALLOC_LEN (16384 << 10) -#define CONFIG_MALLOC_BASE (TEXT_BASE - CONFIG_MALLOC_LEN) -#define CONFIG_STACKBASE (CONFIG_MALLOC_BASE - 4) - -/* * Clock settings */ diff --git a/board/netx/config.h b/board/netx/config.h index f622f67fc8..ca15136817 100644 --- a/board/netx/config.h +++ b/board/netx/config.h @@ -1,2 +1,4 @@ -#define CFG_MALLOC_LEN (4096 << 10) -#define CONFIG_STACKSIZE (120<<10) /* stack size */ +#ifndef __CONFIG_H +#define __CONFIG_H + +#endif /* __CONFIG_H */ diff --git a/board/pcm030/config.h b/board/pcm030/config.h index 339ea71f8b..16b7ba8518 100644 --- a/board/pcm030/config.h +++ b/board/pcm030/config.h @@ -87,7 +87,6 @@ IPB Bus clocking configuration. #define CFG_INIT_RAM_SIZE MPC5XXX_SRAM_SIZE /* End of used area in DPRAM */ #define CONFIG_EARLY_INITDATA_SIZE 0x100 -#define CFG_MALLOC_LEN (8 << 20) /* Reserve 8 MB for malloc() */ #define CFG_BOOTMAPSZ (8 << 20) /* Initial Memory map for Linux */ /*------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/board/pcm037/config.h b/board/pcm037/config.h index aa79c8a575..5495d0309c 100644 --- a/board/pcm037/config.h +++ b/board/pcm037/config.h @@ -24,10 +24,6 @@ * Definitions related to passing arguments to kernel. */ -#define CFG_MALLOC_LEN (4096 << 10) - -#define CONFIG_STACKSIZE (120<<10) /* stack size */ - /* #define CONFIG_SYSPLL_CLK_FREQ 26000000 */ /* FIXME */ diff --git a/board/pcm038/config.h b/board/pcm038/config.h index 51f9bd9983..b3eed0bb3c 100644 --- a/board/pcm038/config.h +++ b/board/pcm038/config.h @@ -21,9 +21,4 @@ #ifndef __CONFIG_H #define __CONFIG_H -/* FIXME: ugly....should be simply part of the BSP file */ - -#define CFG_MALLOC_LEN (4096 << 10) -#define CONFIG_STACKSIZE ( 120 << 10) /* stack size */ - #endif /* __CONFIG_H */ diff --git a/board/scb9328/config.h b/board/scb9328/config.h index 38e11549d9..cc22b7ae72 100644 --- a/board/scb9328/config.h +++ b/board/scb9328/config.h @@ -24,10 +24,6 @@ #ifndef __CONFIG_H #define __CONFIG_H -#define CFG_MALLOC_LEN (4096 << 10) - -#define CONFIG_STACKSIZE (120<<10) /* stack size */ - #define CONFIG_SYSPLL_CLK_FREQ 16000000 #endif /* __CONFIG_H */ diff --git a/commands/bootm.c b/commands/bootm.c index e210059aa2..9b0a158796 100644 --- a/commands/bootm.c +++ b/commands/bootm.c @@ -42,6 +42,7 @@ #include <boot.h> #include <rtc.h> #include <init.h> +#include <asm-generic/memory_layout.h> #ifdef CONFIG_SHOW_BOOT_PROGRESS # include <status_led.h> @@ -223,7 +224,7 @@ int relocate_image(struct image_handle *handle, void *load_address) */ if (BZ2_bzBuffToBuffDecompress (load_address, &unc_len, (char *)data, len, - CFG_MALLOC_LEN < (4096 * 1024), 0) + MALLOC_SIZE < (4096 * 1024), 0) != BZ_OK) return -1; break; diff --git a/common/Kconfig b/common/Kconfig index 79a3684867..c7ec266a40 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -19,13 +19,69 @@ menu "General Settings " config BOARDINFO string +menu "memory layout " + +config HAVE_CONFIGURABLE_TEXT_BASE + bool + config TEXT_BASE + depends on HAVE_CONFIGURABLE_TEXT_BASE prompt "TEXT_BASE" hex default ARCH_TEXT_BASE help The Address U-Boot gets linked at. +config HAVE_CONFIGURABLE_MEMORY_LAYOUT + bool + +choice + prompt "select memory layout" + depends on HAVE_CONFIGURABLE_MEMORY_LAYOUT + default MEMORY_LAYOUT_DEFAULT + +config MEMORY_LAYOUT_DEFAULT + bool "use default memory layout" + help + select this option to use U-Boots standard memory layout: + + stack + ----- + malloc heap + ----- + TEXT_BASE + +config MEMORY_LAYOUT_FIXED + bool "manually assign a memory layout" + help + select this option to manually assign stack base and malloc + heap base + +endchoice + +config STACK_BASE + depends on MEMORY_LAYOUT_FIXED + hex + prompt "STACK_BASE" + +config STACK_SIZE + hex + depends on HAVE_CONFIGURABLE_MEMORY_LAYOUT + default 0x8000 + prompt "Stack size" + +config MALLOC_BASE + depends on MEMORY_LAYOUT_FIXED + hex + prompt "MALLOC_BASE" + +config MALLOC_SIZE + hex + depends on HAVE_CONFIGURABLE_MEMORY_LAYOUT + default 0x400000 + prompt "malloc area size" +endmenu + config BROKEN bool prompt "Prompt for broken or incomplete code" diff --git a/include/asm-arm/u-boot-arm.h b/include/asm-arm/u-boot-arm.h index 68d48aa3a4..539135add0 100644 --- a/include/asm-arm/u-boot-arm.h +++ b/include/asm-arm/u-boot-arm.h @@ -33,8 +33,6 @@ extern ulong _armboot_start; /* code start */ extern ulong _bss_start; /* code + data end == BSS start */ extern ulong _bss_end; /* BSS end */ -extern ulong IRQ_STACK_START; /* top of IRQ stack */ -extern ulong FIQ_STACK_START; /* top of FIQ stack */ /* cpu/.../cpu.c */ int cleanup_before_linux(void); diff --git a/include/asm-generic/memory_layout.h b/include/asm-generic/memory_layout.h new file mode 100644 index 0000000000..941cd42955 --- /dev/null +++ b/include/asm-generic/memory_layout.h @@ -0,0 +1,19 @@ +#ifndef __ASM_GENERIC_MEMORY_LAYOUT_H +#define __ASM_GENERIC_MEMORY_LAYOUT_H + +#ifdef CONFIG_MEMORY_LAYOUT_DEFAULT + +#define MALLOC_BASE (TEXT_BASE - CONFIG_MALLOC_SIZE) +#define STACK_BASE (TEXT_BASE - CONFIG_MALLOC_SIZE - CONFIG_STACK_SIZE) + +#else + +#define STACK_BASE CONFIG_STACK_BASE +#define MALLOC_BASE CONFIG_MALLOC_BASE + +#endif + +#define MALLOC_SIZE CONFIG_MALLOC_SIZE +#define STACK_SIZE CONFIG_STACK_SIZE + +#endif /* __ASM_GENERIC_MEMORY_LAYOUT_H */ |