kern
changeset 76:0fe6eef16335
holy fuck, copy_on_write didn't actually do the copy!!!!
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 05 Nov 2011 04:53:46 +0200 |
parents | 8b21fe04ba2c |
children | a6513dc35f04 |
files | src/main.c src/vm.c |
diffstat | 2 files changed, 13 insertions(+), 4 deletions(-) [+] |
line diff
1.1 --- a/src/main.c Sat Oct 15 08:07:09 2011 +0300 1.2 +++ b/src/main.c Sat Nov 05 04:53:46 2011 +0200 1.3 @@ -5,6 +5,7 @@ 1.4 #include "asmops.h" 1.5 #include "segm.h" 1.6 #include "intr.h" 1.7 +#include "ata.h" 1.8 #include "rtc.h" 1.9 #include "timer.h" 1.10 #include "mem.h" 1.11 @@ -35,6 +36,9 @@ 1.12 /* initialize paging and the virtual memory manager */ 1.13 init_vm(); 1.14 1.15 + /* initialize ATA disks */ 1.16 + init_ata(); 1.17 + 1.18 /* initialize the timer and RTC */ 1.19 init_timer(); 1.20 init_rtc();
2.1 --- a/src/vm.c Sat Oct 15 08:07:09 2011 +0300 2.2 +++ b/src/vm.c Sat Nov 05 04:53:46 2011 +0200 2.3 @@ -93,7 +93,7 @@ 2.4 pglist[MEM_USER]->end = kmem_start_pg; 2.5 pglist[MEM_USER]->next = 0; 2.6 2.7 - /* temporaroly map something into every 1024th page of the kernel address 2.8 + /* temporarily map something into every 1024th page of the kernel address 2.9 * space to force pre-allocation of all the kernel page-tables 2.10 */ 2.11 for(i=kmem_start_pg; i<pgtbl_base_pg; i+=1024) { 2.12 @@ -607,7 +607,7 @@ 2.13 /* copy-on-write handler, called from pgfault above */ 2.14 static int copy_on_write(struct vm_page *page) 2.15 { 2.16 - uint32_t newphys; 2.17 + int tmpvpg; 2.18 struct vm_page *newpage; 2.19 struct rbnode *vmnode; 2.20 struct process *p = get_current_proc(); 2.21 @@ -631,14 +631,19 @@ 2.22 newpage->vpage = page->vpage; 2.23 newpage->flags = page->flags; 2.24 2.25 - if(!(newphys = alloc_phys_page())) { 2.26 + if(!(tmpvpg = pgalloc(1, MEM_KERNEL))) { 2.27 printf("copy_on_write: failed to allocate physical page\n"); 2.28 /* XXX proper action: SIGSEGV */ 2.29 return -1; 2.30 } 2.31 - newpage->ppage = ADDR_TO_PAGE(newphys); 2.32 + newpage->ppage = virt_to_phys_page(tmpvpg); 2.33 newpage->nref = 1; 2.34 2.35 + /* do the copy */ 2.36 + memcpy((void*)PAGE_TO_ADDR(tmpvpg), (void*)PAGE_TO_ADDR(page->vpage), PGSIZE); 2.37 + unmap_page(tmpvpg); 2.38 + pgfree(tmpvpg, 1); 2.39 + 2.40 /* set the new vm_page in the process vmmap */ 2.41 vmnode = rb_findi(&p->vmmap, newpage->vpage); 2.42 assert(vmnode && vmnode->data == page); /* shouldn't be able to fail */