Hack to provide kernel with space for page table.
This commit is contained in:
parent
9bee3f4b08
commit
42e1dad99c
@ -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
|
||||
|
@ -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<NR_MEMS; i++)
|
||||
{
|
||||
if (mem_chunks[i].size == 0)
|
||||
continue;
|
||||
if (mem_chunks[i].base + mem_chunks[i].size > 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; i++)
|
||||
{
|
||||
if (mem_chunks[i].size <= clicks)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
if (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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user