aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFeng Tang <feng.tang@intel.com>2010-06-22 17:19:45 +0800
committerFeng Tang <feng.tang@intel.com>2010-07-20 11:10:04 +0800
commit3df0e180cfa2161114d476a651085276748d7f6f (patch)
treecc639a06f491b61e88753dfc05ebcbba67e3df4e
parenta6261fd6112c54f994f6e7a3f3eca606cc2fdf8d (diff)
downloadsyslinux-3df0e180cfa2161114d476a651085276748d7f6f.tar.gz
syslinux-3df0e180cfa2161114d476a651085276748d7f6f.tar.xz
syslinux-3df0e180cfa2161114d476a651085276748d7f6f.zip
June 22: new mem_init works
-rw-r--r--core/configinit.inc7
-rw-r--r--core/extern.inc2
-rw-r--r--core/fs/fs.c4
-rw-r--r--core/highmem.inc1
-rw-r--r--core/init.inc7
-rw-r--r--core/mem/init.c79
6 files changed, 75 insertions, 25 deletions
diff --git a/core/configinit.inc b/core/configinit.inc
index 915e77f7..296a4d7a 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 6bbc78cf..5cd56170 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 dfc24bcb..cb2f2066 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 ea386ffc..05b41f22 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 6c57387f..cce4327c 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 cf451048..4e08d109 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);
}