diff --git a/src/bin/init/main.c b/src/bin/init/main.c index 9ecc9b3..29da1d2 100755 --- a/src/bin/init/main.c +++ b/src/bin/init/main.c @@ -45,9 +45,8 @@ if (!fork()) { exec("shell"); printf("Error Starting Shell\n"); - while(1) { - printf("."); - } + while(1); } + while(1); exit(1); } \ No newline at end of file diff --git a/src/bin/shell/main.c b/src/bin/shell/main.c index 33da392..234aa38 100755 --- a/src/bin/shell/main.c +++ b/src/bin/shell/main.c @@ -48,7 +48,7 @@ int main() { unsigned char buffer[256],*tmp; - int cPid = 0; + int cPid = 0,i = 0; tmp = &buffer; while (1) { printf("UbixOS: "); @@ -60,7 +60,12 @@ cPid = fork(); printf("Pid: [%i]\n",cPid); if (!cPid) { - exec(tmp); + //exec(tmp); + for (i=1;i<=20;i++) { + printf("[%i]",i); + } + printf("\n"); + exit(1); } else { while (pidStatus(cPid)); diff --git a/src/sys/drivers/keyboard.c b/src/sys/drivers/keyboard.c index ca5a830..0466885 100755 --- a/src/sys/drivers/keyboard.c +++ b/src/sys/drivers/keyboard.c @@ -26,6 +26,7 @@ #include #include #include +#include #include unsigned int keystrokeBuffer[255]; @@ -119,7 +120,181 @@ /* */ { 0x5000, 0, 0, 0, 0, 0, 0, 0}, /* */ { 0x5100, 0, 0, 0, 0, 0, 0, 0}, /* */ { 0x5200, 0, 0, 0, 0, 0, 0, 0}, -/* */ { 0x5300, 0, 0, 0, 0, 0, 0, 0} +/* */ { 0x5300, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0, 0, 0, 0, 0, 0, 0}, +/* */ { 0, 0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0, 0, 0, 0, 0} }; void initKeyboard() { setVector(keyboardIsr, mVec+1, dPresent + dInt + dDpl3); /* IRQ1 Handler */ @@ -187,9 +362,17 @@ else if (controlKeys == 2) { keyMap = 2; } else if (controlKeys == 4) { keyMap = 3; } else { keyMap = 0; } - keystrokeBuffer[keystrokeBuffersize] = keyboardMap[key][keyMap]; - keystrokeBuffersize++; + //If Key Is Not Null Add It To Handler + if ((uInt)(keyboardMap[key][keyMap]) > 0) { + keystrokeBuffer[keystrokeBuffersize] = keyboardMap[key][keyMap]; + keystrokeBuffersize++; + } + else { + //kprintf("Key: [%i], KeyMap: [%i],Key Char: [%i]\n",key,keyMap,keyboardMap[key][keyMap]); + } outportByte(mPic, eoi); + //Return + return; } void setLeds() { diff --git a/src/sys/include/vmm/paging.h b/src/sys/include/vmm/paging.h index 1efa7a3..078cc41 100755 --- a/src/sys/include/vmm/paging.h +++ b/src/sys/include/vmm/paging.h @@ -51,6 +51,7 @@ void *getFreePage(pid_t pid); void *getPhysicalAddr(uLong pageAddr); void setPageAttribute(uLong pageAddr,int attributes); +void clearVirtualPage(uLong pageAddr); void pageFault(); void _pageFault(); diff --git a/src/sys/kernel/fork.c b/src/sys/kernel/fork.c index 459e88a..32ccd13 100755 --- a/src/sys/kernel/fork.c +++ b/src/sys/kernel/fork.c @@ -53,6 +53,7 @@ newProcess->tss.esp2 = 0x0; newProcess->tss.ss2 = 0x10; newProcess->tss.eflags = 0x206; + newProcess->tss.ebx = ret; newProcess->tss.esi = 0x0; newProcess->tss.edi = 0x0; newProcess->tss.es = 0x10; @@ -75,15 +76,12 @@ newProcess->tss.cr3 = (long)copyVirtualSpace(newProcess->id); newProcess->status = RUNNING; childStart: - //Set Up Pointer to Return Value - if (_current->id == newProcess->id) { - //If We Are The Child We Must Return 0 - *ret = 0; - } - else { - //If We Are The Parent We Must Return The Childs PID - *ret = newProcess->id; + if (ret == 0) { + asm("":"=b" (ret)); } + //Set ret Equal To Id For Parent + *ret = newProcess->id; + if (*ret <= 0) { *ret = 0; } //Return return; } \ No newline at end of file diff --git a/src/sys/kernel/schedule.c b/src/sys/kernel/schedule.c index e4d44e5..e42002e 100755 --- a/src/sys/kernel/schedule.c +++ b/src/sys/kernel/schedule.c @@ -40,6 +40,7 @@ int currentProc = -1; +int lastPid = -1; kTask_t *taskList = (kTask_t *)0xE0800000; kTask_t *_current,*_usedMath = 0x0; @@ -84,10 +85,17 @@ /* Finds A Free Task */ kTask_t * findTask() { int i = 0; - for (i=0;i 0) { + //Clear The Page First For Security Reasons + clearVirtualPage(dest); freePage(((uLong)pageTable[destPageTableIndex] & 0xFFFFF000)); } //Set The Source Address In The Destination