From mboxrd@z Thu Jan 1 00:00:00 1970 From: Graeme Russ Date: Sat, 26 Sep 2009 22:57:33 +1000 Subject: [U-Boot] [RFC][PATCH 3/8] Fix i386 malloc initialisation In-Reply-To: <1253969858-841-1-git-send-email-graeme.russ@gmail.com> References: <1253969858-841-1-git-send-email-graeme.russ@gmail.com> Message-ID: <1253969858-841-4-git-send-email-graeme.russ@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de --- board/eNET/u-boot.lds | 5 ++++- common/dlmalloc.c | 6 ------ include/configs/eNET.h | 2 +- include/configs/sc520_cdp.h | 2 +- include/configs/sc520_spunk.h | 2 +- lib_i386/board.c | 15 +++++++-------- 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/board/eNET/u-boot.lds b/board/eNET/u-boot.lds index 4ea424d..832d101 100644 --- a/board/eNET/u-boot.lds +++ b/board/eNET/u-boot.lds @@ -32,12 +32,15 @@ SECTIONS . = ALIGN(4); .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } + + .eh_frame : { *(.eh_frame) } _i386boot_text_size = SIZEOF(.text) + SIZEOF(.rodata); . = 0x03FF0000; /* Ram data segment to use */ _i386boot_romdata_dest = ABSOLUTE(.); - .data : AT ( LOADADDR(.rodata) + SIZEOF(.rodata) ) { *(.data) } + .data : AT ( LOADADDR(.eh_frame) + SIZEOF(.eh_frame) ) { *(.data) } +/* .data : { *(.data) } */ _i386boot_romdata_start = LOADADDR(.data); . = ALIGN(4); diff --git a/common/dlmalloc.c b/common/dlmalloc.c index 241db8c..f980430 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -1520,11 +1520,6 @@ void *sbrk(ptrdiff_t increment) return (void *)old; } -#ifndef CONFIG_X86 -/* - * x86 boards use a slightly different init sequence thus they implement - * their own version of mem_malloc_init() - */ void mem_malloc_init(ulong start, ulong size) { mem_malloc_start = start; @@ -1533,7 +1528,6 @@ void mem_malloc_init(ulong start, ulong size) memset((void *)mem_malloc_start, 0, size); } -#endif /* field-extraction macros */ diff --git a/include/configs/eNET.h b/include/configs/eNET.h index 243a554..54c34fa 100644 --- a/include/configs/eNET.h +++ b/include/configs/eNET.h @@ -61,7 +61,7 @@ /* * Size of malloc() pool */ -#define CONFIG_MALLOC_SIZE (CONFIG_SYS_ENV_SIZE + 128*1024) +#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 128*1024) #define CONFIG_BAUDRATE 9600 diff --git a/include/configs/sc520_cdp.h b/include/configs/sc520_cdp.h index 214a9af..2f1dae7 100644 --- a/include/configs/sc520_cdp.h +++ b/include/configs/sc520_cdp.h @@ -65,7 +65,7 @@ /* * Size of malloc() pool */ -#define CONFIG_MALLOC_SIZE (CONFIG_ENV_SIZE + 128*1024) +#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 128*1024) #define CONFIG_BAUDRATE 9600 diff --git a/include/configs/sc520_spunk.h b/include/configs/sc520_spunk.h index f3fc960..cf5633c 100644 --- a/include/configs/sc520_spunk.h +++ b/include/configs/sc520_spunk.h @@ -63,7 +63,7 @@ /* * Size of malloc() pool */ -#define CONFIG_MALLOC_SIZE (CONFIG_ENV_SIZE + 128*1024) +#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 128*1024) #define CONFIG_BAUDRATE 9600 diff --git a/lib_i386/board.c b/lib_i386/board.c index 0262b5e..39a3099 100644 --- a/lib_i386/board.c +++ b/lib_i386/board.c @@ -73,17 +73,16 @@ ulong i386boot_bios_size = (ulong)&_i386boot_bios_size; /* size of BIOS const char version_string[] = U_BOOT_VERSION" (" U_BOOT_DATE " - " U_BOOT_TIME ")"; -static int mem_malloc_init(void) +static int heap_init(void) { /* start malloc area right after the stack */ - mem_malloc_start = i386boot_bss_start + - i386boot_bss_size + CONFIG_SYS_STACK_SIZE; - mem_malloc_start = (mem_malloc_start+3)&~3; + ulong start = i386boot_bss_start + i386boot_bss_size + + CONFIG_SYS_STACK_SIZE; - /* Use all available RAM for malloc() */ - mem_malloc_end = gd->ram_size; + /* 4-byte aligned */ + start = (start+3)&~3; - mem_malloc_brk = mem_malloc_start; + mem_malloc_init(start, CONFIG_SYS_MALLOC_LEN); return 0; } @@ -180,7 +179,7 @@ init_fnc_t *init_sequence[] = { cpu_init, /* basic cpu dependent setup */ board_init, /* basic board dependent setup */ dram_init, /* configure available RAM banks */ - mem_malloc_init, /* dependant on dram_init */ + heap_init, /* dependant on dram_init */ interrupt_init, /* set up exceptions */ timer_init, serial_init, -- 1.6.4.1.174.g32f4c