# HG changeset patch # User John Tsiombikas # Date 1302322446 -10800 # Node ID 387078ef5c0d0abe04b0e8236bd0a606334ea03a # Parent 9939a6d7a45a1ea08d4094cffa302a1890c726d8 fixes here and there diff -r 9939a6d7a45a -r 387078ef5c0d src/main.c --- a/src/main.c Wed Apr 06 07:42:44 2011 +0300 +++ b/src/main.c Sat Apr 09 07:14:06 2011 +0300 @@ -57,7 +57,10 @@ /* silence the blasted timer interrupt */ interrupt(32, do_nothing); - init_vm(mbinf); + /* initialize the physical memory manager */ + init_mem(mbinf); + /* initialize paging and the virtual memory manager */ + init_vm(); dbg_print_vm(MEM_USER); dbg_print_vm(MEM_KERNEL); diff -r 9939a6d7a45a -r 387078ef5c0d src/vm-asm.S --- a/src/vm-asm.S Wed Apr 06 07:42:44 2011 +0300 +++ b/src/vm-asm.S Sat Apr 09 07:14:06 2011 +0300 @@ -1,6 +1,6 @@ .text /* enable_paging(void) - * sets the cr0 bit 31 which enables page translation */ + * sets bit 31 of cr0 which enables page translation */ .globl enable_paging enable_paging: movl %cr0, %eax @@ -9,7 +9,7 @@ ret /* disable_paging(void) - * clears the cr0 bit 31 */ + * clears bit 31 of cr0 which disables page translation */ .globl disable_paging disable_paging: movl %cr0, %eax @@ -17,6 +17,8 @@ movl %eax, %cr0 ret +/* get_paging_status(void) + * returns 0 if paging is disabled or 1 if it's enabled */ .globl get_paging_status get_paging_status: movl %cr0, %eax diff -r 9939a6d7a45a -r 387078ef5c0d src/vm.c --- a/src/vm.c Wed Apr 06 07:42:44 2011 +0300 +++ b/src/vm.c Sat Apr 09 07:14:06 2011 +0300 @@ -53,13 +53,10 @@ static struct page_range first_node; -void init_vm(struct mboot_info *mb) +void init_vm(void) { uint32_t idmap_end; - /* initialize the physical memory map and allocator */ - init_mem(mb); - /* setup the page tables */ pgdir = (uint32_t*)alloc_phys_page(); memset(pgdir, 0, PGSIZE); @@ -83,12 +80,12 @@ node_pool = 0; first_node.start = ADDR_TO_PAGE(KMEM_START); - first_node.end = PAGE_COUNT; + first_node.end = ADDR_TO_PAGE(PGTBL_BASE); first_node.next = 0; pglist[MEM_KERNEL] = &first_node; pglist[MEM_USER] = alloc_node(); - pglist[MEM_USER]->start = 0; + pglist[MEM_USER]->start = ADDR_TO_PAGE(idmap_end); pglist[MEM_USER]->end = ADDR_TO_PAGE(KMEM_START); pglist[MEM_USER]->next = 0; } @@ -149,7 +146,7 @@ if(!(pgdir[diridx] & PG_PRESENT)) { goto err; } - pgtbl = (uint32_t*)(pgdir[diridx] & ADDR_PGENT_MASK); + pgtbl = PGTBL(diridx); if(!(pgtbl[pgidx] & PG_PRESENT)) { goto err; @@ -168,18 +165,9 @@ int map_page_range(int vpg_start, int pgcount, int ppg_start, unsigned int attr) { int i, phys_pg; - uint32_t paddr; for(i=0; i