diff --git a/src/sys/include/vmm/vmm.h b/src/sys/include/vmm/vmm.h index 714e026..72ec33d 100644 --- a/src/sys/include/vmm/vmm.h +++ b/src/sys/include/vmm/vmm.h @@ -54,10 +54,6 @@ spinLock_t *lock; }; -uInt32 freePages = 0; -uInt32 usedPages = 0; -mMap *vmmFreePages; -mMap *vmmUsedPages; extern int numPages; extern mMap *vmmMemoryMap; @@ -75,6 +71,15 @@ /*** $Log$ + Revision 1.11 2005/08/10 08:09:17 fsdfs + the new memory management suite is located in sys/mm now. + + heres the idea. basically what we are doing is allocating every bit + of physical memory available to us and flagging them as used. when + we create virtual memory, we simply set the pageAddr to the address + of the virtual address, and leave the physicalAddr property to + it's respective physical location in RAM. + Revision 1.10 2005/08/10 07:07:03 fsdfs vmm_pageFault2() implemented diff --git a/src/sys/mm/copyvirtualspace.c b/src/sys/mm/copyvirtualspace.c index 6f97b26..e6bd7be 100644 --- a/src/sys/mm/copyvirtualspace.c +++ b/src/sys/mm/copyvirtualspace.c @@ -1,33 +1,4 @@ -/***************************************************************************************** - Copyright (c) 2002-2004 The UbixOS Project - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, are - permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this list of - conditions, the following disclaimer and the list of authors. Redistributions in binary - form must reproduce the above copyright notice, this list of conditions, the following - disclaimer and the list of authors in the documentation and/or other materials provided - with the distribution. Neither the name of the UbixOS Project nor the names of its - contributors may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - $Id$ - -*****************************************************************************************/ - -#include +#include #include #include #include diff --git a/src/sys/mm/kfree.c b/src/sys/mm/kfree.c new file mode 100644 index 0000000..cf2c3e1 --- /dev/null +++ b/src/sys/mm/kfree.c @@ -0,0 +1,6 @@ + +void kfree(void *ptr) +{ + + return; +} diff --git a/src/sys/mm/kmalloc.c b/src/sys/mm/kmalloc.c new file mode 100644 index 0000000..fc852d8 --- /dev/null +++ b/src/sys/mm/kmalloc.c @@ -0,0 +1,6 @@ + + +void *kmalloc(size_t size) +{ + +} diff --git a/src/sys/mm/memory.c b/src/sys/mm/memory.c index a8bd42b..10dc626 100644 --- a/src/sys/mm/memory.c +++ b/src/sys/mm/memory.c @@ -18,6 +18,7 @@ vmmFreePages->Last->Next = task->FirstPage; task->FirstPage->Previous = vmmFreePages->Last; vmmFreePages->Last = task->LastPage; + memset(emptyKernDesc,0x0,0x4000); /* TODO: zero out the memory last used */ kprintf("mmFreeTaskPages: Memory has been wiped\n"); } diff --git a/src/sys/mm/pagefault.c b/src/sys/mm/pagefault.c index fa5ce06..083f13d 100644 --- a/src/sys/mm/pagefault.c +++ b/src/sys/mm/pagefault.c @@ -1,56 +1,8 @@ -/***************************************************************************************** - Copyright (c) 2002 The UbixOS Project - All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are -permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list of -conditions, the following disclaimer and the list of authors. Redistributions in binary -form must reproduce the above copyright notice, this list of conditions, the following -disclaimer and the list of authors in the documentation and/or other materials provided -with the distribution. Neither the name of the UbixOS Project nor the names of its -contributors may be used to endorse or promote products derived from this software -without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - $Id$ - -*****************************************************************************************/ - -#include -#include -#include -#include +#include #include -#include #include static spinLock_t pageFaultSpinLock = SPIN_LOCK_INITIALIZER; -/***************************************************************************************** - - Function: void vmm_pageFault(uInt32 memAddr,uInt32 eip,uInt32 esp); - Description: This is the page fault handler, it will handle COW and trap all other - exceptions and segfault the thread. - - Notes: - -07/30/02 - Fixed COW However I Need To Think Of A Way To Impliment - A Paging System Also Start To Add Security Levels - -07/27/04 - Added spin locking to ensure that we are thread safe. I know that spining a - cpu is a waste of resources but for now it prevents errors. - -*****************************************************************************************/ void LoadPageIntoMemory(mMap *page); void vmm_pageFault2(uInt32 memAddr, uInt32 eip, uInt32 esp) diff --git a/src/sys/vmm/copyvirtualspace.c b/src/sys/vmm/copyvirtualspace.c index 6986f53..5b806f9 100644 --- a/src/sys/vmm/copyvirtualspace.c +++ b/src/sys/vmm/copyvirtualspace.c @@ -50,54 +50,6 @@ Which Task Has Which Physical Pages ************************************************************************/ -void vmmCopyVirtualSpace2(kTask_t *task, kTask_t *new) -{ - mMap *tmp, *tmp2 , *prev; - - tmp = task->FirstPage; - - if(tmp != NULL) - { - tmp2 = (mMap *)kmalloc(sizeof(mMap)); - new->FirstPage = tmp2; - prev = NULL; - } - else - { - new->FirstPage = NULL; - new->LastPage = NULL; - return; - } - if(tmp->Next == NULL) - { - tmp2->Next = NULL; - tmp2->Previous = NULL; - new->LastPage = tmp2; - } - else - { - for(;;) - { - tmp2->Previous = prev; - tmp2->pid = new->id; - tmp2->pageAddr = tmp->pageAddr; - tmp2->status = tmp->status; - prev = tmp2; - tmp2 = (mMap *) kmalloc(sizeof(mMap)); - prev->Next = tmp2; - tmp = tmp->Next; - if(tmp == NULL) - { - kfree(tmp2); - prev->Next = NULL; - new->LastPage = prev; - break; - } - } - } - return; -} - void * vmmCopyVirtualSpace(pidType pid) @@ -253,6 +205,10 @@ /*** $Log$ + Revision 1.10 2005/08/10 06:01:59 fsdfs + cleaned up dependencies. rewrote vmmCopyVirtualSpace. does not compile + CVSn: ---------------------------------------------------------------------- + Revision 1.9 2005/08/09 08:45:40 fsdfs reverting to old vmm. i may have modified something accidently when i wasted time indenting the code. diff --git a/src/sys/vmm/getfreepage.c b/src/sys/vmm/getfreepage.c index 824ce5c..db90972 100644 --- a/src/sys/vmm/getfreepage.c +++ b/src/sys/vmm/getfreepage.c @@ -45,24 +45,6 @@ ************************************************************************/ -void * vmmGetFreePage2(kTask_t *task) -{ - mMap *tmp; - - /* remove the first free entry from the free pages list */ - tmp = vmmFreePages->First; - freePages--; - vmmFreePages->First = vmmFreePages->First->Next; - vmmFreePages->First->Previous = NULL; - - /* add the free entry to the task's pages list */ - usedPages++; - tmp->Next = NULL; - tmp->Previous = task->LastPage; - task->LastPage = tmp; - return tmp; -} - void * vmmGetFreePage(pidType pid) { @@ -97,6 +79,10 @@ /*** $Log$ + Revision 1.12 2005/08/10 06:01:59 fsdfs + cleaned up dependencies. rewrote vmmCopyVirtualSpace. does not compile + CVSn: ---------------------------------------------------------------------- + Revision 1.11 2005/08/10 04:58:18 fsdfs updated mememory management diff --git a/src/sys/vmm/memory.c b/src/sys/vmm/memory.c index e510a85..092cc1c 100644 --- a/src/sys/vmm/memory.c +++ b/src/sys/vmm/memory.c @@ -39,6 +39,9 @@ static spinLock_t vmmSpinLock = SPIN_LOCK_INITIALIZER; static spinLock_t vmmCowSpinLock = SPIN_LOCK_INITIALIZER; +uInt32 usedPages; +uInt32 freePages; + int numPages = 0; mMap *vmmMemoryMap = (mMap *)0x101000; @@ -53,8 +56,7 @@ ************************************************************************/ int vmmMemMapInit() { - int i, memStart, z; - mMap *tmpMap; + int i, memStart; /* Count System Memory */ numPages = countMemory(); @@ -87,60 +89,6 @@ freePages++; } - for(z = 0 ; z < numPages; z++) - { - if(vmmMemoryMap[z].status == memAvail) - { - if(vmmFreePages == NULL) - { - //UBU: replace this with static location - vmmFreePages = kmalloc(sizeof(mMap)); - vmmFreePages->First = vmmFreePages; - vmmFreePages->Last = vmmFreePages; - vmmFreePages->Next = NULL; - vmmFreePages->Previous = NULL; - vmmFreePages->pid = vmmID; - vmmFreePages->pageAddr = z * 4096; - vmmFreePages->status = memAvail; - } - else - { - tmpMap = kmalloc(sizeof(mMap)); - vmmFreePages->Last->Next = tmpMap; - tmpMap->Previous = vmmFreePages->Last; - vmmFreePages->Last = tmpMap; - tmpMap->pid = vmmID; - tmpMap->pageAddr = z * 4096; - tmpMap->status = memAvail; - } - } - else - { - if(vmmUsedPages == NULL) - { - //UBU: replace this with static location - vmmUsedPages = kmalloc(sizeof(mMap)); - vmmUsedPages->First = vmmUsedPages; - vmmUsedPages->Last = vmmUsedPages; - vmmUsedPages->Next = NULL; - vmmUsedPages->Previous = NULL; - vmmUsedPages->pid = vmmID; - vmmUsedPages->pageAddr = z * 4096; - vmmUsedPages->status = memNotavail; - } - else - { - tmpMap = kmalloc(sizeof(mMap)); - vmmUsedPages->Last->Next = tmpMap; - tmpMap->Previous = vmmUsedPages->Last; - vmmUsedPages->Last = tmpMap; - tmpMap->pid = vmmID; - tmpMap->pageAddr = z * 4096; - tmpMap->status = memNotavail; - } - } - } - /* Print Out Memory Information */ kprintf("Real Memory: %iMB\n", ((numPages * 4096) / 1024) / 1024 ); kprintf("Available Memory: %iMB\n", ((freePages * 4096) / 1024) / 1024 ); @@ -392,6 +340,10 @@ /*** $Log$ + Revision 1.20 2005/08/10 06:01:59 fsdfs + cleaned up dependencies. rewrote vmmCopyVirtualSpace. does not compile + CVSn: ---------------------------------------------------------------------- + Revision 1.19 2005/08/10 04:14:04 fsdfs reworking memory management and WTF is with all the errors in the headers it won't let me add anything!?