diff --git a/src/sys/include/ubixos/sched.h b/src/sys/include/ubixos/sched.h index b5a279e..46c3fff 100644 --- a/src/sys/include/ubixos/sched.h +++ b/src/sys/include/ubixos/sched.h @@ -78,7 +78,7 @@ void schedEndTask(pidType pid); kTask_t *schedNewTask(); -kTask_t *schedFindTask(uInt32 id); +kTask_t *schedFindTask(pidType id); extern kTask_t *_current; extern kTask_t *_usedMath; @@ -88,6 +88,9 @@ /*** $Log$ + Revision 1.2 2007/01/26 18:29:41 reddawg + Functional changes to vfs not yet 100% complete also need to impliment kopen in kernel + Revision 1.1.1.1 2007/01/17 03:31:52 reddawg UbixOS diff --git a/src/sys/include/vmm/paging.h b/src/sys/include/vmm/paging.h index 129c190..5666176 100644 --- a/src/sys/include/vmm/paging.h +++ b/src/sys/include/vmm/paging.h @@ -39,7 +39,8 @@ #define pageLength 0x00000400 #define PAGE_TABLES_BASE_ADDR 0xBFC00000 /* Base address of page tables in virtual area 3GB - 4MB */ -#define PARENT_PAGEDIR_ADDR 0x100000 /* Address at which the page directory is stored */ +#define PARENT_PAGEDIR_ADDR 0x3FF000 /* 0x100000 */ /* Address at which the page directory is stored */ +#define PAGE_DIR_INDEX (PARENT_PAGEDIR_ADDR/0x1000) #define PAGE_COW 0x00000200 #define PAGE_STACK 0x00000400 #define PAGE_WIRED 0x00000600 @@ -58,7 +59,7 @@ #define PAGE_UNAVAILABLE 0x2 /* Set the page to be in use */ #define PAGE_KERNEL_ENTRY 0x300 /* First kernel page entry */ -#define PAGE_DIR_SPACE 0x2FF /* Virtual Area For Pages 4MB */ +#define PAGE_DIR_SPACE 0x2FF /* Virtual Area For Page Tables 4MB */ #define PTI(x) ((x >> 12) & 0x3FF) /* Return page directory index of address */ #define PDI(x) (x >> 22) /* Return page table index of address */ diff --git a/src/sys/include/vmm/vmm.h b/src/sys/include/vmm/vmm.h index 1567e1b..d6999b8 100644 --- a/src/sys/include/vmm/vmm.h +++ b/src/sys/include/vmm/vmm.h @@ -32,6 +32,7 @@ #include #include +#include #define vmmID -3 #define vmmMemoryMapAddr 0xE6667000 @@ -66,7 +67,7 @@ int vmm_remapPage(u_int32_t,u_int32_t,u_int16_t); void vmm_freePage(u_int32_t pageAddr); void vmm_adjustCowCounter(u_int32_t pageAddr,int adjustment); -void vmm_freeProcessPages(pidType pid); +void vmm_freeProcessPages(kTask_t *tmpTask); /* Interrupt Functions */ void vmm_pageFault(u_int32_t,u_int32_t,u_int32_t); @@ -82,6 +83,9 @@ /*** $Log$ + Revision 1.4 2009/07/09 04:01:15 reddawg + More Sanity Checks + Revision 1.3 2009/07/08 21:20:13 reddawg Getting There diff --git a/src/sys/kernel/endtask.c b/src/sys/kernel/endtask.c index 1297e21..eba57c9 100644 --- a/src/sys/kernel/endtask.c +++ b/src/sys/kernel/endtask.c @@ -45,32 +45,20 @@ ************************************************************************/ void endTask(pidType pid) { - //kTask_t *tmpTask = 0x0; /* Don't mess with scheduler structures from outside the scheduler! */ /* Just set status to dead, and let the scheduler clean up itself */ if (sched_setStatus(pid,DEAD) != 0x0) - kpanic("sched_setStatus: Failed\n"); - //tmpTask = schedFindTask(pid); - //if (sched_deleteTask(pid) != 0x0) - // kpanic("sched_deleteTask: Failed\n"); - //kprintf("Ending Task: (%i:0x%X)\n",tmpTask->id,tmpTask); - //sched_addDelTask(tmpTask); - //tmpTask->state = DEAD; + K_PANIC("sched_setStatus: Failed\n"); - //tmpTask->term->owner = tmpTask->parentPid; - //kprintf("wtf?"); - //return; - - if (pid == _current->id) - while(1) - sched_yield(); - sched_yield(); + while (pid == _current->id) + sched_yield(); return; } /*** + $Log$ END ***/ diff --git a/src/sys/kernel/exec.c b/src/sys/kernel/exec.c index 845a3be..5bcf39b 100644 --- a/src/sys/kernel/exec.c +++ b/src/sys/kernel/exec.c @@ -39,7 +39,7 @@ #include /* WHERE SHOULD THE STACK BE? */ -#define STACK_ADDR 0x80000000 //0xC800000 +#define STACK_ADDR 0xBFC00000 //0x80000000 //0xC800000 #define AT_NULL 0 /* Terminates the vector. */ #define AT_IGNORE 1 /* Ignored entry. */ @@ -167,12 +167,12 @@ elfProgramHeader *programHeader = 0x0; /* Get A New Task For This Proccess */ - kprintf("execFile: %s",file); _current = schedNewTask(); assert(_current); _current->gid = 0x0; _current->uid = 0x0; _current->term = tty_find(console); + if (_current->term == 0x0) kprintf("Error: invalid console\n"); @@ -213,10 +213,6 @@ //kprintf(">a:%i:0x%X:0x%X<",sizeof(elfHeader),binaryHeader,tmpFd); fread(binaryHeader,sizeof(elfHeader),1,tmpFd); - //UBU - kprintf("2"); - - /* Check If App Is A Real Application */ if ((binaryHeader->eIdent[1] != 'E') && (binaryHeader->eIdent[2] != 'L') && (binaryHeader->eIdent[3] != 'F')) { kprintf("Exec Format Error: Binary File Not Executable.\n"); @@ -243,8 +239,6 @@ //kprintf(">c:%i:0x%X:0x%X<",sizeof(elfProgramHeader)*binaryHeader->ePhnum,programHeader,tmpFd); fread(programHeader,(sizeof(elfProgramHeader)*binaryHeader->ePhnum),1,tmpFd); - //kprintf(">d<"); - kprintf("1"); /* Loop Through The Header And Load Sections Which Need To Be Loaded */ for (i=0;iePhnum;i++) { @@ -384,8 +378,6 @@ return; } - kprintf("Sys EXEC: %i 0x%X 0x%X\n",tmpFd->size,ap,ep); - /* Set tasks FD for binary */ _current->imageFd = tmpFd; @@ -431,7 +423,6 @@ if ((programHeader = (elfProgramHeader *)kmalloc(sizeof(elfProgramHeader)*binaryHeader->ePhnum)) == 0x0) K_PANIC("kmalloc: failed to allocate memory"); - assert(programHeader); fseek(tmpFd,binaryHeader->ePhoff,0); if (fread(programHeader,(sizeof(elfProgramHeader)*binaryHeader->ePhnum),1,tmpFd) != (sizeof(elfProgramHeader)*binaryHeader->ePhnum)) K_PANIC("fread: Read more than specified"); @@ -439,20 +430,16 @@ if ((sectionHeader = (elfSectionHeader *)kmalloc(sizeof(elfSectionHeader)*binaryHeader->eShnum)) == 0x0) K_PANIC("kmalloc: failed to allocate memory"); - assert(sectionHeader); fseek(tmpFd,binaryHeader->eShoff,0); if (fread(sectionHeader,sizeof(elfSectionHeader)*binaryHeader->eShnum,1,tmpFd) != (sizeof(elfSectionHeader)*binaryHeader->eShnum)) K_PANIC("fread: read more than specified"); - kprintf("This Loop SegFaults HERE: [%i]\n",binaryHeader->ePhnum); /* Loop Through The Header And Load Sections Which Need To Be Loaded */ for (i=0;iePhnum;i++) { - kprintf("phType: 0x%X, PT_LOAD: 0x%X\n",programHeader[i].phType,PT_LOAD); switch (programHeader[i].phType) { case PT_LOAD: seg_addr = trunc_page(programHeader[i].phVaddr); seg_size = round_page(programHeader[i].phMemsz + programHeader[i].phVaddr - seg_addr); - kprintf("seg_addr: 0x%X, seg_size: 0x%X\n",seg_addr,seg_size); /* Allocate Memory Im Going To Have To Make This Load Memory With Correct @@ -467,11 +454,8 @@ if (vmm_remapPage(vmm_findFreePage(_current->id),((programHeader[i].phVaddr & 0xFFFFF000) + x),PAGE_DEFAULT) == 0x0) K_PANIC("Error: Remap Page Failed"); memset((void *)((programHeader[i].phVaddr & 0xFFFFF000) + x),0x0,0x1000); - kprintf("."); } -kprintf("A"); - /* Now Load Section To Memory */ fseek(tmpFd,programHeader[i].phOffset,0); fread((void *)programHeader[i].phVaddr,programHeader[i].phFilesz,1,tmpFd); @@ -498,7 +482,6 @@ elfDynamicS = (elfDynamic *)programHeader[i].phVaddr; fseek(tmpFd,programHeader[i].phOffset,0); fread((void *)programHeader[i].phVaddr,programHeader[i].phFilesz,1,tmpFd); - kprintf(".DYN.\n"); break; case PT_INTERP: interp = (char *)kmalloc(programHeader[i].phFilesz); @@ -526,17 +509,11 @@ tmp[1] = (uInt32)tmpFd; break; } -/* - else { - kprintf("dyn_val: %i",elfDynamicS[i].dynVal); - } -*/ } } _current->td.vm_dsize = seg_size >> PAGE_SHIFT; _current->td.vm_daddr = seg_addr; - kprintf("STARTING-*: [0x%X][0x%X]\n",_current->td.vm_dsize,_current->td.vm_daddr); argv = (char **)ap; envp = (char **)ep; @@ -544,6 +521,7 @@ if ((ep != 0x0) && (envp[0] != 0x0)) kprintf("ENV SIZE: [0x%X]\n",envp[0]); + if (argv[1] != 0x0) { //UBU argc = (int)argv[0]; @@ -562,13 +540,13 @@ argv = argvNew; } + //! Clean the virtual of COW pages left over from the fork //QUESTION Why did I feel a need to add vm_dsize to vm_daddr kprintf("First: 0x%X, 0x%X\n",_current->td.vm_dsize,_current->td.vm_daddr); vmm_cleanVirtualSpace((u_int32_t)_current->td.vm_daddr + (_current->td.vm_dsize << PAGE_SHIFT)); - //! Adjust iframe iFrame = (struct i386_frame *)(_current->tss.esp0 - sizeof(struct i386_frame)); iFrame->ebp = STACK_ADDR; diff --git a/src/sys/kernel/fork.c b/src/sys/kernel/fork.c index f1e9575..a1713d1 100644 --- a/src/sys/kernel/fork.c +++ b/src/sys/kernel/fork.c @@ -88,12 +88,14 @@ newProcess->tss.trace_bitmap = 0x0000; newProcess->tss.io_map = 0x8000; + // This makes a copy of the CURRENT VMSPACE! /* Create A Copy Of The VM Space For New Task */ newProcess->tss.cr3 = (uInt32)vmm_copyVirtualSpace(newProcess->id); newProcess->state = FORK; /* Fix gcc optimization problems */ - while (tmpProcPtr->state == FORK) sched_yield(); + while (tmpProcPtr->state == FORK) + sched_yield(); /* Return Id of Proccess */ return(newProcess->id); diff --git a/src/sys/kernel/ld.c b/src/sys/kernel/ld.c index b516f95..15c6d27 100644 --- a/src/sys/kernel/ld.c +++ b/src/sys/kernel/ld.c @@ -64,10 +64,6 @@ kprintf("Can not open ld.so\n"); } - #ifdef LD_DEBUG - kprintf("Loading LD\n"); - #endif - fseek(ldFd,0x0,0x0); binaryHeader = (elfHeader *)kmalloc(sizeof(elfHeader)); assert(binaryHeader); diff --git a/src/sys/kernel/sched.c b/src/sys/kernel/sched.c index 220e493..7008962 100644 --- a/src/sys/kernel/sched.c +++ b/src/sys/kernel/sched.c @@ -68,8 +68,9 @@ int sched_init() { taskList = (kTask_t *)kmalloc(sizeof(kTask_t)); - if(taskList == 0x0) - kpanic("Unable to create task list"); + + if (taskList == 0x0) + kpanic("Unable to create task list"); taskList->id = nextID++; @@ -96,6 +97,7 @@ return; tmpTask = _current->next; + assert(tmpTask); //outportByte(0xE9,_current->id + '0'); schedStart: @@ -171,7 +173,6 @@ tmpTask->prev = 0x0; taskList->prev = tmpTask; taskList = tmpTask; - spinUnlock(&schedulerSpinLock); return(tmpTask); @@ -181,7 +182,10 @@ int sched_deleteTask(pidType id) { kTask_t *tmpTask = 0x0; + kprintf("Deleting: %i\n",id); + /* Checking each task from the prio queue */ + spinLock(&schedulerSpinLock); for (tmpTask = taskList; tmpTask != 0x0; tmpTask = tmpTask->next) { if (tmpTask->id == id) { if (tmpTask->prev != 0x0) @@ -191,9 +195,11 @@ if (taskList == tmpTask) taskList = tmpTask->next; + spinUnlock(&schedulerSpinLock); return(0x0); } } + spinUnlock(&schedulerSpinLock); return(0x1); } @@ -218,19 +224,17 @@ } -kTask_t * -schedFindTask(uInt32 id) -{ - kTask_t *tmpTask = 0x0; +kTask_t *schedFindTask(pidType id) { + kTask_t *tmpTask = 0x0; - for (tmpTask = taskList; tmpTask; tmpTask = tmpTask->next) { - if (tmpTask->id == id) - return(tmpTask); - } + for (tmpTask = taskList; tmpTask; tmpTask = tmpTask->next) { + if (tmpTask->id == id) + return(tmpTask); + } - return(0x0); -} - + /* Return NULL when we can't find the task */ + return(0x0); + } /************************************************************************ diff --git a/src/sys/kernel/spinlock.c b/src/sys/kernel/spinlock.c index 6c4b722..79d3e06 100644 --- a/src/sys/kernel/spinlock.c +++ b/src/sys/kernel/spinlock.c @@ -35,14 +35,12 @@ } void spinUnlock(spinLock_t *lock) { - *lock = 0x0; - /* + //*lock = 0x0; register int unlocked; asm volatile( "xchgl %0, %1" : "=&r" (unlocked), "=m" (*lock) : "0" (0) ); - */ } int spinTryLock(spinLock_t *lock) { @@ -54,12 +52,11 @@ } void spinLock(spinLock_t *lock) { - while (!spinTryLock(lock)) - { + while (!spinTryLock(lock)) { while (*lock == 1) - sched_yield(); + sched_yield(); + } } -} void spinLock_scheduler(spinLock_t *lock) { while (!spinTryLock(lock)) diff --git a/src/sys/kernel/systemtask.c b/src/sys/kernel/systemtask.c index ba1a6f9..353b912 100644 --- a/src/sys/kernel/systemtask.c +++ b/src/sys/kernel/systemtask.c @@ -110,7 +110,7 @@ kprintf("Closing: [0x%X]\n",tmpTask->imageFd); fclose(tmpTask->imageFd); } - vmm_freeProcessPages(tmpTask->id); + vmm_freeProcessPages(tmpTask); kfree(tmpTask); } videoBuffer[0] = systemVitals->sysTicks; diff --git a/src/sys/vfs/mount.c b/src/sys/vfs/mount.c index c36977d..4f72900 100644 --- a/src/sys/vfs/mount.c +++ b/src/sys/vfs/mount.c @@ -52,8 +52,6 @@ if ((mp = (struct vfs_mountPoint *)kmalloc(sizeof(struct vfs_mountPoint))) == NULL) kprintf("vfs_mount: failed to allocate mp\n"); - kprintf("DEBUG: MOUNT"); - /* Copy Mount Point Into Buffer */ sprintf(mp->mountPoint,mountPoint); @@ -65,11 +63,9 @@ return(0x1); } - kprintf("DEBUG: [0x%X]\n",device); - /* Set Up Mp Defaults */ mp->device = device; - mp->fs = vfsFindFS(vfsType); + mp->fs = (struct fileSystem *)vfsFindFS(vfsType); mp->partition = partition; mp->perms = *perms; @@ -79,8 +75,6 @@ return(0x1); } - kprintf("DEBUG: mp->fs\n"); - /*What is this for? 10/6/2006 */ /* if (device != 0x0) { diff --git a/src/sys/vmm/pagefault.c b/src/sys/vmm/pagefault.c index 6854725..91eac58 100644 --- a/src/sys/vmm/pagefault.c +++ b/src/sys/vmm/pagefault.c @@ -112,11 +112,8 @@ pageTable[pageTableIndex] = (u_int32_t)vmm_findFreePage(_current->id) | PAGE_DEFAULT; } else { - spinUnlock(&pageFaultSpinLock); - /* Need To Create A Routine For Attempting To Access Non Mapped Memory */ kprintf("Segfault @: 0x%X, ESP: 0x%X, PID: %i, EIP: 0x%X Non Mapped\n",memAddr,esp,_current->id,eip); - spinUnlock(&pageFaultSpinLock); /* End this task */ @@ -135,6 +132,9 @@ /*** $Log$ + Revision 1.6 2009/07/09 00:49:50 reddawg + Lots of fixes and renaming to the vmm portion of the kernel + Revision 1.5 2009/07/08 21:20:13 reddawg Getting There diff --git a/src/sys/vmm/paging.c b/src/sys/vmm/paging.c index f169442..8e9f3c7 100644 --- a/src/sys/vmm/paging.c +++ b/src/sys/vmm/paging.c @@ -117,7 +117,7 @@ /* Also Set Up Page Directory To Be The The First Page In 0xE0400000 */ pageTable = (u_int32_t *) (kernelPageDirectory[0] & 0xFFFFF000); - pageTable[256] = (u_int32_t) ((u_int32_t) (kernelPageDirectory) | KERNEL_PAGE_DEFAULT); + pageTable[PAGE_DIR_INDEX] = (u_int32_t) ((u_int32_t) (kernelPageDirectory) | KERNEL_PAGE_DEFAULT); /* Now Lets Turn On Paging With This Initial Page Table */ diff --git a/src/sys/vmm/setpageattributes.c b/src/sys/vmm/setpageattributes.c index 0995769..15885a9 100644 --- a/src/sys/vmm/setpageattributes.c +++ b/src/sys/vmm/setpageattributes.c @@ -1,5 +1,5 @@ /***************************************************************************************** - Copyright (c) 2002 The UbixOS Project + Copyright (c) 2002, 2009 The UbixOS Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are @@ -40,28 +40,25 @@ ************************************************************************/ void vmm_setPageAttributes(u_int32_t memAddr,u_int16_t attributes) { - u_int16_t directoryIndex = 0x0, tableIndex = 0x0; + u_int16_t pageDI = 0x0; + u_int16_t pageTI = 0x0; u_int32_t *pageTable = 0x0; -#ifdef VMMDEBUG - kprintf("vmm_getPageAttributes"); -#endif - /* Calculate The Page Directory Index */ - directoryIndex = PDI(memAddr);; + pageDI = PDI(memAddr);; /* Calculate The Page Table Index */ - tableIndex = PTI(memAddr); + pageTI = PTI(memAddr); /* Set Table Pointer */ - if ((pageTable = (u_int32_t *) (PAGE_TABLES_BASE_ADDR + (0x1000 * directoryIndex))) == 0x0) + if ((pageTable = (u_int32_t *) (PAGE_TABLES_BASE_ADDR + (0x1000 * pageDI))) == 0x0) kpanic("Error: pageTable == NULL, File: %s, Line: %i\n",__FILE__,__LINE__); /* Set Attribute If Page Is Mapped */ - if (pageTable[tableIndex] != 0x0) - pageTable[tableIndex] = ((pageTable[tableIndex] & 0xFFFFF000) | attributes); + if (pageTable[pageTI] != 0x0) + pageTable[pageTI] = ((pageTable[pageTI] & 0xFFFFF000) | attributes); else - kpanic("WTF NON MAPPED"); + K_PANIC("Page Not Mapped"); /* Reload The Page Table; */ asm volatile( @@ -75,6 +72,9 @@ /*** $Log$ + Revision 1.3 2009/07/08 21:20:13 reddawg + Getting There + Revision 1.2 2009/07/08 16:05:56 reddawg Sync diff --git a/src/sys/vmm/unmappage.c b/src/sys/vmm/unmappage.c index 5e2e1e8..93ab0fe 100644 --- a/src/sys/vmm/unmappage.c +++ b/src/sys/vmm/unmappage.c @@ -1,5 +1,5 @@ /***************************************************************************************** - Copyright (c) 2002-2004 The UbixOS Project + Copyright (c) 2002-2004,c 009 The UbixOS Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are @@ -60,7 +60,7 @@ if ((pageTable[dI] & PAGE_PRESENT) != PAGE_PRESENT) { #ifdef VMMDEBUG - kprintf("vmm_unmapPages: page not present"); + kprintf("vmm_unmapPages: page not present - 0x%X",addr); #endif return; } @@ -84,6 +84,9 @@ /*** $Log$ + Revision 1.4 2009/07/09 04:01:15 reddawg + More Sanity Checks + Revision 1.3 2009/07/08 16:06:37 reddawg Trying To Hunt Down Bugs diff --git a/src/sys/vmm/vmm_memory.c b/src/sys/vmm/vmm_memory.c index d6fe5f8..c700196 100644 --- a/src/sys/vmm/vmm_memory.c +++ b/src/sys/vmm/vmm_memory.c @@ -294,7 +294,7 @@ /************************************************************************ - Function: void vmm_freeProcessPages(pid_t pid); + Function: void vmm_freeProcessPages(kTask_t tmpTask); Description: This Function Will Free Up Memory For The Exiting Process @@ -303,31 +303,63 @@ 08/04/02 - Added Checking For COW Pages First ************************************************************************/ -void vmm_freeProcessPages(pidType pid) { +void vmm_freeProcessPages(kTask_t *tmpTask) { int i=0; int x=0; u_int32_t *tmpPageTable = 0x0; u_int32_t *tmpPageDir = (uInt32 *)PARENT_PAGEDIR_ADDR; +/* + This is where a Memory Leak Came From + u_int32_t *tmpPageDir = (uInt32 *)PARENT_PAGEDIR_ADDR; +*/ + + assert(tmpTask); + spinLock(&vmmSpinLock); + + #ifdef BOOB + + tmpPageDir = (u_int32_t *)0x7A00000; + + if (vmm_remapPage(tmpTask->tss.cr3,0x7A00000,KERNEL_PAGE_DEFAULT) == 0x0) + K_PANIC("vmmFailed"); + + for (i=0;i<0x1000;i++) { + kprintf("tmpPageDir[%i]: 0x%X",i,tmpPageDir[i] & PAGE_UNMASK); + if (vmm_remapPage(tmpPageDir[i] & PAGE_UNMASK,0x7A01000 + (i * 0x1000),KERNEL_PAGE_DEFAULT) == 0x0) + K_PANIC("Returned NULL"); + } + + /* Check Page Directory For An Avail Page Table */ for (i=0;i<=0x300;i++) { + kprintf("tPD: 0x%X\n",tmpPageDir[i]); if (tmpPageDir[i] != 0) { + kprintf("PE"); /* Set Up Page Table Pointer */ - tmpPageTable = (u_int32_t *)(PAGE_TABLES_BASE_ADDR + (i * 0x1000)); + tmpPageTable = (u_int32_t *)(0x7A01000 + (i * 0x1000)); /* Check The Page Table For COW Pages */ for (x = 0;x < PAGE_ENTRIES;x++) { /* If The Page Is COW Adjust COW Counter */ if (((u_int32_t)tmpPageTable[x] & PAGE_COW) == PAGE_COW) { + kprintf("COW!"); vmm_adjustCowCounter(((u_int32_t)tmpPageTable[x] & 0xFFFFF000),-1); } } } } + //Return The Address Of The Mapped In Memory + vmm_unmapPages(0x7A00000,1,1); + for (i=0;i<0x1000;i++) { + vmm_unmapPages((0x7A01000 + (i*0x1000)),1,1); + } + + #endif /* Loop Through Pages To Find Pages Owned By Process */ for (i=0;iid) { /* Check To See If The cowCounter Is Zero If So We Can Ree It */ if (vmmMemoryMap[i].cowCounter == 0) { vmmMemoryMap[i].status = PAGE_AVAILABLE; @@ -336,6 +368,9 @@ freePages++; systemVitals->freePages = freePages; } + else { + K_PANIC("COW!NULL"); + } } } /* Return */ @@ -345,6 +380,9 @@ /*** $Log$ + Revision 1.4 2009/07/09 04:01:15 reddawg + More Sanity Checks + Revision 1.3 2009/07/08 21:20:13 reddawg Getting There diff --git a/src/sys/vmm/vmm_virtual.c b/src/sys/vmm/vmm_virtual.c index 95d2ac6..7f4f4c4 100644 --- a/src/sys/vmm/vmm_virtual.c +++ b/src/sys/vmm/vmm_virtual.c @@ -42,7 +42,7 @@ u_int32_t *pageTableSrc = 0x0; u_int32_t *pageDir = 0x0; - assert((addr & 0xFFF) == 0x0); + assert((addr & PAGE_MASK) == 0x0); pageDir = (u_int32_t *) PARENT_PAGEDIR_ADDR; @@ -79,8 +79,10 @@ /* we must now reload the page directory */ asm( + "push %eax\n" "movl %cr3,%eax\n" "movl %eax,%cr3\n" + "pop %eax\n" ); return(0x0); @@ -108,6 +110,10 @@ spinLock(&fvpSpinLock); + #ifdef VMMDEBUG + kprintf("vmm_getFreeVirtualPage_old"); + #endif + pageDir = (u_int32_t *)PARENT_PAGEDIR_ADDR; /* Lets Search For A Free Page */ @@ -267,7 +273,7 @@ /* Start at suggest address if supplied */ if (start_addr != -1) { start_page = start_addr; - #ifdef VMM_DEBUG + #ifdef VMMDEBUG kprintf("Start_ADDR"); #endif } @@ -297,7 +303,7 @@ for (y = 0; y < PAGE_ENTRIES; y++) { /* Loop Through The Page Table Find An UnAllocated Page */ if ((pageTableSrc[y] & PAGE_COW) == PAGE_COW) { - kprintf("PAGE_COW: 0x%X", (x * (0x400000) + (y * 0x1000))); + kprintf("FVP.PAGE_COW: 0x%X", (x * (0x400000) + (y * 0x1000))); //_current->td.vm_dsize += btoc(0x1000); /* HACK MEMORY LEAK */ //pageTableSrc[y] = 0x0; @@ -307,7 +313,7 @@ for (c = 0; c < count; c++) { if (y + c < 1024) { if ((pageTableSrc[y + c] & PAGE_COW) == PAGE_COW) { - kprintf("PAGE-COW"); + kprintf("FVP.PAGE-COW"); //_current->td.vm_dsize += btoc(0x1000); /* HACK MEMORY LEAK */ //pageTableSrc[y + c] = 0x0; @@ -524,7 +530,7 @@ } } /* Set Virtual Mapping For Page Directory */ - newPageTable[256] = (vmm_getPhysicalAddr((u_int32_t) newPageDirectory) | PAGE_DEFAULT); + newPageTable[PAGE_DIR_INDEX] = (vmm_getPhysicalAddr((u_int32_t) newPageDirectory) | PAGE_DEFAULT); /* * Now The Fun Stuff Build The Initial Virtual Page Space So We Don't Have @@ -625,7 +631,7 @@ newPageTable[x] = parentPageTable[x]; } /* Set Virtual Mapping For Page Directory */ - newPageTable[256] = (vmm_getPhysicalAddr((u_int32_t) newPageDirectory) | PAGE_DEFAULT); + newPageTable[PAGE_DIR_INDEX] = (vmm_getPhysicalAddr((u_int32_t) newPageDirectory) | PAGE_DEFAULT); /* * Now The Fun Stuff Build The Initial Virtual Page Space So We Don't Have @@ -652,6 +658,9 @@ /* $Log$ + Revision 1.11 2009/07/09 04:01:15 reddawg + More Sanity Checks + Revision 1.10 2009/07/09 00:49:50 reddawg Lots of fixes and renaming to the vmm portion of the kernel diff --git a/src/tools/Makefile b/src/tools/Makefile index 060d81c..b460a98 100644 --- a/src/tools/Makefile +++ b/src/tools/Makefile @@ -38,6 +38,7 @@ install-ubix: (cp ../sys/compile/ubix.elf /ubix/boot/kernel/kernel) + (cp ../sys/compile/ubix.elf /ubix/boot/loader) (cp ../bin/init/init /ubix/bin) (cp ../bin/login/login /ubix/bin) (cp ../bin/shell/shell //ubix/bin)