[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.
This commit is contained in:
parent
9e6ee5e795
commit
596c845072
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -2,13 +2,6 @@
|
|||
#ifndef __CONFIG_H
|
||||
#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
|
||||
*/
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
||||
/*------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 */
|
Loading…
Reference in New Issue