core: fix lowmem malloc
authorH. Peter Anvin <hpa@zytor.com>
Wed, 24 Feb 2010 22:16:15 +0000 (14:16 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Wed, 24 Feb 2010 22:16:15 +0000 (14:16 -0800)
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@zytor.com>
core/com32.inc
core/mem/init.c
core/mem/malloc.h
core/syslinux.ld

index 5d5cac7..6ef0784 100644 (file)
@@ -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
-
index 03f1509..0fb5377 100644 (file)
@@ -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 */
index 889dfc5..b8ec44d 100644 (file)
@@ -15,6 +15,7 @@
 typedef size_t malloc_tag_t;
 enum malloc_owner {
     MALLOC_FREE,
+    MALLOC_HEAD,
     MALLOC_CORE,
     MALLOC_MODULE,
 };
index fd5c5fe..07bd8d4 100644 (file)
@@ -243,6 +243,7 @@ SECTIONS
        __high_clear_dwords = (__high_clear_len + 3) >> 2;
 
        /* Start of the lowmem heap */
+       . = ALIGN(16);
        __lowmem_heap = .;
 
        /*