[syslinux:pathbased] core: fix lowmem malloc

syslinux-bot for H. Peter Anvin hpa at zytor.com
Wed Feb 24 14:21:20 PST 2010


Commit-ID:  3ae1da98a68d2f719ce17766550f7e9682ba8ae7
Gitweb:     http://syslinux.zytor.com/commit/3ae1da98a68d2f719ce17766550f7e9682ba8ae7
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Wed, 24 Feb 2010 14:16:15 -0800
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Wed, 24 Feb 2010 14:16:15 -0800

core: fix lowmem malloc

a) initialize *all* the head nodes
b) the lowmem heap needs to be paragraph (16 byte) aligned
c) use a dedicated tag value for headnodes.  The type code should be
   removed and replaced with special tag values for head node and
   free.
d) for libcom32 code called from the core, do NOT present a
   usable bounce buffer; we should only ever use lmalloc/lfree.

Signed-off-by: H. Peter Anvin <hpa at zytor.com>


---
 core/com32.inc    |    5 ++---
 core/mem/init.c   |    2 ++
 core/mem/malloc.h |    1 +
 core/syslinux.ld  |    1 +
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/core/com32.inc b/core/com32.inc
index 5d5cac7..6ef0784 100644
--- a/core/com32.inc
+++ b/core/com32.inc
@@ -126,10 +126,9 @@ __com32:
 		dd 8				; Argument count
 		dd 0				; No command line
 		dd core_intcall			; Intcall entry point
-		dd core_xfer_buf		; Bounce buffer address
-		dd 1 << 16			; 64K bounce buffer
+		dd 0				; Bounce buffer address
+		dd 0				; 64K bounce buffer
 		dd core_farcall			; Farcall entry point
 		dd core_cfarcall		; Cfarcall entry point
 HighMemSize	dd 0				; End of memory pointer (bytes)
 		dd pm_api_vector		; Protected mode functions
-
diff --git a/core/mem/init.c b/core/mem/init.c
index 03f1509..0fb5377 100644
--- a/core/mem/init.c
+++ b/core/mem/init.c
@@ -20,6 +20,8 @@ void mem_init(void)
     for (i = 0 ; i < NHEAP ; i++) {
 	fp->a.next = fp->a.prev = fp->next_free = fp->prev_free = fp;
 	fp->a.attrs = ARENA_TYPE_HEAD | (i << ARENA_HEAP_POS);
+	fp->a.tag = MALLOC_HEAD;
+	fp++;
     }
 
     /* Initialize the main heap */
diff --git a/core/mem/malloc.h b/core/mem/malloc.h
index 889dfc5..b8ec44d 100644
--- a/core/mem/malloc.h
+++ b/core/mem/malloc.h
@@ -15,6 +15,7 @@
 typedef size_t malloc_tag_t;
 enum malloc_owner {
     MALLOC_FREE,
+    MALLOC_HEAD,
     MALLOC_CORE,
     MALLOC_MODULE,
 };
diff --git a/core/syslinux.ld b/core/syslinux.ld
index fd5c5fe..07bd8d4 100644
--- a/core/syslinux.ld
+++ b/core/syslinux.ld
@@ -243,6 +243,7 @@ SECTIONS
 	__high_clear_dwords = (__high_clear_len + 3) >> 2;
 
 	/* Start of the lowmem heap */
+	. = ALIGN(16);
 	__lowmem_heap = .;
 
 	/*



More information about the Syslinux-commits mailing list