summaryrefslogtreecommitdiff
path: root/arch/sandbox/lib
diff options
context:
space:
mode:
authorMatthias Weisser <weisserm@arcor.de>2011-11-05 11:40:34 +0100
committerMike Frysinger <vapier@gentoo.org>2011-12-10 17:54:04 -0500
commit21899b10850b8ba155b16038fac5dd8d98214842 (patch)
tree704f143e00b60eb3a2f405fb3d8870c59b527425 /arch/sandbox/lib
parentc90a4dd79cb17abb46689f27ff9f1c971362d6e2 (diff)
downloadu-boot-imx-21899b10850b8ba155b16038fac5dd8d98214842.zip
u-boot-imx-21899b10850b8ba155b16038fac5dd8d98214842.tar.gz
u-boot-imx-21899b10850b8ba155b16038fac5dd8d98214842.tar.bz2
sandbox: Add improved RAM simulation
Using mmap to allocate memory from the OS for RAM simulation we can use u-boot own malloc implementation. Tested-by: Simon Glass <sjg@chromium.org> Signed-off-by: Matthias Weisser <weisserm@arcor.de> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch/sandbox/lib')
-rw-r--r--arch/sandbox/lib/board.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/arch/sandbox/lib/board.c b/arch/sandbox/lib/board.c
index ae5a517..b7997e9 100644
--- a/arch/sandbox/lib/board.c
+++ b/arch/sandbox/lib/board.c
@@ -45,8 +45,12 @@
#include <version.h>
#include <serial.h>
+#include <os.h>
+
DECLARE_GLOBAL_DATA_PTR;
+static gd_t gd_mem;
+
/************************************************************************
* Init Utilities *
************************************************************************
@@ -147,7 +151,7 @@ void board_init_f(ulong bootflag)
uchar *mem;
unsigned long addr_sp, addr, size;
- gd = malloc(sizeof(gd_t));
+ gd = &gd_mem;
assert(gd);
memset((void *)gd, 0, sizeof(gd_t));
@@ -158,7 +162,8 @@ void board_init_f(ulong bootflag)
}
size = CONFIG_SYS_SDRAM_SIZE;
- mem = malloc(size);
+ mem = os_malloc(CONFIG_SYS_SDRAM_SIZE);
+
assert(mem);
gd->ram_buf = mem;
addr = (ulong)(mem + size);
@@ -214,11 +219,9 @@ void board_init_r(gd_t *id, ulong dest_addr)
post_output_backlog();
#endif
-#if 0 /* Sandbox uses system malloc for now */
- /* The Malloc area is immediately below the monitor copy in DRAM */
- malloc_start = dest_addr - TOTAL_MALLOC_LEN;
- mem_malloc_init(malloc_start, TOTAL_MALLOC_LEN);
-#endif
+ /* The Malloc area is at the top of simulated DRAM */
+ mem_malloc_init((ulong)gd->ram_buf + gd->ram_size - TOTAL_MALLOC_LEN,
+ TOTAL_MALLOC_LEN);
/* initialize environment */
env_relocate();