[syslinux:elflink] June 22: new mem_init works
syslinux-bot for Feng Tang
feng.tang at intel.com
Thu Aug 12 21:03:20 PDT 2010
Commit-ID: 3df0e180cfa2161114d476a651085276748d7f6f
Gitweb: http://syslinux.zytor.com/commit/3df0e180cfa2161114d476a651085276748d7f6f
Author: Feng Tang <feng.tang at intel.com>
AuthorDate: Tue, 22 Jun 2010 17:19:45 +0800
Committer: Feng Tang <feng.tang at intel.com>
CommitDate: Tue, 20 Jul 2010 11:10:04 +0800
June 22: new mem_init works
---
core/configinit.inc | 7 ++--
core/extern.inc | 2 +
core/fs/fs.c | 4 ++-
core/highmem.inc | 1 +
core/init.inc | 7 ++++
core/mem/init.c | 79 ++++++++++++++++++++++++++++++++++++++-------------
6 files changed, 75 insertions(+), 25 deletions(-)
diff --git a/core/configinit.inc b/core/configinit.inc
index 915e77f..296a4d7 100644
--- a/core/configinit.inc
+++ b/core/configinit.inc
@@ -20,7 +20,7 @@
section .text16
reset_config:
- call highmemsize
+ ;call highmemsize
; Initialize the .config section
xor eax,eax
@@ -45,7 +45,6 @@ mkkeymap: stosb
inc al
loop mkkeymap
- mov eax,[HighMemSize]
- mov [VKernelEnd],eax
-
+ ;mov eax,[HighMemSize]
+ ;mov [VKernelEnd],eax
ret
diff --git a/core/extern.inc b/core/extern.inc
index 6bbc78c..5cd5617 100644
--- a/core/extern.inc
+++ b/core/extern.inc
@@ -29,6 +29,8 @@
extern printf_init
+ extern mem_init
+
; fs.c
extern fs_init, pm_searchdir, getfssec, getfsbytes
extern pm_mangle_name, load_config
diff --git a/core/fs/fs.c b/core/fs/fs.c
index dfc24bc..cb2f206 100644
--- a/core/fs/fs.c
+++ b/core/fs/fs.c
@@ -409,8 +409,10 @@ void fs_init(com32sys_t *regs)
/* ops is a ptr list for several fs_ops */
const struct fs_ops **ops = (const struct fs_ops **)regs->eax.l;
+ mp("enter");
+
/* Initialize malloc() */
- mem_init();
+ //mem_init();
/* Default name for the root directory */
fs.cwd_name[0] = '/';
diff --git a/core/highmem.inc b/core/highmem.inc
index ea386ff..05b41f2 100644
--- a/core/highmem.inc
+++ b/core/highmem.inc
@@ -24,6 +24,7 @@
; HighMemSize. All registers are preserved.
;
highmemsize:
+ ret
push es
pushfd
pushad
diff --git a/core/init.inc b/core/init.inc
index 6c57387..cce4327 100644
--- a/core/init.inc
+++ b/core/init.inc
@@ -50,6 +50,13 @@ common_init:
pm_call printf_init
;
+; Inite the memmory subsystem
+;
+ pm_call mem_init
+ mov eax,[HighMemSize]
+ mov [VKernelEnd],eax
+
+;
; CPU-dependent initialization and related checks.
;
check_escapes:
diff --git a/core/mem/init.c b/core/mem/init.c
index cf45104..4e08d10 100644
--- a/core/mem/init.c
+++ b/core/mem/init.c
@@ -4,39 +4,78 @@
#include "malloc.h"
#include <stdio.h>
+#include <syslinux/memscan.h>
struct free_arena_header __core_malloc_head[NHEAP];
-//static __hugebss char main_heap[128 << 10];
+static __hugebss char main_heap[128 << 10];
/* change it to 32M */
-static __hugebss char main_heap[32 << 20];
+//static __hugebss char main_heap[32 << 20];
extern char __lowmem_heap[];
+extern char free_high_memory[];
+
+#define E820_MEM_MAX 0xfff00000 /* 4 GB - 1 MB */
+int scan_highmem_area(void *data, addr_t start, addr_t len, bool is_ram)
+{
+ struct free_arena_header *fp;
+ addr_t end;
+
+ mp("start = %x, len = %x, is_ram = %d\n", start, len, is_ram);
+
+ if (start < 0x100000 || start > E820_MEM_MAX
+ || !is_ram)
+ return 0;
+
+ if (start < __com32.cs_memsize)
+ start = __com32.cs_memsize;
+ if (len > E820_MEM_MAX - start)
+ len = E820_MEM_MAX - start;
+ end = start + len;
+
+ if (len >= 2 * sizeof(struct arena_header)) {
+ fp = (struct free_arena_header *)start;
+ fp->a.attrs = ARENA_TYPE_USED | (HEAP_MAIN << ARENA_HEAP_POS);
+ ARENA_SIZE_SET(fp->a.attrs, len);
+ mp("will inject a block start:0x%x size 0x%x", start, len);
+ __inject_free_block(fp);
+ }
+
+ __com32.cs_memsize = start + len; /* update the HighMemSize */
+ return 0;
+}
void mem_init(void)
{
- struct free_arena_header *fp;
- int i;
- uint16_t *bios_free_mem = (uint16_t *)0x413;
+ struct free_arena_header *fp;
+ int i;
+ uint16_t *bios_free_mem = (uint16_t *)0x413;
+
+ mp("enter");
- /* Initialize the head nodes */
- fp = &__core_malloc_head[0];
- for (i = 0 ; i < NHEAP ; i++) {
+ /* Initialize the head nodes */
+ fp = &__core_malloc_head[0];
+ 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 */
- fp = (struct free_arena_header *)main_heap;
- fp->a.attrs = ARENA_TYPE_USED | (HEAP_MAIN << ARENA_HEAP_POS);
- 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);
- ARENA_SIZE_SET(fp->a.attrs, (*bios_free_mem << 10) - (uintptr_t)fp);
- __inject_free_block(fp);
+ /* Initialize the lowmem heap */
+ fp = (struct free_arena_header *)__lowmem_heap;
+ fp->a.attrs = ARENA_TYPE_USED | (HEAP_LOWMEM << ARENA_HEAP_POS);
+ ARENA_SIZE_SET(fp->a.attrs, (*bios_free_mem << 10) - (uintptr_t)fp);
+ __inject_free_block(fp);
+
+ /* Initialize the main heap */
+ /*
+ fp = (struct free_arena_header *)main_heap;
+ fp->a.attrs = ARENA_TYPE_USED | (HEAP_MAIN << ARENA_HEAP_POS);
+ ARENA_SIZE_SET(fp->a.attrs, sizeof main_heap);
+ __inject_free_block(fp);
+ */
+
+ __com32.cs_memsize = free_high_memory;
+ syslinux_scan_memory(scan_highmem_area, NULL);
}
More information about the Syslinux-commits
mailing list