From: Philip Homburg Date: Fri, 30 Sep 2005 12:56:00 +0000 (+0000) Subject: Hack to provide kernel with space for page table. X-Git-Tag: v3.1.2a~684 X-Git-Url: http://zhaoyanbai.com/repos/man.dnssec-dsfromkey.html?a=commitdiff_plain;h=42e1dad99c6e5c6a645540d3ef027464f51e9bdb;p=minix.git Hack to provide kernel with space for page table. --- diff --git a/servers/pm/alloc.c b/servers/pm/alloc.c index 391e1f823..edb8e8fcf 100644 --- a/servers/pm/alloc.c +++ b/servers/pm/alloc.c @@ -227,6 +227,8 @@ phys_clicks *free; /* memory size summaries */ *free = 0; for (i=NR_MEMS-1; i>=0; i--) { if (chunks[i].size > 0) { + printf("mem_init: adding (clicks) 0x%x @ 0x%x\n", + chunks[i].size, chunks[i].base); free_mem(chunks[i].base, chunks[i].size); *free += chunks[i].size; #if ENABLE_SWAP diff --git a/servers/pm/main.c b/servers/pm/main.c index 0225c1211..04e98843b 100644 --- a/servers/pm/main.c +++ b/servers/pm/main.c @@ -32,6 +32,7 @@ FORWARD _PROTOTYPE( int get_nice_value, (int queue) ); FORWARD _PROTOTYPE( void get_mem_chunks, (struct memory *mem_chunks) ); FORWARD _PROTOTYPE( void patch_mem_chunks, (struct memory *mem_chunks, struct mem_map *map_ptr) ); +FORWARD _PROTOTYPE( void do_x86_vm, (struct memory mem_chunks[NR_MEMS]) ); #define click_to_round_k(n) \ ((unsigned) ((((unsigned long) (n) << CLICK_SHIFT) + 512) / 1024)) @@ -259,6 +260,9 @@ PRIVATE void pm_init() } #endif /* ENABLE_BOOTDEV */ + /* Withhold some memory from x86 VM */ + do_x86_vm(mem_chunks); + /* Initialize tables to all physical memory and print memory information. */ printf("Physical memory:"); mem_init(mem_chunks, &free_clicks); @@ -380,3 +384,58 @@ struct mem_map *map_ptr; /* memory to remove */ } } +#define PAGE_SIZE 4096 +#define PAGE_TABLE_COVER (1024*PAGE_SIZE) +/*=========================================================================* + * do_x86_vm * + *=========================================================================*/ +PRIVATE void do_x86_vm(mem_chunks) +struct memory mem_chunks[NR_MEMS]; +{ + phys_bytes high, bytes; + phys_clicks clicks, base_click; + unsigned pages; + int i, r; + + /* Compute the highest memory location */ + high= 0; + for (i= 0; i high) + high= mem_chunks[i].base + mem_chunks[i].size; + } + + high <<= CLICK_SHIFT; + printf("do_x86_vm: found high 0x%x\n", high); + + /* The number of pages we need is one for the page directory, enough + * page tables to cover the memory, and one page for alignement. + */ + pages= 1 + (high + PAGE_TABLE_COVER-1)/PAGE_TABLE_COVER + 1; + bytes= pages*PAGE_SIZE; + clicks= (bytes + CLICK_SIZE-1) >> CLICK_SHIFT; + + printf("do_x86_vm: need %d pages\n", pages); + printf("do_x86_vm: need %d bytes\n", bytes); + printf("do_x86_vm: need %d clicks\n", clicks); + + for (i= 0; i= NR_MEMS) + panic("PM", "not enough memory for VM page tables?", NO_NUM); + base_click= mem_chunks[i].base; + mem_chunks[i].base += clicks; + mem_chunks[i].size -= clicks; + + printf("do_x86_vm: using 0x%x clicks @ 0x%x\n", clicks, base_click); + r= sys_vm_setbuf(base_click << CLICK_SHIFT, clicks << CLICK_SHIFT, + high); + if (r != 0) + printf("do_x86_vm: sys_vm_setbuf failed: %d\n", r); +}