;
; Danger, Will Robinson: it's not clear the use of
; core_xfer_buf is safe here.
- global __entry_esp, __com32
+ global __entry_esp, __com32, HighMemSize
alignz 4
__entry_esp:
dd 0 ; Dummy to avoid _exit issues
/* ops is a ptr list for several fs_ops */
const struct fs_ops **ops = (const struct fs_ops **)regs->eax.l;
- /* Initialize malloc() */
- mem_init();
-
/* Default name for the root directory */
fs.cwd_name[0] = '/';
struct free_arena_header __malloc_head[NHEAP];
-static __hugebss char main_heap[128 << 10];
extern char __lowmem_heap[];
+size_t __bss16 MallocStart;
+extern size_t HighMemSize;
void mem_init(void)
{
struct free_arena_header *fp;
int i;
uint16_t *bios_free_mem = (uint16_t *)0x413;
+ size_t main_heap_size;
/* Initialize the head nodes */
fp++;
}
- /* Initialize the main heap */
- fp = (struct free_arena_header *)main_heap;
+ /* Initialize the main heap; give it 1/16 of high memory */
+ main_heap_size = (HighMemSize - 0x100000) >> 4;
+ MallocStart = (HighMemSize - main_heap_size) & ~4095;
+ main_heap_size = (HighMemSize - MallocStart) & ARENA_SIZE_MASK;
+
+ fp = (struct free_arena_header *)MallocStart;
fp->a.attrs = ARENA_TYPE_USED | (HEAP_MAIN << ARENA_HEAP_POS);
- ARENA_SIZE_SET(fp->a.attrs, sizeof main_heap);
+ ARENA_SIZE_SET(fp->a.attrs, main_heap_size);
__inject_free_block(fp);
/* Initialize the lowmem heap */
mov cx,di
sub cx,command_line
call crlf
- mov esi,[HighMemSize] ; Start from top of memory
+ mov esi,[MallocStart] ; Start from top of memory
.scan:
cmp esi,[VKernelEnd]
jbe .not_vk
; Now check if it is a "virtual kernel"
;
vk_check:
- mov esi,[HighMemSize] ; Start from top of memory
+ mov esi,[MallocStart] ; Start from top of memory
.scan:
cmp esi,[VKernelEnd]
jbe .not_vk