aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFeng Tang <feng.tang@intel.com>2010-06-13 16:48:36 +0800
committerFeng Tang <feng.tang@intel.com>2010-07-20 11:10:03 +0800
commit406b3ea5275361e75db5bcba912e4d364e8f65df (patch)
treeac4fac44b3d8cf8ec93ba0b7e61b5dbe5ee81d1f
parent638ea79273213c72c075eff71ad927ee40aee8c5 (diff)
downloadsyslinux-406b3ea5275361e75db5bcba912e4d364e8f65df.tar.gz
syslinux-406b3ea5275361e75db5bcba912e4d364e8f65df.tar.xz
syslinux-406b3ea5275361e75db5bcba912e4d364e8f65df.zip
elflink: make malloc works
mask the malloc of com32, will still need to change its way of calling inject_free_block
-rw-r--r--com32/lib/free.c2
-rw-r--r--com32/lib/malloc.c2
-rw-r--r--com32/lib/sys/open.c2
-rw-r--r--core/elflink/cli.c1
-rw-r--r--core/fs/fs.c4
-rw-r--r--core/mem/free.c4
-rw-r--r--core/mem/init.c3
-rw-r--r--core/mem/malloc.c11
8 files changed, 23 insertions, 6 deletions
diff --git a/com32/lib/free.c b/com32/lib/free.c
index ac9c7893..fb8fdb4a 100644
--- a/com32/lib/free.c
+++ b/com32/lib/free.c
@@ -98,6 +98,7 @@ void __inject_free_block(struct free_arena_header *ah)
__free_block(ah);
}
+#if 0
void free(void *ptr)
{
struct free_arena_header *ah;
@@ -121,3 +122,4 @@ void free(void *ptr)
/* Here we could insert code to return memory to the system. */
}
+#endif
diff --git a/com32/lib/malloc.c b/com32/lib/malloc.c
index b03f456c..ba79b659 100644
--- a/com32/lib/malloc.c
+++ b/com32/lib/malloc.c
@@ -139,6 +139,7 @@ static void *__malloc_from_block(struct free_arena_header *fp, size_t size)
return (void *)(&fp->a + 1);
}
+#if 0
void *malloc(size_t size)
{
struct free_arena_header *fp;
@@ -166,6 +167,7 @@ void *malloc(size_t size)
mp("will return 0x%p", buf);
return buf;
}
+#endif
/* need to revisit this later */
int posix_memalign(void **memptr, size_t align, size_t size)
diff --git a/com32/lib/sys/open.c b/com32/lib/sys/open.c
index d7a923b4..1d7677bc 100644
--- a/com32/lib/sys/open.c
+++ b/com32/lib/sys/open.c
@@ -57,7 +57,7 @@ int open(const char *pathname, int flags, ...)
fd = opendev(&__file_dev, NULL, flags);
- printf("enter, file = %s, fd = %d\n", pathname, fd);
+ //printf("enter, file = %s, fd = %d\n", pathname, fd);
if (fd < 0)
return -1;
diff --git a/core/elflink/cli.c b/core/elflink/cli.c
index b3a2f912..db2c7758 100644
--- a/core/elflink/cli.c
+++ b/core/elflink/cli.c
@@ -85,7 +85,6 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
if (getscreensize(1, &height, &width))
width = 80;
}
- printf("width = %d\n", width);
strncpy(cmdline, input, MAX_CMDLINE_LEN);
cmdline[MAX_CMDLINE_LEN - 1] = '\0';
diff --git a/core/fs/fs.c b/core/fs/fs.c
index 6c272e94..dfc24bcb 100644
--- a/core/fs/fs.c
+++ b/core/fs/fs.c
@@ -220,7 +220,7 @@ int searchdir(const char *name)
if (!pathbuf)
goto err;
- mp("parent->ino = %d", parent->ino);
+ //mp("parent->ino = %d", parent->ino);
do {
got_link:
@@ -338,7 +338,7 @@ int open_file(const char *name, struct com32_filedata *filedata)
mangle_name(mangled_name, name);
rv = searchdir(mangled_name);
- mp("name = %s, rv = %d", name, rv);
+ //mp("name = %s, rv = %d", name, rv);
if (rv >= 0) {
file = handle_to_file(rv);
diff --git a/core/mem/free.c b/core/mem/free.c
index 58d7bd60..9d853a4b 100644
--- a/core/mem/free.c
+++ b/core/mem/free.c
@@ -101,7 +101,7 @@ void __inject_free_block(struct free_arena_header *ah)
size_t n_end;
//dprintf("inject: %#zx bytes @ %p, heap %u (%p)\n",
- mp("inject: %#zx bytes @ %p, heap %u (%p)",
+ printf("inject: %#zx bytes @%p, heap%u (%p)\n",
ARENA_SIZE_GET(ah->a.attrs), ah,
ARENA_HEAP_GET(ah->a.attrs), head);
@@ -116,6 +116,8 @@ void __inject_free_block(struct free_arena_header *ah)
if ((size_t) ah >= n_end)
continue;
+ printf("conflict:ah: %p, a_end: %p, nah: %p, n_end: %p\n", ah, a_end, nah, n_end);
+
/* Otherwise we have some sort of overlap - reject this block */
return;
}
diff --git a/core/mem/init.c b/core/mem/init.c
index f35501c8..5063633e 100644
--- a/core/mem/init.c
+++ b/core/mem/init.c
@@ -3,6 +3,8 @@
#include <string.h>
#include "malloc.h"
+#include <stdio.h>
+
struct free_arena_header __core_malloc_head[NHEAP];
static __hugebss char main_heap[128 << 10];
@@ -29,6 +31,7 @@ void mem_init(void)
ARENA_SIZE_SET(fp->a.attrs, sizeof main_heap);
__inject_free_block(fp);
+ //mp("__lowmem_heap = 0x%p bios_free = 0x%p", __lowmem_heap, *bios_free_mem);
/* Initialize the lowmem heap */
fp = (struct free_arena_header *)__lowmem_heap;
fp->a.attrs = ARENA_TYPE_USED | (HEAP_LOWMEM << ARENA_HEAP_POS);
diff --git a/core/mem/malloc.c b/core/mem/malloc.c
index b6953ad2..0f41960f 100644
--- a/core/mem/malloc.c
+++ b/core/mem/malloc.c
@@ -10,6 +10,8 @@
#include <dprintf.h>
#include "malloc.h"
+#include <stdio.h>
+
static void *__malloc_from_block(struct free_arena_header *fp,
size_t size, malloc_tag_t tag)
{
@@ -63,6 +65,7 @@ static void *_malloc(size_t size, enum heap heap, malloc_tag_t tag)
struct free_arena_header *head = &__core_malloc_head[heap];
void *p = NULL;
+ //mp("_malloc(%zu, %u, %u) @ %p = ",
dprintf("_malloc(%zu, %u, %u) @ %p = ",
size, heap, tag, __builtin_return_address(0));
@@ -79,7 +82,8 @@ static void *_malloc(size_t size, enum heap heap, malloc_tag_t tag)
}
}
- dprintf("%p\n", p);
+ //dprintf("%p\n", p);
+ //printf("%p\n", p);
return p;
}
@@ -88,6 +92,11 @@ void *hmalloc(size_t size)
return _malloc(size, HEAP_MAIN, MALLOC_CORE);
}
+void *malloc(size_t size)
+{
+ return _malloc(size, HEAP_MAIN, MALLOC_CORE);
+}
+
void *lmalloc(size_t size)
{
return _malloc(size, HEAP_LOWMEM, MALLOC_CORE);