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>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
+
+void *os_malloc(size_t length)
+{
+ return mmap(NULL, length, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+}
#include <version.h>
#include <serial.h>
#include <version.h>
#include <serial.h>
/************************************************************************
* Init Utilities *
************************************************************************
/************************************************************************
* Init Utilities *
************************************************************************
uchar *mem;
unsigned long addr_sp, addr, size;
uchar *mem;
unsigned long addr_sp, addr, size;
- gd = malloc(sizeof(gd_t));
assert(gd);
memset((void *)gd, 0, sizeof(gd_t));
assert(gd);
memset((void *)gd, 0, sizeof(gd_t));
}
size = CONFIG_SYS_SDRAM_SIZE;
}
size = CONFIG_SYS_SDRAM_SIZE;
+ mem = os_malloc(CONFIG_SYS_SDRAM_SIZE);
+
assert(mem);
gd->ram_buf = mem;
addr = (ulong)(mem + size);
assert(mem);
gd->ram_buf = mem;
addr = (ulong)(mem + size);
post_output_backlog();
#endif
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();
/* initialize environment */
env_relocate();
ifndef CONFIG_SPL_BUILD
COBJS-y += main.o
COBJS-y += command.o
ifndef CONFIG_SPL_BUILD
COBJS-y += main.o
COBJS-y += command.o
-ifndef CONFIG_SANDBOX
-COBJS-y += dlmalloc.o
-endif
COBJS-y += exports.o
COBJS-$(CONFIG_SYS_HUSH_PARSER) += hush.o
COBJS-y += image.o
COBJS-y += exports.o
COBJS-$(CONFIG_SYS_HUSH_PARSER) += hush.o
COBJS-y += image.o
* Put tty into raw mode to mimic serial console better
*/
void os_tty_raw(int fd);
* Put tty into raw mode to mimic serial console better
*/
void os_tty_raw(int fd);
+
+/**
+ * Acquires some memory from the underlying os.
+ *
+ * \param length Number of bytes to be allocated
+ * \return Pointer to length bytes or NULL on error
+ */
+void *os_malloc(size_t length);