diff --git a/src/bin/init/main.c b/src/bin/init/main.c index 7aaadf4..abf6e17 100755 --- a/src/bin/init/main.c +++ b/src/bin/init/main.c @@ -34,9 +34,15 @@ exit(1); } printf("Initializing System.\n"); - if (!fork()) { + startup: + i = fork(); + if (!i) { exec("login"); printf("Error Starting System\n"); } + else { + while (pidStatus(i)) { asm("nop"); } + goto startup; + } exit(1); } diff --git a/src/bin/shell/commands.c b/src/bin/shell/commands.c index 544acec..39033a6 100755 --- a/src/bin/shell/commands.c +++ b/src/bin/shell/commands.c @@ -29,20 +29,20 @@ #include "shell.h" int commands(inputBuffer *data) { - int cPid = 0x0; - printf("Test: [%s]\n",data->argv[0]); - if (0 == memcmp(data->argv[0], "uname", 5)) { + int cPid = 0x0,i = 0x0; + printf("Test: [%s]\n",data->argv[1]); + if (0 == memcmp(data->argv[1], "uname", 5)) { printf("UbixOS v0.01a " __DATE__" " __TIME__ " \n"); return(1); } - else if (0 == memcmp(data->argv[0], "exit", 4)) { + else if (0 == memcmp(data->argv[1], "exit", 4)) { exit(1); } - else if (0 == memcmp(data->argv[0], "mypid", 5)) { + else if (0 == memcmp(data->argv[1], "mypid", 5)) { printf("My Pid: [%i]\n",getpid()); return(1); } - else if (memcmp(data->argv[0],"stress", 6) == 0) { + else if (memcmp(data->argv[1],"stress", 6) == 0) { while (1) { cPid = fork(); printf("Pid: [%i]\n",cPid); @@ -56,14 +56,16 @@ } } - else if (memcmp(data->argv[0],"echo",4) == 0) { - printf("%s",data->argv[1]); + else if (memcmp(data->argv[1],"echo",4) == 0) { + for (i=2;i<=data->argv[0];i++) { + printf("%s",data->argv[i]); + } } - else if (memcmp(data->argv[0],"about",5) == 0) { + else if (memcmp(data->argv[1],"about",5) == 0) { printf("UbixOS Shell v0.99 (C) 2002\n"); printf("Base Command Line Interface\n"); - //printf("UbixOS Shell v0.99 (C) 2002\n"); - //printf("Base Command Line Interface\n"); + printf("UbixOS Shell v0.99 (C) 2002\n"); + printf("Base Command Line Interface\n"); } else { return(0); diff --git a/src/bin/shell/input.c b/src/bin/shell/input.c index 1aa5d9c..16cdd31 100755 --- a/src/bin/shell/input.c +++ b/src/bin/shell/input.c @@ -25,16 +25,24 @@ #include "shell.h" void parseInput(inputBuffer *buffer,char *data) { + int i = 0x0; char *tmp = 0x0; + buffer->argc = 0x1; while (data[0] == ' ') { data++; } + buffer->argv[1] = data; for (tmp = data;*tmp > 0;tmp++) { - if (*tmp == ' ') { + if ((*tmp == ' ') || (*tmp == '\n')) { *tmp = '\0'; - buffer->argc++; + buffer->argc++; + if (*(tmp+1) > 0) { + buffer->argv[buffer->argc] = tmp+1; + } } } - buffer->argv = &data; - printf("Data: %s\n",data); + buffer->argv[0] = &buffer->argc; + for (i=1;i<=buffer->argc;i++) { + printf("Data: (%i)[%s]\n",i,buffer->argv[i]); + } } \ No newline at end of file diff --git a/src/lib/libc/stdio/fread.c b/src/lib/libc/stdio/fread.c index 9e2e1f0..798103c 100755 --- a/src/lib/libc/stdio/fread.c +++ b/src/lib/libc/stdio/fread.c @@ -26,7 +26,7 @@ size_t fread(void *pointer,size_t size,size_t count, FILE *stream) { asm( "int %0\n" - : : "i" (0x80),"a" (9),"b" (pointer),"c" (size),"d" (stream) + : : "i" (0x80),"a" (9),"b" (pointer),"c" (&size),"d" (stream) ); return(count); } \ No newline at end of file diff --git a/src/sys/include/ubixos/idt.h b/src/sys/include/ubixos/idt.h index f2dbb2f..4a4cdfe 100755 --- a/src/sys/include/ubixos/idt.h +++ b/src/sys/include/ubixos/idt.h @@ -35,5 +35,12 @@ void _int4(); void _int5(); void _int6(); +void _int7(); +void _int8(); +void _int9(); +void _int10(); +void _int11(); +void _int12(); +void _int13(); #endif \ No newline at end of file diff --git a/src/sys/kernel/exec.c b/src/sys/kernel/exec.c index ca7bd00..12a637e 100755 --- a/src/sys/kernel/exec.c +++ b/src/sys/kernel/exec.c @@ -102,24 +102,22 @@ unmapPage((0x7C0000 + (0x1000 * i)),0); } //Now Lets Make A Clean Stack - newLoc = (char *)0x5DA000; - remapPage(findFreePage(_current->id),0x5DA000); - setPageAttribute(0x5DA000,(pageDefault | pageStack)); + newLoc = (char *)0x5DB000; remapPage(findFreePage(_current->id),0x5DB000); setPageAttribute(0x5DB000,(pageDefault | pageStack)); remapPage(findFreePage(_current->id),0x5DC000); setPageAttribute(0x5DC000,(pageDefault | pageStack)); - for (i=0;i<(4096 * 3);i++) { + for (i=0;i<(4096 * 2);i++) { newLoc[i] = 0x0; } i = 0x5DC000+4095; //Set All The Proper Information For The Task _current->tss.back_link = 0x0; - _current->tss.esp0 = i; + _current->tss.esp0 = 0x5000; _current->tss.ss0 = 0x10; - _current->tss.esp1 = 0x0; + _current->tss.esp1 = 0x4000; _current->tss.ss1 = 0x10; - _current->tss.esp2 = 0x0; + _current->tss.esp2 = 0x3000; _current->tss.ss2 = 0x10; _current->tss.eip = (long)eStart; _current->tss.eflags = 0x206; @@ -160,11 +158,11 @@ newProcess = findTask(); //Set All The Correct Thread Attributes newProcess->tss.back_link = 0x0; - newProcess->tss.esp0 = stack; + newProcess->tss.esp0 = 0x5000; newProcess->tss.ss0 = 0x10; - newProcess->tss.esp1 = 0x0; + newProcess->tss.esp1 = 0x4000; newProcess->tss.ss1 = 0x10; - newProcess->tss.esp2 = 0x0; + newProcess->tss.esp2 = 0x3000; newProcess->tss.ss2 = 0x10; newProcess->tss.cr3 = (unsigned int)kernelPageDirectory; newProcess->tss.eip = (unsigned int)tproc; @@ -258,6 +256,7 @@ } } else if (programHeader[i].phType == 3) { + /* binDynStr = (void *)binarySpace + sectionHeader[4].shOffset; binDynSym = (void *)binarySpace + sectionHeader[3].shOffset; libFd = fopen("libc.so","r"); @@ -290,7 +289,8 @@ } } } - } + } + */ } } //Get The Starting Point diff --git a/src/sys/kernel/idt.c b/src/sys/kernel/idt.c index 0ec74ab..5d4bb85 100755 --- a/src/sys/kernel/idt.c +++ b/src/sys/kernel/idt.c @@ -27,6 +27,7 @@ #include #include #include +#include descriptorTable(IDT, 256) { }; @@ -39,8 +40,8 @@ /* Sets Up Initial IDT Table */ void initIdt() { int i=0; - for (i=15;i<256;i++) { - setVector(intNull, i, dPresent + dInt + dDpl1); + for (i=0;i<256;i++) { + setVector(&intNull, i, dPresent + dInt + dDpl1); } asm ( "cli\n" @@ -52,14 +53,22 @@ : : "r" ((char *) &loadidt) ); - setVector(_int0,0,dPresent + dInt + dDpl1); - setVector(_int1,1,dPresent + dInt + dDpl1); - setVector(_int2,2,dPresent + dInt + dDpl1); - setVector(_int3,3,dPresent + dInt + dDpl1); - setVector(_int4,4,dPresent + dInt + dDpl1); - setVector(_int5,5,dPresent + dInt + dDpl1); - setVector(_int6,6,dPresent + dInt + dDpl1); - setVector(_sysCall,128,dPresent + dInt + dDpl1); + setVector(&_int0,0,dPresent + dTrap + dDpl1); + setVector(&_int1,1,dPresent + dTrap + dDpl1); + setVector(&_int2,2,dPresent + dTrap + dDpl1); + setVector(&_int3,3,dPresent + dTrap + dDpl1); + setVector(&_int4,4,dPresent + dTrap + dDpl1); + setVector(&_int5,5,dPresent + dTrap + dDpl1); + setVector(&_int6,6,dPresent + dTrap + dDpl1); + setVector(&_int7,7,dPresent + dTrap + dDpl1); + setVector(&_int8,8,dPresent + dTrap + dDpl1); + setVector(&_int9,9,dPresent + dTrap + dDpl1); + setVector(&_int10,10,dPresent + dTrap + dDpl1); + setVector(&_int11,11,dPresent + dTrap + dDpl1); + setVector(&_int12,12,dPresent + dTrap + dDpl1); + setVector(&_int13,13,dPresent + dTrap + dDpl1); + setVector(&_pageFault,14,dPresent + dTrap + dDpl1); + setVector(&_sysCall,128,dPresent + dTrap + dDpl1); } /* Sets Up IDT Vector */ @@ -130,3 +139,38 @@ schedule(); while(1); } + +void _int7() { + kprintf("int7: Device Not Available!\n"); + while(1); + } + +void _int8() { + kprintf("int8: Double Fault!\n"); + while(1); + } + +void _int9() { + kprintf("int9: Coprocessor Segment Overrun!\n"); + while(1); + } + +void _int10() { + kprintf("int10: Invalid TSS!\n"); + while(1); + } + +void _int11() { + kprintf("int11: Segment Not Present!\n"); + while(1); + } + +void _int12() { + kprintf("int12: Stack-Segment Fault!\n"); + while(1); + } + +void _int13() { + kprintf("int13: General Protection Fault!\n"); + while(1); + } diff --git a/src/sys/vmm/memory.c b/src/sys/vmm/memory.c index 3f7622d..29e19bc 100755 --- a/src/sys/vmm/memory.c +++ b/src/sys/vmm/memory.c @@ -144,7 +144,7 @@ If We Found A Free Page Set It To Not Available After That Set Its Own And Return The Address */ - if (memoryMap[i].status == memAvail) { + if ((memoryMap[i].status == memAvail) && (memoryMap[i].cowCounter == 0)) { memoryMap[i].status = memNotavail; memoryMap[i].pid = pid; freePages--; @@ -170,8 +170,10 @@ void adjustCowCounter(uLong baseAddr,int adjustment) { int memoryMapIndex = (baseAddr/4096); //Adjust COW Counter + kprintf("COW (%i[%i]%x)",memoryMapIndex,memoryMap[memoryMapIndex].cowCounter,baseAddr); memoryMap[memoryMapIndex].cowCounter += adjustment; - if (memoryMap[memoryMapIndex].cowCounter <= 0) { + kprintf("(%i[%i]%x)\n",memoryMapIndex,memoryMap[memoryMapIndex].cowCounter,baseAddr); + if (memoryMap[memoryMapIndex].cowCounter == 0) { memoryMap[memoryMapIndex].status = memAvail; memoryMap[memoryMapIndex].cowCounter = 0x0; memoryMap[memoryMapIndex].pid = -2; @@ -203,7 +205,6 @@ //If The Page Is COW Adjust COW Counter if (((uLong)tmpPageTable[x] & pageCow) == pageCow) { adjustCowCounter(((uLong)tmpPageTable[x] & 0xFFFFF000),-1); - //kprintf("Cow Page"); } } } @@ -212,7 +213,7 @@ for (i=0;iid); freeProcessPages(_current->id); _current->status = EMPTY; schedule(); @@ -641,16 +641,16 @@ for (i=0;iid); freeProcessPages(_current->id); _current->status = EMPTY; schedule();