diff --git a/sys/vmm/createvirtualspace.c b/sys/vmm/createvirtualspace.c index 4469f0d..dc1c20f 100644 --- a/sys/vmm/createvirtualspace.c +++ b/sys/vmm/createvirtualspace.c @@ -91,7 +91,7 @@ adjustCowCounter(((uint32_t) parentPageTable[1022] & 0xFFFFF000), 2); - vmm_unmapPage((uint32_t) newPageTable, 1); + vmm_unmapPage((uint32_t) newPageTable, 1); /* diff --git a/sys/vmm/getfreevirtualpage.c b/sys/vmm/getfreevirtualpage.c index 743a7f7..7af505a 100644 --- a/sys/vmm/getfreevirtualpage.c +++ b/sys/vmm/getfreevirtualpage.c @@ -47,33 +47,28 @@ ************************************************************************/ void *vmm_getFreeVirtualPage(pidType pid, int count, int type) { int y = 0, counter = 0, pdI = 0x0, ptI = 0x0; - uint32_t *pageTableSrc = 0x0; - uint32_t *pageDir = 0x0; + uint32_t *pageDirectory = 0x0; + uint32_t *pageTable = 0x0; uint32_t start_page = 0x0; spinLock(&fvpSpinLock); - pageDir = (uInt32 *) PD_BASE_ADDR; + pageDirectory = (uint32_t *) PD_BASE_ADDR; /* Lets Search For A Free Page */ if (_current->oInfo.vmStart <= 0x100000) kpanic("Invalid vmStart\n"); - //MrOlsen kprintf("type: %i ", type); - /* Get Our Starting Address */ if (type == VM_THRD) { start_page = (uint32_t) (_current->td.vm_daddr + ctob(_current->td.vm_dsize)); } else if (type == VM_TASK) { - //kprintf("vmStart"); start_page = _current->oInfo.vmStart; } else K_PANIC("Invalid Type"); - //kprintf( "Entering MMAP: Type: %i, Returning %i Pages At Address: 0x%X\n", type, count, start_page ); - /* * * I Need To Write Some Function For Space That Is Returned Maybe A Malloc Type Map @@ -88,23 +83,16 @@ pdI = ((start_page + (counter * 0x1000)) / 0x400000); keepMapping: - //kprintf("PAGE IS"); - /* If Page Directory Is Not Yet Allocated Allocate It */ - if ((pageDir[pdI] & PAGE_PRESENT) != PAGE_PRESENT) { - //kprintf("PAGE NOT %i,", __LINE__); - pageDir[pdI] = (uInt32) vmm_findFreePage(_current->id) | PAGE_DEFAULT; - //kprintf("PAGE NOT %i,", __LINE__); - //kprintf("PAGE NOT %i,", __LINE__); + if ((pageDirectory[pdI] & PAGE_PRESENT) != PAGE_PRESENT) { /* If Page Directory Is Not Yet Allocated Allocate It */ - /* Also Add It To Virtual Space So We Can Make Changes Later */ - pageTableSrc = (uint32_t *) (PT_BASE_ADDR + (PD_INDEX( PT_BASE_ADDR ) * 0x1000)); /* Table that maps that 4b */ - pageTableSrc[pdI] = (pageDir[pdI] & 0xFFFFF000) | PAGE_DEFAULT; /* Is This Why Page Needs To Be User As Well? */ - pageTableSrc = (uint32_t *) (PT_BASE_ADDR + (pdI * 0x1000)); + pageDirectory[pdI] = (uint32_t) vmm_findFreePage(_current->id) | PAGE_DEFAULT; + /* Also Add It To Virtual Space So We Can Make Changes Later */ + pageTable = (uint32_t *) (PT_BASE_ADDR + (PD_INDEX( PT_BASE_ADDR ) * 0x1000)); /* Table that maps that 4MB */ - - //kprintf("PAGE NOT %i,", __LINE__); + pageTable[pdI] = (pageDirectory[pdI] & 0xFFFFF000) | PAGE_DEFAULT; + pageTable = (uint32_t *) (PT_BASE_ADDR + (pdI * 0x1000)); /* Reload Page Directory */ asm( @@ -112,33 +100,24 @@ "movl %eax,%cr3\n" ); - //kprintf("PAGE NOT %i,", __LINE__); - pageTableSrc = (uInt32 *) (PT_BASE_ADDR + (0x1000 * pdI)); - - //kprintf("PAGE NOT %i,", __LINE__); - /* Initialize The New Page Table To Prevent Dirty Bits */ - for (y = 0x0; y < PD_ENTRIES; y++) { - pageTableSrc[y] = (uInt32) 0x0; - } - //kprintf("PAGE NOT %i,", __LINE__); - + bzero(pageTable, PAGE_SIZE); } else { - pageTableSrc = (uInt32 *) (PT_BASE_ADDR + (0x1000 * pdI)); + pageTable = (uint32_y *) (PT_BASE_ADDR + (0x1000 * pdI)); } -//kprintf("HERE?"); ptI = ((start_page - (pdI * 0x400000)) / 0x1000); for (y = ptI; y < 1024 && counter < count; y++) { /* Loop Through The Page Table Find An UnAllocated Page */ - if ((pageTableSrc[y] & PAGE_COW) == PAGE_COW) { + if ((pageTable[y] & PAGE_COW) == PAGE_COW) { kprintf("COW PAGE NOT CLEANED!"); } - else if ((uInt32) pageTableSrc[y] == (uInt32) 0x0) { + else if ((uint32_t) pageTable[y] == (uint32_t) 0x0) { if ((vmm_remapPage((uInt32) vmm_findFreePage(pid), ((pdI * (1024 * 4096)) + (y * 4096)), PAGE_DEFAULT, pid)) == 0x0) kpanic("vmmRemapPage: getFreeVirtualPage-1: (%i)[0x%X]\n", type, ((pdI * (1024 * 4096)) + (y * 4096))); + vmm_clearVirtualPage((uInt32) ((pdI * (1024 * 4096)) + (y * 4096))); } else { @@ -146,12 +125,10 @@ K_PANIC("UHM HOW DO WE HAVE AN ALLOCATED PAGE HERE!!\n"); } - //kprintf("[0x%X:%i:%i:%i]", ((pdI * (1024 * 4096)) + (y * 4096)), y, counter, count); counter++; } if (counter < count) { - //kprintf("Need More Pages!"); start_page += (0x1000 * counter); pdI = ((start_page + (counter * 0x1000)) / 0x400000); goto keepMapping; @@ -160,22 +137,11 @@ if (type == VM_THRD) { _current->td.vm_dsize += btoc(count * 0x1000); - //kprintf( "vm_dsize: [0x%X]][0x%X]\n", ctob( _current->td.vm_dsize ), _current->td.vm_dsize ); } else if (type == VM_TASK) _current->oInfo.vmStart += (count * 0x1000); - /* - * MMAP Return - */ - //kprintf( "mmap: [0x%x]\n", start_page ); - /* If No Free Page Was Found Return NULL */ spinUnlock(&fvpSpinLock); return (start_page); } - -/*** - END - ***/ - diff --git a/sys/vmm/paging.c b/sys/vmm/paging.c index f3f6863..ce41624 100644 --- a/sys/vmm/paging.c +++ b/sys/vmm/paging.c @@ -242,9 +242,9 @@ "mov %eax,%cr3 \n" "pop %eax \n" ); - memset(pageTable, 0x0, 0x1000); + } /* Set Address To Page Table */ diff --git a/sys/vmm/unmappage.c b/sys/vmm/unmappage.c index bfb0cfd..1551965 100644 --- a/sys/vmm/unmappage.c +++ b/sys/vmm/unmappage.c @@ -110,32 +110,3 @@ } return; } - -/*** - $Log: unmappage.c,v $ - Revision 1.1.1.1 2006/06/01 12:46:13 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:38 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:24:54 reddawg - no message - - Revision 1.4 2004/07/26 19:15:49 reddawg - test code, fixes and the like - - Revision 1.3 2004/06/15 12:35:05 reddawg - Cleaned Up - - Revision 1.2 2004/06/10 22:23:56 reddawg - Volatiles - - Revision 1.1.1.1 2004/04/15 12:06:53 reddawg - UbixOS v1.0 - - Revision 1.7 2004/04/13 16:36:34 reddawg - Changed our copyright, it is all now under a BSD-Style license - - END - ***/