diff --git a/src/bin/shell/commands.c b/src/bin/shell/commands.c index 7345874..cd794ef 100644 --- a/src/bin/shell/commands.c +++ b/src/bin/shell/commands.c @@ -81,7 +81,7 @@ } } else if (memcmp(data->args->arg,"test2", 5) == 0) { - for (i=0x0;i<3;i++) { + for (i=0x0;i<500;i++) { cPid = fork(); if (cPid == 0x0) { printf("Pid: [%i:%i]\n",cPid,i); @@ -90,10 +90,6 @@ } else { printf("Childs Pid: [%i]\n",cPid); - /* - while (pidStatus(cPid) > 0) - sched_yield(); - */ } } } diff --git a/src/sys/include/isa/atkbd.h b/src/sys/include/isa/atkbd.h index eba9876..6589312 100644 --- a/src/sys/include/isa/atkbd.h +++ b/src/sys/include/isa/atkbd.h @@ -37,8 +37,9 @@ #define ledScrolllock 1 #define ledCapslock 4 -int atkbd_init(); -void keyboardISR(); +int atkbd_init(); +void atkbd_isr(); + void keyboardHandler(); void setLED(); @@ -46,6 +47,10 @@ /*** $Log$ + Revision 1.3 2004/07/09 13:34:51 reddawg + keyboard: keyboardInit to atkbd_init + Adjusted initialization routines + Revision 1.2 2004/05/21 14:57:16 reddawg Cleaned up diff --git a/src/sys/include/ubixos/sched.h b/src/sys/include/ubixos/sched.h index 737a575..79b31ed 100644 --- a/src/sys/include/ubixos/sched.h +++ b/src/sys/include/ubixos/sched.h @@ -40,7 +40,7 @@ #include -typedef enum { PLACEHOLDER=-2,DEAD=-1,NEW=0,READY=1,RUNNING=2,IDLE=3 } tState; +typedef enum { PLACEHOLDER=-2,DEAD=-1,NEW=0,READY=1,RUNNING=2,IDLE=3,FORK=4 } tState; struct osInfo { uInt8 timer; @@ -101,6 +101,9 @@ /*** $Log$ + Revision 1.14 2004/07/21 17:15:02 reddawg + removed garbage + Revision 1.13 2004/07/21 14:43:14 flameshadow add: added cwc (current working container) to the osInfo strut diff --git a/src/sys/init/main.c b/src/sys/init/main.c index b17bdc5..340bc55 100644 --- a/src/sys/init/main.c +++ b/src/sys/init/main.c @@ -49,11 +49,12 @@ 0x28 - Ring 3 CS 0x30 - Ring 3 DS 0x38 - GPF TSS + 0x40 - Stack Fault TSS Notes: *****************************************************************************************/ -ubixDescriptorTable(ubixGDT,8) { +ubixDescriptorTable(ubixGDT,9) { {dummy:0}, ubixStandardDescriptor(0x0, 0xFFFFF, (dCode + dRead + dBig + dBiglim)), ubixStandardDescriptor(0x0, 0xFFFFF, (dData + dWrite + dBig + dBiglim)), @@ -62,11 +63,12 @@ ubixStandardDescriptor(0x0, 0xFFFFF, (dCode + dWrite + dBig + dBiglim + dDpl3)), ubixStandardDescriptor(0x0, 0xFFFFF, (dData + dWrite + dBig + dBiglim + dDpl3)), ubixStandardDescriptor(0x4200, (sizeof(struct tssStruct)), (dTss)), + ubixStandardDescriptor(0x6200, (sizeof(struct tssStruct)), (dTss)), }; struct { unsigned short limit __attribute__ ((packed)); union descriptorTableUnion *gdt __attribute__ ((packed)); - } loadGDT = { (8 * sizeof(union descriptorTableUnion) - 1), ubixGDT }; + } loadGDT = { (9 * sizeof(union descriptorTableUnion) - 1), ubixGDT }; /***************************************************************************************** Functoin: int main() @@ -113,6 +115,15 @@ /*** $Log$ + Revision 1.64 2004/07/28 00:17:05 reddawg + Major: + Disconnected page 0x0 from the system... Unfortunately this broke many things + all of which have been fixed. This was good because nothing deferences NULL + any more. + + Things affected: + malloc,kmalloc,getfreepage,getfreevirtualpage,pagefault,fork,exec,ld,ld.so,exec,file + Revision 1.63 2004/07/27 12:02:01 reddawg chg: fixed marks bug readFile did a lookup which is why it looked like it was loopping so much diff --git a/src/sys/isa/atkbd.c b/src/sys/isa/atkbd.c index 7a8bb43..b036146 100644 --- a/src/sys/isa/atkbd.c +++ b/src/sys/isa/atkbd.c @@ -149,7 +149,7 @@ ************************************************************************/ int atkbd_init() { /* Insert the IDT vector for the keyboard handler */ - setVector(&keyboardISR, mVec+1, dPresent + dInt + dDpl3); + setVector(&atkbd_isr, mVec+0x1, dPresent + dInt + dDpl0); /* Set the LEDS to their defaults */ setLED(); @@ -158,7 +158,7 @@ irqEnable(0x1); /* Print out information on keyboard */ - kprintf("atkbd0 - Address: [0x%X], Keyboard Buffer: [0x%X], Buffer Size [%i]\n",&keyboardISR,&stdinBuffer,512); + kprintf("atkbd0 - Address: [0x%X], Keyboard Buffer: [0x%X], Buffer Size [%i]\n",&atkbd_isr,&stdinBuffer,512); /* Return so we know everything went well */ return(0x0); @@ -169,24 +169,35 @@ */ asm( - ".globl keyboardISR \n" - "keyboardISR: \n" - " sti \n" + ".globl atkbd_isr \n" + "atkbd_isr: \n" " pusha \n" /* Save all registers */ - " mov $0x60,%dx \n" - " inb %dx,%al \n" - " push %eax \n" - " call keyboardHandler \n" - " mov $0x20,%dx \n" /* The Following Sends Our EOI To The MPIC */ + " call keyboardHandler \n" + " mov $0x20,%dx \n" " mov $0x20,%ax \n" " outb %al,%dx \n" - " pop %eax \n" + /* " sti \n" */ " popa \n" " iret \n" /* Exit interrupt */ ); + +static int atkbd_scan() { + int code = 0x0; + int val = 0x0; + + code = inportByte(0x60); + val = inportByte(0x61); + + outportByte(0x61,val | 0x80); + outportByte(0x61,val); + + return(code); + } -void keyboardHandler(unsigned int key) { +void keyboardHandler() { + int key = atkbd_scan(); + if (key > 255) return; @@ -240,8 +251,8 @@ stdinSize++; break; case 0x3: - endTask(_current->id); - kprintf("CTRL-C pressed\n"); + //endTask(_current->id); + //kprintf("CTRL-C pressed\n"); break; default: stdinBuffer[stdinSize] = keyboardMap[key][keyMap]; @@ -252,8 +263,7 @@ else { switch ((keyboardMap[key][keyMap] >> 8)) { case 0x30: - kprintf("Changing Consoles[0x%X:0x%X]\n",_current->id,_current);//schedFindTask(0x0),); - /* changeConsole((keyboardMap[key][keyMap] & 0xFF)); */ + //kprintf("Changing Consoles[0x%X:0x%X]\n",_current->id,_current); break; default: break; @@ -289,6 +299,9 @@ /*** $Log$ + Revision 1.17 2004/07/28 18:45:39 reddawg + movement of files + Revision 1.16 2004/07/28 17:07:25 reddawg MPI: moved the syscalls diff --git a/src/sys/isa/fdc.c b/src/sys/isa/fdc.c index 4eb3d1e..ed1a635 100644 --- a/src/sys/isa/fdc.c +++ b/src/sys/isa/fdc.c @@ -80,19 +80,7 @@ ".globl floppyIsr \n" "floppyIsr: \n" " pusha \n" - /* - " pushw %ds \n" - " pushw %es \n" - " pushw %ss \n" - " pushw %ss \n" - " popw %ds \n" - " popw %es \n" - */ " call floppyIsrhndlr \n" - /* - " popw %es \n" - " popw %ds \n" - */ " popa \n" " iret \n" ); @@ -315,6 +303,9 @@ /*** $Log$ + Revision 1.17 2004/07/27 08:03:36 reddawg + chg: stopped push all these extra registers I can't find a good reason as to why I was doing it + Revision 1.16 2004/07/22 17:32:25 reddawg I broke it hopefully diff --git a/src/sys/kernel/fork.c b/src/sys/kernel/fork.c index 2ba031c..aeed0d5 100644 --- a/src/sys/kernel/fork.c +++ b/src/sys/kernel/fork.c @@ -67,7 +67,7 @@ int forkCopyProcess(struct taskStruct *newProcess,long ebp,long edi,long esi,long none,long ebx,long ecx,long edx,long eip,long cs,long eflags,long esp,long ss) { assert(newProcess); assert(_current); - + /* Set Up New Tasks Information */ newProcess->tss.eip = eip; sprintf(newProcess->oInfo.cwd,_current->oInfo.cwd); @@ -101,13 +101,23 @@ newProcess->tss.io_map = 0x8000; /* Create A Copy Of The VM Space For New Task */ newProcess->tss.cr3 = (uInt32)vmmCopyVirtualSpace(newProcess->id); - newProcess->state = READY; + newProcess->state = FORK; + while (newProcess->state == FORK); /* Return Id of Proccess */ return(newProcess->id); } /*** $Log$ + Revision 1.16 2004/07/28 00:17:05 reddawg + Major: + Disconnected page 0x0 from the system... Unfortunately this broke many things + all of which have been fixed. This was good because nothing deferences NULL + any more. + + Things affected: + malloc,kmalloc,getfreepage,getfreevirtualpage,pagefault,fork,exec,ld,ld.so,exec,file + Revision 1.15 2004/07/25 06:04:00 reddawg Last of my fixes for the morning diff --git a/src/sys/kernel/sched.c b/src/sys/kernel/sched.c index 935d205..8e6c69b 100644 --- a/src/sys/kernel/sched.c +++ b/src/sys/kernel/sched.c @@ -156,6 +156,8 @@ for (tmpTask = _current->next; tmpTask; tmpTask = tmpTask->next) { if (tmpTask->state > 0x0) { _current = tmpTask; + if (_current->state == FORK) + _current->state = READY; break; } /* @@ -248,7 +250,7 @@ kTask_t *tmpTask = 0x0; /* Checking each task from the prio queue */ - for (tmpTask = taskList; tmpTask; tmpTask = tmpTask->next) { + for (tmpTask = taskList; tmpTask != 0x0; tmpTask = tmpTask->next) { if (tmpTask->id == id) { if (_current == tmpTask) kpanic("you can not delete yourself!!!\n"); @@ -333,6 +335,9 @@ /*** $Log$ + Revision 1.22 2004/07/28 16:29:30 reddawg + old sched back + Revision 1.20 2004/07/25 06:04:00 reddawg Last of my fixes for the morning diff --git a/src/sys/kernel/spinlock.c b/src/sys/kernel/spinlock.c index 3328f8d..1113048 100644 --- a/src/sys/kernel/spinlock.c +++ b/src/sys/kernel/spinlock.c @@ -55,8 +55,7 @@ void spinLock(spinLock_t *lock) { while (!spinTryLock(lock)) - while (*lock == 1) - schedYield(); + while (*lock == 1); } int spinLockLocked(spinLock_t *lock) { @@ -66,6 +65,12 @@ /*** $Log$ + Revision 1.12 2004/07/28 22:35:24 reddawg + ok couldn't resist last commit hopefully it doesnt cause any bugs but if it does + in spinlock.c take the while (*lock == 1) schedYield(); and just make it + while (*lock == 1); however I felt spining burns cpu time so if we yield it will + run a new task should make stress a bit faster + Revision 1.11 2004/07/21 17:11:18 reddawg A Quick tweak I'm going to clean up some unused variables in sched.h diff --git a/src/sys/kernel/timer.S b/src/sys/kernel/timer.S index 3f5f92b..a0d0f73 100644 --- a/src/sys/kernel/timer.S +++ b/src/sys/kernel/timer.S @@ -32,11 +32,11 @@ .code32 timerInt: pusha /* Save all of the registers */ - movl systemVitals,%ecx /* Put Location Of System Vitals Into ECX */ - incl 4(%ecx) /* Increment sysTicks our 1000ms counter */ mov $0x20,%dx /* The Following Sends Our EOI To The MPIC */ mov $0x20,%ax - outb %al,%dx + outb %al,%dx + movl systemVitals,%ecx /* Put Location Of System Vitals Into ECX */ + incl 4(%ecx) /* Increment sysTicks our 1000ms counter */ movl 4(%ecx),%eax /* Increment our sysUptime by 1S if 1000MS */ movl $1000,%ebx /* Have Passed */ xor %edx,%edx @@ -58,6 +58,9 @@ /*** $Log$ + Revision 1.4 2004/07/23 17:49:59 reddawg + atkbd: adjust the timing issue on the driver hopefully it will work fine now + Revision 1.3 2004/07/22 17:32:25 reddawg I broke it hopefully diff --git a/src/sys/sys/idt.c b/src/sys/sys/idt.c index f44fae5..68bb6d4 100644 --- a/src/sys/sys/idt.c +++ b/src/sys/sys/idt.c @@ -62,6 +62,7 @@ int idt_init() { int i = 0x0; + struct tssStruct *sfTSS = (struct tssStruct *)0x6200; struct tssStruct *gpfTSS = (struct tssStruct *)0x4200; /* Set up default vector table for all possible 256 interrupts */ @@ -91,8 +92,7 @@ setVector(_int5, 5, dPresent + dInt + dDpl3); setVector(_int6, 6, dPresent + dInt + dDpl3); setVector(_int7,7,dPresent + dInt + dDpl3); - setVector(_int8,8,dPresent + dInt + dDpl3); - //setTaskVector(8,dPresent + dTask + dDpl3, 0x38); + setTaskVector(8,dPresent + dTask + dDpl3, 0x40); setVector(_int9, 9, dPresent + dInt + dDpl3); setVector(_int10, 10, dPresent + dInt + dDpl3); setVector(_int11, 11, dPresent + dInt + dDpl3); @@ -114,8 +114,8 @@ gpfTSS->cr3 = (unsigned int)kernelPageDirectory; gpfTSS->eip = (unsigned int)&_int13; gpfTSS->eflags = 0x206; - gpfTSS->esp = 0x1CFFF; - gpfTSS->ebp = 0x1CFFF; + gpfTSS->esp = 0x1D000; + gpfTSS->ebp = 0x1D000; gpfTSS->esi = 0x0; gpfTSS->edi = 0x0; gpfTSS->es = 0x10; @@ -127,7 +127,20 @@ gpfTSS->ldt = 0x0; gpfTSS->trace_bitmap = 0x0000; gpfTSS->io_map = 0x8000; - + + memset(sfTSS,0x0,sizeof(struct tssStruct)); + sfTSS->cr3 = (unsigned int)kernelPageDirectory; + sfTSS->eip = (unsigned int)&_int8; + sfTSS->eflags = 0x206; + sfTSS->esp = 0x1C000; + sfTSS->ebp = 0x1C000; + sfTSS->es = 0x10; + sfTSS->cs = 0x08; + sfTSS->ss = 0x10; + sfTSS->ds = 0x10; + sfTSS->fs = 0x10; + sfTSS->gs = 0x10; + sfTSS->io_map = 0x8000; /* Print out information for the IDT */ kprintf("idt0 - Address: [0x%X]\n", &ubixIDT); @@ -219,8 +232,21 @@ } void _int8() { + struct tssStruct *sfTSS = (struct tssStruct *)0x6200; kprintf("int8: Double Fault! [%i]\n",_current->id); - endTask(_current->id); + sfTSS->cr3 = (unsigned int)kernelPageDirectory; + sfTSS->eip = (unsigned int)&_int8; + sfTSS->eflags = 0x206; + sfTSS->esp = 0x1C000; + sfTSS->ebp = 0x1C000; + sfTSS->es = 0x10; + sfTSS->cs = 0x08; + sfTSS->ss = 0x10; + sfTSS->ds = 0x10; + sfTSS->fs = 0x10; + sfTSS->gs = 0x10; + sfTSS->io_map = 0x8000; + while (1); } void _int9() { @@ -247,11 +273,6 @@ schedYield(); } -/* - * void _int13() { kprintf("int13: General Protection Fault!\n"); - * kprintf("Task Id: [%i]\n",_current->id); while(1); } - */ - void _int13() { uInt8 *ip = 0x0; uInt16 *stack = 0x0, *ivt = 0x0; @@ -430,6 +451,9 @@ /*** $Log$ + Revision 1.24 2004/07/28 22:23:02 reddawg + make sure it still works before I goto bed + Revision 1.23 2004/07/28 15:05:43 reddawg Major: Pages now have strict security enforcement.