From 5c7d64b981b1797b50496ef86b2a916bacbcf8f8 Mon Sep 17 00:00:00 2001 From: Cristiano Giuffrida Date: Fri, 25 Jun 2010 12:48:56 +0000 Subject: [PATCH] No malloc() in VM. --- servers/vm/arch/i386/pagetable.c | 22 ++++++---------------- servers/vm/utility.c | 18 ------------------ 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/servers/vm/arch/i386/pagetable.c b/servers/vm/arch/i386/pagetable.c index 939322b41..8c3d7c3a8 100644 --- a/servers/vm/arch/i386/pagetable.c +++ b/servers/vm/arch/i386/pagetable.c @@ -88,6 +88,8 @@ int kernmappings = 0; /* Page table that contains pointers to all page directories. */ u32_t page_directories_phys, *page_directories = NULL; +PRIVATE char static_sparepages[I386_PAGE_SIZE*SPAREPAGES + I386_PAGE_SIZE]; + #if SANITYCHECKS /*===========================================================================* * pt_sanitycheck * @@ -131,21 +133,6 @@ PUBLIC void pt_sanitycheck(pt_t *pt, char *file, int line) } #endif -/*===========================================================================* - * aalloc * - *===========================================================================*/ -PRIVATE void *aalloc(size_t bytes) -{ -/* Page-aligned malloc(). only used if vm_allocpage can't be used. */ - u32_t b; - - b = (u32_t) malloc(I386_PAGE_SIZE + bytes); - if(!b) panic("aalloc: out of memory: %d", bytes); - b += I386_PAGE_SIZE - (b % I386_PAGE_SIZE); - - return (void *) b; -} - /*===========================================================================* * findhole * *===========================================================================*/ @@ -727,12 +714,15 @@ PUBLIC void pt_init(phys_bytes usedlimit) struct vm_ep_data ep_data; vir_bytes sparepages_mem; phys_bytes sparepages_ph; + vir_bytes ptr; /* Shorthand. */ newpt = &vmprocess->vm_pt; /* Get ourselves spare pages. */ - if(!(sparepages_mem = (vir_bytes) aalloc(I386_PAGE_SIZE*SPAREPAGES))) + ptr = (vir_bytes) static_sparepages; + ptr += I386_PAGE_SIZE - (ptr % I386_PAGE_SIZE); + if(!(sparepages_mem = ptr)) panic("pt_init: aalloc for spare failed"); if((r=sys_umap(SELF, VM_D, (vir_bytes) sparepages_mem, I386_PAGE_SIZE*SPAREPAGES, &sparepages_ph)) != OK) diff --git a/servers/vm/utility.c b/servers/vm/utility.c index 9aacae714..40147f638 100644 --- a/servers/vm/utility.c +++ b/servers/vm/utility.c @@ -4,7 +4,6 @@ #define _SYSTEM 1 #define _MINIX 1 /* To get the brk() prototype (as _brk()). */ -#define brk _brk /* Our brk() must redefine _brk(). */ #include #include @@ -151,23 +150,6 @@ vir_bytes *sp; /* put stack pointer here */ return(OK); } -/*===========================================================================* - * _brk * - *===========================================================================*/ -extern char *_brksize; -PUBLIC int brk(brk_addr) -char *brk_addr; -{ - int r; - struct vmproc *vmm = &vmproc[VM_PROC_NR]; - -/* VM wants to call brk() itself. */ - if((r=real_brk(vmm, (vir_bytes) brk_addr)) != OK) - panic("VM: brk() on myself failed"); - _brksize = brk_addr; - return 0; -} - /*===========================================================================* * do_info * *===========================================================================*/ -- 2.44.0