diff --git a/src/bin/shell/commands.c b/src/bin/shell/commands.c index 3ef353f..6b5101b 100644 --- a/src/bin/shell/commands.c +++ b/src/bin/shell/commands.c @@ -46,6 +46,7 @@ } else if (memcmp(data->args->arg,"stress", 6) == 0) { while (1) { + printf("Starting Clock\n"); cPid = fork(); if (cPid == 0x0) { printf("Pid: [%i]\n",cPid); diff --git a/src/sys/include/vmm/paging.h b/src/sys/include/vmm/paging.h index ddef330..3571e8f 100644 --- a/src/sys/include/vmm/paging.h +++ b/src/sys/include/vmm/paging.h @@ -58,8 +58,8 @@ void *vmmGetPhysicalAddr(uInt32); void *vmmCreateVirtualSpace(pidType); void *vmmGetFreeVirtualPage(pidType,int); -void vmmPageFault(); -void _vmmPageFault(); +void vmm_pageFault(uInt32); +void _vmm_pageFault(); extern uInt32 *kernelPageDirectory; @@ -67,6 +67,9 @@ /*** $Log$ + Revision 1.3 2004/07/22 17:32:25 reddawg + I broke it hopefully + Revision 1.2 2004/05/21 15:21:04 reddawg Cleaned up diff --git a/src/sys/isa/atkbd.c b/src/sys/isa/atkbd.c index ae5aed4..0ee8f70 100644 --- a/src/sys/isa/atkbd.c +++ b/src/sys/isa/atkbd.c @@ -178,6 +178,7 @@ " mov $0x20,%dx \n" /* The Following Sends Our EOI To The MPIC */ " mov $0x20,%ax \n" " outb %al,%dx \n" + " sti \n" " call keyboardHandler \n" " pop %eax \n" " popa \n" @@ -288,6 +289,9 @@ /*** $Log$ + Revision 1.11 2004/07/24 15:12:56 reddawg + Now I'm current + Revision 1.10 2004/07/23 17:49:58 reddawg atkbd: adjust the timing issue on the driver hopefully it will work fine now diff --git a/src/sys/kernel/fork.c b/src/sys/kernel/fork.c index d6aeeb6..a982daa 100644 --- a/src/sys/kernel/fork.c +++ b/src/sys/kernel/fork.c @@ -98,9 +98,7 @@ newProcess->tss.io_map = 0x8000; newProcess->tss.eip = eip; /* Create A Copy Of The VM Space For New Task */ - newProcess->tss.cr3 = (uInt32)vmmCopyVirtualSpace(newProcess->id); - //newProcess->oInfo.curDir = _current->oInfo.curDir; - //newProcess->oInfo.container = _current->oInfo.container; + newProcess->tss.cr3 = (uInt32)vmmCopyVirtualSpace(newProcess->id); sprintf(newProcess->oInfo.cwd,_current->oInfo.cwd); newProcess->state = READY; /* Return Id of Proccess */ @@ -109,6 +107,9 @@ /*** $Log$ + Revision 1.13 2004/07/21 17:11:18 reddawg + A Quick tweak I'm going to clean up some unused variables in sched.h + Revision 1.12 2004/07/20 22:29:55 reddawg assert: remade assert diff --git a/src/sys/sys/idt.c b/src/sys/sys/idt.c index b5639d8..fc1aa39 100644 --- a/src/sys/sys/idt.c +++ b/src/sys/sys/idt.c @@ -95,7 +95,7 @@ setVector(_int11, 11, dPresent + dInt + dDpl3); setVector(_int12, 12, dPresent + dInt + dDpl3); setTaskVector(13, dPresent + dTask + dDpl3, 0x38); - setVector(_vmmPageFault, 14, dPresent + dInt + dDpl3); + setVector(_vmm_pageFault, 14, dPresent + dInt + dDpl3); setVector(_sysCall, 128, dPresent + dTrap + dDpl3); setVector(_sysCallNew, 0x90, dPresent + dTrap + dDpl3); setVector(timerInt, 0x68, (dInt + dPresent + dDpl3)); @@ -427,6 +427,9 @@ /*** $Log$ + Revision 1.19 2004/07/24 15:12:56 reddawg + Now I'm current + Revision 1.18 2004/07/16 04:06:32 reddawg Tune ups this stuff should of been taken care of months ago diff --git a/src/sys/vmm/Makefile b/src/sys/vmm/Makefile index 77ba794..602497a 100644 --- a/src/sys/vmm/Makefile +++ b/src/sys/vmm/Makefile @@ -6,7 +6,7 @@ include ../Makefile.inc # Objects -OBJS = pagefault.o vmminit.o getfreevirtualpage.o copyvirtualspace.o setpageattributes.o unmappage.o getphysicaladdr.o getfreepage.o createvirtualspace.o memory.o paging.o +OBJS = page_fault.o pagefault.o vmminit.o getfreevirtualpage.o copyvirtualspace.o setpageattributes.o unmappage.o getphysicaladdr.o getfreepage.o createvirtualspace.o memory.o paging.o all: $(OBJS) diff --git a/src/sys/vmm/pagefault.c b/src/sys/vmm/pagefault.c index c4d7a44..f5a1011 100644 --- a/src/sys/vmm/pagefault.c +++ b/src/sys/vmm/pagefault.c @@ -30,8 +30,11 @@ #include #include #include +#include #include +static spinLock_t pageFaultSpinLock = SPIN_LOCK_INITIALIZER; + /************************************************************************ Function: void vmmPageFault(); @@ -44,34 +47,21 @@ A Paging System Also Start To Add Security Levels ************************************************************************/ -void vmmPageFault() { - uInt32 memAddr = 0,i = 0, pageTableIndex = 0,pageDirectoryIndex = 0; - uInt32 *pageDir,*pageTable; - uInt32 *src,*dst; +void vmm_pageFault(uInt32 memAddr) { + uInt32 i = 0, pageTableIndex = 0,pageDirectoryIndex = 0; + uInt32 *pageDir = 0x0,*pageTable = 0x0; + uInt32 *src = 0x0,*dst = 0x0; + + spinLock(&pageFaultSpinLock); + pageDir = (uInt32 *)parentPageDirAddr; - //Get Memory Address For Violation - asm volatile( - "movl %%cr2,%%eax \n" - "movl %%eax,%0 \n" - "sti \n" /* Solution suggested by geist */ - - : "=g" (memAddr) - ); //Calculate The Page Directory Index pageDirectoryIndex = (memAddr/(1024*4096)); //Calculate The Page Table Index pageTableIndex = ((memAddr-(pageDirectoryIndex*(1024*4096)))/4096); - if (pageDir[pageDirectoryIndex] == 0) { + if (pageDir[pageDirectoryIndex] == 0x0) { //Creat A Routine For Non Mapped Memory - kprintf("Segfault At Address: [0x%X][0x%X][%i]\n",memAddr,_current->tss.esp,_current->id); - //if ((uInt32)_current->tss.cr3 != (uInt32)kernelPageDirectory) { - // freeProcessPages(_current->id); - // } - //setTaskStatus(_current->id,EXITING); - //if (_current->id <= -1) { - //kPanic("Kernel Crashed.\n"); - // } - //schedule(); + kprintf("Segfault At Address: [0x%X][0x%X][%i], Not A Valid Page Table\n",memAddr,_current->tss.esp,_current->id); while (1); } else { @@ -93,29 +83,14 @@ //Unlink From Memory Map Allocated Page vmmUnmapPage((uInt32)dst,1); } + else if (pageTable[pageTableIndex] != 0x0) { + kprintf("pageTable: [0x%X]\n",pageTable[pageTableIndex]); + } else { //Need To Create A Routine For Attempting To Access Non Mapped Memory kprintf("Segfault At Address: [0x%X][0x%X][%i] Non Mapped\n",memAddr,_current->tss.esp,_current->id); - /* - kprintf("EAX: [0x%X],EBX: [0x%X]\n",_current->tss.eax,_current->tss.ebx); - kprintf("ECX: [0x%X],EDX: [0x%X]\n",_current->tss.ecx,_current->tss.edx); - kprintf("ESP: [0x%X],EPB: [0x%X]\n",_current->tss.esp,_current->tss.ebp); - kprintf("EIP: [0x%X],CR2: [0x%X]\n",_current->tss.eip,memAddr); - kprintf("CS: [0x%X],DS: [0x%X]\n",_current->tss.cs,_current->tss.ds); - kprintf("SS: [0x%X],ES: [0x%X]\n",_current->tss.ss,_current->tss.es); - kprintf("FS: [0x%X],GS: [0x%X]\n",_current->tss.gs,_current->tss.gs); - kprintf("EFLAGS: [0x%X] \n",_current->tss.eflags); - */ _current->state = DEAD; - /* - if ((uInt32)_current->tss.cr3 != (uInt32)kernelPageDirectory) { - freeProcessPages(_current->id); - } - setTaskStatus(_current->id,EXITING); - if (_current->id <= -1) { - panic(); - } - */ + spinUnlock(&pageFaultSpinLock); sched(); } } @@ -123,6 +98,7 @@ "movl %cr3,%eax\n" "movl %eax,%cr3\n" ); + spinUnlock(&pageFaultSpinLock); } /************************************************************************ @@ -132,27 +108,39 @@ Notes: ************************************************************************/ +/* asm( - ".global _vmmPageFault \n" - "_vmmPageFault: \n" - "xchgl %eax,(%esp) \n" - "pushl %ecx \n" - "pushl %edx \n" - "push %ds \n" - "push %es \n" - "push %fs \n" + ".global _vmmPageFault \n" + "_vmmPageFault: \n" + " xchgl %eax,(%esp) \n" + " movl 4(%esp),%eax \n" + " pushl %ecx \n" + " pushl %edx \n" + " push %ds \n" + " push %es \n" + " push %fs \n" + " pushl %eax \n" + "movl %cr2,%eax \n" + "sti \n" + "pushl %eax \n" "call vmmPageFault \n" - "pop %fs \n" - "pop %es \n" - "pop %ds \n" - "popl %edx \n" - "popl %ecx \n" - "popl %eax \n" - "iret \n" + "popl %eax \n" + "popl %eax \n" + "pop %fs \n" + "pop %es \n" + "pop %ds \n" + "popl %edx \n" + "popl %ecx \n" + "popl %eax \n" + "iret \n" ); +*/ /*** $Log$ + Revision 1.4 2004/07/24 17:47:28 reddawg + vmm_pageFault: deadlock resolved thanks to a propper solution suggested by geist + Revision 1.3 2004/07/19 02:05:26 reddawg vmmPageFault: had a potential memory leak here for one page it was still using sysID on certain COW scenarios diff --git a/src/sys/vmm/paging.c b/src/sys/vmm/paging.c index 446e5a1..e9a048b 100644 --- a/src/sys/vmm/paging.c +++ b/src/sys/vmm/paging.c @@ -136,7 +136,7 @@ vmmMemoryMap = (mMap *) vmmMemoryMapAddr; /* Print information on paging */ - kprintf("paging0 - Address: [0x%X], PagingISR Address: [0x%X]\n", kernelPageDirectory, &_vmmPageFault); + kprintf("paging0 - Address: [0x%X], PagingISR Address: [0x%X]\n", kernelPageDirectory, &_vmm_pageFault); /* Return so we know everything went well */ return (0x0); @@ -360,6 +360,9 @@ /*** $Log$ + Revision 1.7 2004/07/22 17:32:25 reddawg + I broke it hopefully + Revision 1.6 2004/07/19 02:06:35 reddawg cleaned out some debug code