core: add new __lowmem macro to allocate a static lowmem buffer
authorH. Peter Anvin <hpa@zytor.com>
Tue, 2 Jun 2009 23:44:41 +0000 (16:44 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Tue, 2 Jun 2009 23:44:41 +0000 (16:44 -0700)
Add a new __lowmem macro that can be applied to an uninitialized
static (or global) object, which allocates it in a new .lowmem section
allocated below the 1 MB boundary.  Keep in mind that low memory is
precious!

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
core/include/core.h
core/init.inc
core/layout.inc
core/syslinux.ld

index 0975ebf..e61bf99 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef CORE_H
 #define CORE_H
 
+#include <klibc/compiler.h>
 #include <com32.h>
 
 extern char core_xfer_buf[65536];
@@ -12,4 +13,6 @@ int __cdecl core_cfarcall(uint32_t, const void *, uint32_t);
 
 void call16(void (*)(void), const com32sys_t *, com32sys_t *);
 
+#define __lowmem __attribute((nocommon,section(".lowmem")))
+
 #endif /* CORE_H */
index 809fa8e..ec8c7b3 100644 (file)
@@ -60,7 +60,6 @@ common_init:
 ; The code to decompress the PM code and initialize other segments.
 ;
                extern _lzo1x_decompress_asm_fast
-               extern __uibss_auxseg_dwords
 
                section .textnr
                bits 32
@@ -83,8 +82,8 @@ pm_decompress:
                mov edi,__bss16_start
                mov ecx,__bss16_dwords
                rep stosd
-               mov edi,__uibss_start
-               mov ecx,__uibss_auxseg_dwords
+               mov edi,__high_clear_start      ; .uibss, .auxseg, .lowmem
+               mov ecx,__high_clear_dwords
                rep stosd
 
                ret
index ec011f3..7223683 100644 (file)
@@ -79,6 +79,8 @@ RBFG_brainfuck:       resb 2048               ; Bigger than an Ethernet packet...
                SECINFO replacestub
 
                SECINFO pm_code
+               SECINFO high_clear
+
                extern __bss_start, __bss_end, __bss_len, __bss_dwords
 
                extern free_high_memory
index eb0e411..b931ed2 100644 (file)
@@ -148,6 +148,8 @@ SECTIONS
        . = ALIGN(16);
        __pm_code_lma = .;
 
+       __high_clear_start = .;
+
        . = ALIGN(512);
        .adv (NOLOAD) : {
                __adv_start = .;
@@ -185,9 +187,22 @@ SECTIONS
        __auxseg_len = __auxseg_end - __auxseg_start;
        __auxseg_dwords = (__auxseg_len + 3) >> 2;
        aux_seg = __auxseg_start >> 4;
-       
-       __uibss_auxseg_len = __auxseg_end - __uibss_start;
-       __uibss_auxseg_dwords = (__uibss_auxseg_len + 3) >> 2;
+
+       /*
+        * Used to allocate lowmem buffers from 32-bit code
+        */
+       .lowmem (NOLOAD) : {
+               __lowmem_start = .;
+               *(.lowmem)
+               __lowmem_end = .;
+       }
+       __lowmem_len = __lowmem_end - __lowmem_start;
+       __lowmem_dwords = (__lowmem_len + 3) >> 2;
+
+       __high_clear_end = .;
+
+       __high_clear_len = __high_clear_end - __high_clear_start;
+       __high_clear_dwords = (__high_clear_len + 3) >> 2;
 
        /*
         * 32-bit code.  This is a hack for the moment due to the