diff --git a/src/bin/Makefile b/src/bin/Makefile index e279384..96bf00e 100644 --- a/src/bin/Makefile +++ b/src/bin/Makefile @@ -1,7 +1,7 @@ # $Id$ # The System Makefile (C) 2002 The UbixOS Project -all: init-bin login-bin shell-bin ls-bin clock-bin cp-bin fdisk-bin format-bin disklabel-bin ubistry-bin edit-bin ld-bin +all: init-bin login-bin shell-bin ls-bin clock-bin cp-bin fdisk-bin format-bin disklabel-bin ubistry-bin edit-bin ld-bin ttyd-bin # test-bin pwd-bin cat-bin de-bin goofball-bin init-bin: init @@ -61,6 +61,9 @@ edit-bin: edit (cd edit;make) +ttyd-bin: ttyd + (cd ttyd;make) + clean: (cd cp;make clean) (cd fdisk;make clean) @@ -75,3 +78,4 @@ (cd ubistry;make clean) (cd ld;make clean) (cd edit;make clean) + (cd ttyd;make clean) diff --git a/src/bin/init/main.c b/src/bin/init/main.c index 3724155..9b6b702 100644 --- a/src/bin/init/main.c +++ b/src/bin/init/main.c @@ -36,10 +36,10 @@ int main(int argc,char **argv) { int i=0x0; - mpiMessage_t myMsg; + mpi_message_t myMsg; /* Create a mailbox for this task */ - if (mpiCreateMbox("init") != 0x0) { + if (mpi_createMbox("init") != 0x0) { printf("Error: Failed to creating mail box: init\n"); exit(0x1); } @@ -52,6 +52,17 @@ printf("Initializing UbixOS\n"); + /* Start TTYD */ + i = fork(); + if (0x0 == i) { + exec("sys:/ttyd",0x0,0x0); + printf("Error: Could not start TTYD\n"); + exit(0x0); + } + while (pidStatus(i) > 0x0) + sched_yield(); + + i = fork(); if (0x0 == i) { printf("Starting Ubix Registry (ubistry)\n"); @@ -71,29 +82,33 @@ printf("Error Starting System\n"); exit(0x0); } - else { - while (pidStatus(i) > 0x0) { - fetchAgain: - if (mpiFetchMessage("init",&myMsg) == 0x0) { - switch (myMsg.type) { - case 10: - printf("Exec: (%s)\n",myMsg.data); - break; - default: - printf("MailBox: init Received Message %i:%s\n",myMsg.type,myMsg.data); - break; - } - goto fetchAgain; + + while (pidStatus(i) > 0x0) { + fetchAgain: + if (mpi_fetchMessage("init",&myMsg) == 0x0) { + switch (myMsg.header) { + case 10: + printf("Exec: (%s)\n",myMsg.data); + break; + default: + printf("MailBox: init Received Message %i:%s\n",myMsg.header,myMsg.data); + break; } - sched_yield(); + goto fetchAgain; } - goto startup; + sched_yield(); } + printf("login exited?"); + goto startup; + return(0x0); } /*** $Log$ + Revision 1.16 2004/08/01 20:47:59 reddawg + Minor changes + Revision 1.15 2004/07/28 17:07:25 reddawg MPI: moved the syscalls diff --git a/src/bin/login/main.c b/src/bin/login/main.c index 70d2e7f..4ba7af5 100644 --- a/src/bin/login/main.c +++ b/src/bin/login/main.c @@ -73,7 +73,6 @@ exit(0x1); } - printf("Starting Login Daemon\n"); fd = fopen("sys:/userdb","r"); if (fd->fd == 0x0) { printf("file not foun!!!\n"); diff --git a/src/bin/shell/commands.c b/src/bin/shell/commands.c index d457577..ce88c66 100644 --- a/src/bin/shell/commands.c +++ b/src/bin/shell/commands.c @@ -41,6 +41,8 @@ int commands(inputBuffer *data) { int cPid = 0x0,i = 0x0,x = 0x0; + mpi_message_t cmdMsg; + if (data == NULL) return 1; if (data->args->arg == NULL) return 1; if (*data->args->arg == '\0') return 1; @@ -130,7 +132,9 @@ } else if (memcmp(data->args->arg,"msg",3) == 0x0) { printf("Posting Message\n"); - mpiPostMessage(data->argv[1],atoi(data->argv[2]),data->argv[3]); + cmdMsg.header = atoi(data->argv[2]); + sprintf(cmdMsg.data,data->argv[3]); + mpi_postMessage(data->argv[1],0x1,&cmdMsg); } else if (memcmp(data->args->arg,"mkdir",5) == 0x0) { if (data->argv[1]) { @@ -141,7 +145,9 @@ printf("UID: %i, GID: %i\n",getuid(),getgid()); } else if (!strcmp(data->argv[0],"reboot")) { - mpiPostMessage("system",1000,0x0); + cmdMsg.header = 1000; + cmdMsg.data[0] = '\0'; + mpi_postMessage("system",0x1,&cmdMsg); } else { return(0); diff --git a/src/bin/ubistry/message.c b/src/bin/ubistry/message.c index d060524..e29d9ad 100644 --- a/src/bin/ubistry/message.c +++ b/src/bin/ubistry/message.c @@ -37,7 +37,7 @@ int ubistryInitMbox(char *name) { - if (mpiCreateMbox(name) != 0x0) { + if (mpi_createMbox(name) != 0x0) { printf("Error: Error Creating Mail Box: [%s]\n",name); return(-1); } @@ -46,13 +46,13 @@ } void ubistryProcessMessages() { - mpiMessage_t msg; + mpi_message_t msg; struct ubistryKey *tmpKey = 0x0; char *key,*value; mfmStart: - if (mpiFetchMessage("ubistry",&msg) == 0x0) { - switch (msg.type) { + if (mpi_fetchMessage("ubistry",&msg) == 0x0) { + switch (msg.header) { case 50: tmpKey = ubistryFindKey(msg.data); if (tmpKey == 0x0) @@ -67,7 +67,7 @@ ubistryAddKey(key,value); break; case 666: - mpiDestroyMbox("ubistry"); + mpi_destroyMbox("ubistry"); if (fork() == 0x0) { printf("ubistry: Restarting\n"); exec("ubistry@sys",0x0,0x0); @@ -77,7 +77,7 @@ } break; default: - printf("ubistry: Command (%i) With Data (%s) Not Valid\n",msg.type,msg.data); + printf("ubistry: Command (%i) With Data (%s) Not Valid\n",msg.header,msg.data); break; } goto mfmStart; @@ -87,5 +87,9 @@ /*** $Log$ + Revision 1.1 2004/05/26 15:41:20 reddawg + ubistry: added command 666 which will restart the registry server also added + command 51 to add a key format key,value + END ***/ diff --git a/src/include/sys/mpi.h b/src/include/sys/mpi.h index 41d7737..91ec6f5 100644 --- a/src/include/sys/mpi.h +++ b/src/include/sys/mpi.h @@ -34,25 +34,28 @@ #define MESSAGE_LENGTH 248 -struct mpiMessage { +struct mpi_message { char data[MESSAGE_LENGTH]; - uInt32 type; - struct mpiMessage *next; + uInt32 header; + struct mpi_message *next; }; -typedef struct mpiMessage mpiMessage_t; +typedef struct mpi_message mpi_message_t; -int mpiCreateMbox(char *); -int mpiDestroyMbox(char *); -int mpiPostMessage(char *,uInt32,void *); -int mpiFetchMessage(char *,mpiMessage_t *); -int mpiSpam(uInt32 type,void *); +int mpi_createMbox(char *); +int mpi_destroyMbox(char *); +int mpi_postMessage(char *,uInt32,mpi_message_t *); +int mpi_fetchMessage(char *,mpi_message_t *); +int mpi_fpam(uInt32 type,void *); #endif /*** $Log$ + Revision 1.4 2004/05/28 03:53:30 reddawg + mpi: oops can't forget userland + Revision 1.3 2004/05/26 15:39:22 reddawg mpi: brought mpiDestroyMbox(char *name) in to the userland diff --git a/src/lib/libc_old/sys/mpi.c b/src/lib/libc_old/sys/mpi.c index 3b05990..9eacac7 100644 --- a/src/lib/libc_old/sys/mpi.c +++ b/src/lib/libc_old/sys/mpi.c @@ -29,7 +29,7 @@ #include -int mpiCreateMbox(char *name) { +int mpi_createMbox(char *name) { volatile int status = 0x0; asm volatile( "int %0\n" @@ -39,7 +39,7 @@ return(status); } -int mpiDestroyMbox(char *name) { +int mpi_destroyMbox(char *name) { volatile int status = 0x0; asm volatile( "int %0\n" @@ -49,15 +49,15 @@ return(status); } -int mpiPostMessage(char *name,uInt32 type,void *data) { +int mpi_postMessage(char *name,uInt32 type,mpi_message_t *msg) { asm volatile( "int %0\n" - : : "i" (0x80),"a" (52),"b" (name),"c" (&type),"d" (data) + : : "i" (0x80),"a" (52),"b" (name),"c" (&type),"d" (msg) ); return(type); } -int mpiFetchMessage(char *name,mpiMessage_t *msg) { +int mpi_fetchMessage(char *name,mpi_message_t *msg) { volatile int status = 0x0; asm volatile( "int %0\n" @@ -66,7 +66,7 @@ return(status); } -int mpiSpam(uInt32 type,void *data) { +int mpi_spam(uInt32 type,void *data) { volatile int status = 0x0; asm volatile( "int %0\n" @@ -77,6 +77,9 @@ /*** $Log$ + Revision 1.3 2004/08/02 18:50:13 reddawg + Updates to make some variable volatile to make work with gcc 3.3. However there are still some issues but we have not caused new issues with gcc 2.95 + Revision 1.2 2004/05/26 15:39:22 reddawg mpi: brought mpiDestroyMbox(char *name) in to the userland diff --git a/src/sys/include/isa/pit.h b/src/sys/include/isa/pit.h index accba67..ebaf07e 100644 --- a/src/sys/include/isa/pit.h +++ b/src/sys/include/isa/pit.h @@ -30,7 +30,7 @@ #ifndef _PIT_H #define _PIT_H -#define PIT_TIMER 1000 +#define PIT_TIMER 200 int pit_init(); @@ -38,6 +38,9 @@ /*** $Log$ + Revision 1.5 2004/07/16 04:06:32 reddawg + Tune ups this stuff should of been taken care of months ago + Revision 1.4 2004/07/16 01:08:58 reddawg Whew we work once again diff --git a/src/sys/include/mpi/mpi.h b/src/sys/include/mpi/mpi.h index 94a8952..6077f06 100644 --- a/src/sys/include/mpi/mpi.h +++ b/src/sys/include/mpi/mpi.h @@ -35,35 +35,39 @@ #define MESSAGE_LENGTH 248 -struct mpiMessage { - char data[MESSAGE_LENGTH]; - uInt32 type; - struct mpiMessage *next; +struct mpi_message { + char data[MESSAGE_LENGTH]; + uInt32 header; + pidType pid; + struct mpi_message *next; }; -struct mpiMbox { - struct mpiMbox *next; - struct mpiMbox *prev; - struct mpiMessage *msg; - struct mpiMessage *msgLast; - char name[64]; - pidType pid; +struct mpi_mbox { + struct mpi_mbox *next; + struct mpi_mbox *prev; + struct mpi_message *msg; + struct mpi_message *msgLast; + char name[64]; + pidType pid; }; -typedef struct mpiMbox mpiMbox_t; -typedef struct mpiMessage mpiMessage_t; +typedef struct mpi_mbox mpi_mbox_t; +typedef struct mpi_message mpi_message_t; -int mpiCreateMbox(char *); -int mpiDestroyMbox(char *); -int mpiPostMessage(char *,uInt32,void *); -int mpiFetchMessage(char *,mpiMessage_t *); -int mpiSpam(uInt32,void *); +int mpi_createMbox(char *); +int mpi_destroyMbox(char *); +int mpi_postMessage(char *,uInt32,mpi_message_t *); +int mpi_fetchMessage(char *,mpi_message_t *); +int mpi_spam(uInt32,void *); #endif /*** $Log$ + Revision 1.7 2004/05/28 03:52:56 reddawg + mpi: took a few suggestions from TCA + Revision 1.6 2004/05/25 18:33:11 reddawg We now use 128byte messages I can increase later diff --git a/src/sys/include/ubixos/tty.h b/src/sys/include/ubixos/tty.h index d2f2e97..9192350 100644 --- a/src/sys/include/ubixos/tty.h +++ b/src/sys/include/ubixos/tty.h @@ -44,7 +44,7 @@ } tty_term; int tty_init(); -int tty_chang(uInt16); +int tty_change(uInt16); tty_term *tty_find(uInt16); int tty_print(char *,tty_term *); @@ -54,6 +54,9 @@ /*** $Log$ + Revision 1.6 2004/08/09 12:58:05 reddawg + let me know when you got the surce + Revision 1.5 2004/08/09 05:40:31 reddawg tty: removed current and made a foreground diff --git a/src/sys/include/vmm/paging.h b/src/sys/include/vmm/paging.h index 7b6afdf..7133157 100644 --- a/src/sys/include/vmm/paging.h +++ b/src/sys/include/vmm/paging.h @@ -62,7 +62,7 @@ int vmm_remapPage(uInt32,uInt32,uInt16); int vmm_pagingInit(); void *vmm_getFreeMallocPage(uInt16 count); -void vmm_pageFault(uInt32,uInt32); +void vmm_pageFault(uInt32,uInt32,uInt32); void _vmm_pageFault(); extern uInt32 *kernelPageDirectory; @@ -71,6 +71,12 @@ /*** $Log$ + Revision 1.7 2004/07/28 15:05:43 reddawg + Major: + Pages now have strict security enforcement. + Many null dereferences have been resolved. + When apps loaded permissions set for pages rw and ro + Revision 1.6 2004/07/26 19:15:49 reddawg test code, fixes and the like diff --git a/src/sys/init/main.c b/src/sys/init/main.c index 250dfbd..3cf37fb 100644 --- a/src/sys/init/main.c +++ b/src/sys/init/main.c @@ -104,12 +104,12 @@ */ execThread(systemTask,(uInt32)(kmalloc(0x2000)+0x2000),0x0); - //execFile("sys:/init",0x0,0x0,0x0); - execFile("sys:/login",0x0,0x0,0x1); - execFile("sys:/login",0x0,0x0,0x2); - execFile("sys:/login",0x0,0x0,0x3); - execFile("sys:/login",0x0,0x0,0x4); + execFile("sys:/init",0x0,0x0,0x1); + //execFile("sys:/login",0x0,0x0,0x1); + //execFile("sys:/login",0x0,0x0,0x2); + //execFile("sys:/login",0x0,0x0,0x3); + //execFile("sys:/login",0x0,0x0,0x4); kprintf("Free Pages: [%i]\n",systemVitals->freePages); kprintf("MemoryMap: [0x%X]\n",vmmMemoryMap); @@ -121,6 +121,9 @@ /*** $Log$ + Revision 1.70 2004/08/09 12:58:05 reddawg + let me know when you got the surce + Revision 1.69 2004/08/06 22:43:04 reddawg ok diff --git a/src/sys/kernel/exec.c b/src/sys/kernel/exec.c index 6115213..651b73a 100644 --- a/src/sys/kernel/exec.c +++ b/src/sys/kernel/exec.c @@ -234,12 +234,12 @@ vmm_remapPage(vmmFindFreePage(_current->id),0x5DB000,PAGE_DEFAULT | PAGE_STACK); /* Kernel Stack 0x2000 bytes long */ - vmm_remapPage(vmmFindFreePage(_current->id),0x5D1000,KERNEL_PAGE_DEFAULT | PAGE_STACK); - vmm_remapPage(vmmFindFreePage(_current->id),0x5D0000,KERNEL_PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5CC000,KERNEL_PAGE_DEFAULT | PAGE_STACK); + vmm_remapPage(vmmFindFreePage(_current->id),0x5CB000,KERNEL_PAGE_DEFAULT | PAGE_STACK); /* Set All The Proper Information For The Task */ _current->tss.back_link = 0x0; - _current->tss.esp0 = 0x5D2000; + _current->tss.esp0 = 0x5CC000; _current->tss.ss0 = 0x10; _current->tss.esp1 = 0x0; _current->tss.ss1 = 0x0; @@ -423,6 +423,9 @@ /*** $Log$ + Revision 1.61 2004/08/09 12:58:05 reddawg + let me know when you got the surce + Revision 1.60 2004/08/06 22:32:16 reddawg Ubix Works Again diff --git a/src/sys/kernel/sched.c b/src/sys/kernel/sched.c index 2103fca..7adf2b0 100644 --- a/src/sys/kernel/sched.c +++ b/src/sys/kernel/sched.c @@ -43,20 +43,35 @@ extern union descriptorTableUnion ubixGDT[5]; -static spinLock_t schedSpinLock = SPIN_LOCK_INITIALIZER; -static spinLock_t schedTaskSpinLock = SPIN_LOCK_INITIALIZER; +static spinLock_t sched_spinLock = SPIN_LOCK_INITIALIZER; -static prioQueue_t *prioLevels[MAXPRIOLEVELS - 1]; -static prioQueue_t *prioQStart = 0x0; -static prioQueue_t *prioQEnd = 0x0; -static prioQueue_t *_currentQueue = 0x0; - -static kTask_t *taskList = 0x0; +static kTask_t *runList = 0x0; static uInt32 nextID = -1; kTask_t *_current = 0x0; kTask_t *_usedMath = 0x0; +static kTask_t *sched_getRunTask() { + kTask_t *tmpTask = 0x0; + + tmpTask = _current->next; + + schedStart: + /* Yield the next task from the current prio queue */ + for (;tmpTask != 0x0; tmpTask = tmpTask->next) { + if (tmpTask->state > 0x0) { + if (tmpTask->state == FORK) + tmpTask->state = READY; + return(tmpTask); + } + } + /* Finished all the tasks, restarting the list */ + if (0x0 == tmpTask) { + tmpTask = runList; + goto schedStart; + } + return(0x0); + } /************************************************************************ @@ -72,154 +87,78 @@ ************************************************************************/ -int -sched_init() -{ - int i; - - for (i = 0; i < MAXPRIOLEVELS; i++) { - prioQueue_t *tmpPrioQ; - kTask_t *tmpTask; +int sched_init() { + kTask_t *tmpTask; - tmpPrioQ = (prioQueue_t *)kmalloc(sizeof(prioQueue_t)); - tmpTask = (kTask_t *)kmalloc(sizeof(kTask_t)); + if ((tmpTask = (kTask_t *)kmalloc(sizeof(kTask_t))) == 0x0) + kpanic("malloc: Failed File: %s, Line: %i\n",__FILE__,__LINE__); - if (tmpPrioQ == 0x0) { - kpanic("Error: schedInit() - kmalloc failed trying to initialize a prioQueue_t struct\n"); - return(0x1); - } - if (tmpTask == 0x0) { - kpanic("Error: schedInit() - kmalloc failed trying to initialize a kTask_t struct\n"); - return(0x1); - } - - tmpPrioQ->start = tmpTask; - tmpPrioQ->end = tmpTask; - tmpPrioQ->prio = i; - prioLevels[i] = tmpPrioQ; + tmpTask->prev = 0x0; + tmpTask->next = 0x0; + tmpTask->id = -1; + tmpTask->state = PLACEHOLDER; + tmpTask->timeSlice = systemVitals->dQuantum; - tmpTask->prev = 0x0; - tmpTask->next = 0x0; - tmpTask->id = -1; - tmpTask->state = PLACEHOLDER; - tmpTask->nice = i; - tmpTask->timeSlice = systemVitals->dQuantum; + runList = tmpTask; + _current = runList; + nextID++; - /* Linking the previous placeholder with the current one */ - if (i > 0) { - prioLevels[i - 1]->start->next = tmpTask; - tmpTask->prev = prioLevels[i - 1]->end; - } - - if (0x0 == prioQStart) { - tmpPrioQ->next = 0x0; - tmpPrioQ->prev = 0x0; - prioQStart = prioQEnd = tmpPrioQ; - } else { - tmpPrioQ->prev = prioQEnd; - prioQEnd->next = tmpPrioQ; - tmpPrioQ->next = 0x0; - prioQEnd = tmpPrioQ; - } - } - - taskList = prioLevels[0]->start; - _current = prioLevels[MAXPRIOLEVELS/2]->start; - _currentQueue = prioLevels[0]; - - nextID++; - - /* Print out information on scheduler */ - kprintf("sched0 solar 0.2.1 - Address: [0x%X]\n", prioQStart); + kprintf("sched0 - Address: [0x%X]\n", runList); - /* Return so we know everything went well */ - return(0x0); -} + /* Return so we know everything went well */ + return(0x0); + } -void sched(){ - uInt32 memAddr = 0x0; +void sched() { + uInt32 memAddr = 0x0; kTask_t *tmpTask = 0x0; - schedStart: - /* Yield the next task from the current prio queue */ - for (tmpTask = _current->next; tmpTask; tmpTask = tmpTask->next) { - if (tmpTask->state > 0x0) { - _current = tmpTask; - if (_current->state == FORK) - _current->state = READY; - - break; - } + tmpTask = sched_getRunTask(); + + if (tmpTask != 0x0) { + _current = tmpTask; + if (_current->oInfo.v86Task == 0x1) + irqDisable(0x0); + memAddr = (uInt32)&(_current->tss); + ubixGDT[4].descriptor.baseLow = (memAddr & 0xFFFF); + ubixGDT[4].descriptor.baseMed = ((memAddr >> 16) & 0xFF); + ubixGDT[4].descriptor.baseHigh = (memAddr >> 24); + ubixGDT[4].descriptor.access = '\x89'; + asm("ljmp $0x20,$0\n"); } + return; + } - /* Finished all the tasks, restarting the list */ - if (0x0 == tmpTask) { - _current = taskList; - goto schedStart; - } - /* Setting the timeslice this task is allowed to run */ - systemVitals->quantum = _current->timeSlice; +kTask_t *schedNewTask() { + kTask_t *tmpTask = (kTask_t *)kmalloc(sizeof(kTask_t)); + + if (tmpTask == 0x0) + kpanic("Error: schedNewTask() - kmalloc failed trying to initialize a new task struct\n"); + + spinLock(&sched_spinLock); - - if (_current->state > 0x0) { - if (_current->oInfo.v86Task == 0x1) - irqDisable(0x0); - asm("cli"); - memAddr = (uInt32)&(_current->tss); - ubixGDT[4].descriptor.baseLow = (memAddr & 0xFFFF); - ubixGDT[4].descriptor.baseMed = ((memAddr >> 16) & 0xFF); - ubixGDT[4].descriptor.baseHigh = (memAddr >> 24); - ubixGDT[4].descriptor.access = '\x89'; - asm("ljmp $0x20,$0\n"); - } + tmpTask->usedMath = 0x0; + tmpTask->id = ++nextID; + tmpTask->state = NEW; + tmpTask->nice = _current->nice; - return; -} + tmpTask->timeSlice = systemVitals->dQuantum * tmpTask->nice; + tmpTask->oInfo.cwd = (char *)kmalloc(1024); + assert(tmpTask->oInfo.cwd); - -kTask_t * -schedNewTask() -{ - kTask_t *tmpTask = (kTask_t *)kmalloc(sizeof(kTask_t)); - - if (tmpTask == 0x0) { - kpanic("Error: schedNewTask() - kmalloc failed trying to initialize a new task struct\n"); - return(0x0); - } - - //spinLock(&schedTaskSpinLock); - - /* Filling in tasks attrs */ - tmpTask->usedMath = 0x0; - tmpTask->id = ++nextID; - tmpTask->state = NEW; - tmpTask->nice = _current->nice; - - tmpTask->timeSlice = systemVitals->dQuantum * tmpTask->nice; - tmpTask->oInfo.cwd = (char *)kmalloc(1024); - assert(tmpTask->oInfo.cwd); - - /* Are we adding a task at the end of the last prio queue? */ - if (0x0 == prioLevels[_current->nice]->next) - tmpTask->next = 0x0; - else - tmpTask->next = prioLevels[_current->nice + 1]->start; - - tmpTask->prev = prioLevels[_current->nice]->end; - - /* - * Inserting the task at the end of the proper prio queue; - * this gives me the feeling of O(1) for task insertion - */ - prioLevels[_current->nice]->end->next = tmpTask; - prioLevels[_current->nice]->end = tmpTask; + tmpTask->prev = 0x0; + tmpTask->next = runList; + if (runList != 0x0) + runList->prev = tmpTask; + + runList = tmpTask; - //spinUnlock(&schedTaskSpinLock); - return(tmpTask); -} + spinUnlock(&sched_spinLock); + return(tmpTask); + } /* @@ -232,11 +171,11 @@ kTask_t *tmpTask = 0x0; /* Checking each task from the prio queue */ - for (tmpTask = taskList; tmpTask != 0x0; tmpTask = tmpTask->next) { + for (tmpTask = runList; tmpTask != 0x0; tmpTask = tmpTask->next) { if (tmpTask->id == id) { if (_current == tmpTask) kpanic("you can not delete yourself!!!\n"); - if (tmpTask == taskList) + if (tmpTask == runList) kpanic("Whoa"); if (tmpTask->prev) tmpTask->prev->next = tmpTask->next; @@ -256,7 +195,7 @@ { kTask_t *tmpTask = 0x0; - for (tmpTask = taskList; tmpTask; tmpTask = tmpTask->next) { + for (tmpTask = runList; tmpTask; tmpTask = tmpTask->next) { if (tmpTask->id == id) return(tmpTask); } @@ -294,10 +233,12 @@ ************************************************************************/ -void -sched_yield() { - asm("hlt"); - //sched(); +void sched_yield() { + asm("hlt"); + /* + asm("cli"); + sched(); + */ } /* @@ -328,6 +269,9 @@ /*** $Log$ + Revision 1.30 2004/08/09 12:58:05 reddawg + let me know when you got the surce + Revision 1.29 2004/08/06 22:43:04 reddawg ok diff --git a/src/sys/kernel/systemtask.c b/src/sys/kernel/systemtask.c index e26e93b..a694877 100644 --- a/src/sys/kernel/systemtask.c +++ b/src/sys/kernel/systemtask.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -40,18 +41,24 @@ #include void systemTask() { - mpiMessage_t myMsg; + mpi_message_t myMsg; uInt32 counter = 0x0; int i = 0x0; + int *x = 0x0; - if (mpiCreateMbox("system") != 0x0) { + if (mpi_createMbox("system") != 0x0) { kpanic("Error: Error creating mailbox: system\n"); } while(1) { - if (mpiFetchMessage("system",&myMsg) == 0x0) { + if (mpi_fetchMessage("system",&myMsg) == 0x0) { kprintf("A"); - switch(myMsg.type) { + switch(myMsg.header) { + case 0x69: + x = (int *)&myMsg.data; + kprintf("Switching to term: [%i][%i]\n",*x,myMsg.pid); + schedFindTask(myMsg.pid)->term = tty_find(*x); + break; case 1000: kprintf("Restarting the system in 5 seconds\n"); counter = systemVitals->sysUptime + 5; @@ -81,7 +88,7 @@ } break; default: - kprintf("system: Received message %i:%s\n",myMsg.type,myMsg.data); + kprintf("system: Received message %i:%s\n",myMsg.header,myMsg.data); break; } } @@ -92,6 +99,9 @@ /*** $Log$ + Revision 1.11 2004/08/06 22:43:04 reddawg + ok + Revision 1.10 2004/08/06 22:32:16 reddawg Ubix Works Again diff --git a/src/sys/kernel/timer.S b/src/sys/kernel/timer.S index a0d0f73..47f7162 100644 --- a/src/sys/kernel/timer.S +++ b/src/sys/kernel/timer.S @@ -38,7 +38,7 @@ 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 */ + movl $200,%ebx /* Have Passed */ xor %edx,%edx div %ebx test %edx,%edx @@ -58,6 +58,9 @@ /*** $Log$ + Revision 1.5 2004/07/29 21:32:16 reddawg + My quick lunchs breaks worth of updates.... + Revision 1.4 2004/07/23 17:49:59 reddawg atkbd: adjust the timing issue on the driver hopefully it will work fine now diff --git a/src/sys/kernel/vitals.c b/src/sys/kernel/vitals.c index b160732..3a6f393 100644 --- a/src/sys/kernel/vitals.c +++ b/src/sys/kernel/vitals.c @@ -57,8 +57,8 @@ systemVitals->freePages = 0x0; systemVitals->sysTicks = 0x0; systemVitals->sysUptime = 0x0; - systemVitals->quantum = 40; - systemVitals->dQuantum = 40; + systemVitals->quantum = 8; + systemVitals->dQuantum = 8; systemVitals->fileSystems = 0x0; systemVitals->mountPoints = 0x0; systemVitals->timeStart = 0x0; @@ -74,6 +74,9 @@ /*** $Log$ + Revision 1.9 2004/07/19 01:56:56 reddawg + vitals: cleaned up all defaults this should not cause any problems in the future + Revision 1.8 2004/07/17 03:22:20 reddawg Added asscerts diff --git a/src/sys/mpi/message.c b/src/sys/mpi/message.c index 2dd767d..f4c986e 100644 --- a/src/sys/mpi/message.c +++ b/src/sys/mpi/message.c @@ -31,36 +31,39 @@ void sysMpiCreateMbox(uInt32 *status,char *name) { if (status && name) - *status = mpiCreateMbox(name); + *status = mpi_createMbox(name); return; } void sysMpiDestroyMbox(uInt32 *status,char *name) { if (status && name) - *status = mpiDestroyMbox(name); + *status = mpi_destroyMbox(name); return; } -void sysMpiPostMessage(char *name,uInt32 *type,void *data) { +void sysMpiPostMessage(char *name,uInt32 *type,mpi_message_t *data) { if (type && name && data) - *type = mpiPostMessage(name,*type,data); + *type = mpi_postMessage(name,*type,data); return; } -void sysMpiFetchMessage(char *name,mpiMessage_t *msg,uInt32 *status) { +void sysMpiFetchMessage(char *name,mpi_message_t *msg,uInt32 *status) { if (status && name && msg) - *status = mpiFetchMessage(name,msg); + *status = mpi_fetchMessage(name,msg); return; } void sysMpiSpam(uInt32 type,void *data,uInt32 *status) { if (status && data) - *status = mpiSpam(type,data); + *status = mpi_spam(type,data); return; } /*** $Log$ + Revision 1.11 2004/07/28 17:07:25 reddawg + MPI: moved the syscalls + END ***/ diff --git a/src/sys/mpi/system.c b/src/sys/mpi/system.c index 986ff72..a115194 100644 --- a/src/sys/mpi/system.c +++ b/src/sys/mpi/system.c @@ -32,7 +32,7 @@ #include #include -static mpiMbox_t *mboxList = 0x0; +static mpi_mbox_t *mboxList = 0x0; static spinLock_t mpiSpinLock = SPIN_LOCK_INITIALIZER; /***************************************************************************************** @@ -44,8 +44,8 @@ Notes: *****************************************************************************************/ -static mpiMbox_t * mpiFindMbox(char *name) { - mpiMbox_t *mbox = 0x0; +static mpi_mbox_t * mpi_findMbox(char *name) { + mpi_mbox_t *mbox = 0x0; for (mbox = mboxList;mbox;mbox = mbox->next) { if (!strcmp(mbox->name,name)) { @@ -67,17 +67,17 @@ Notes: *****************************************************************************************/ -int mpiCreateMbox(char *name) { - mpiMbox_t *mbox = 0x0; +int mpi_createMbox(char *name) { + mpi_mbox_t *mbox = 0x0; spinLock(&mpiSpinLock); - if (mpiFindMbox(name) != 0x0) { + if (mpi_findMbox(name) != 0x0) { spinUnlock(&mpiSpinLock); return(-1); } - mbox = (mpiMbox_t *)kmalloc(sizeof(mpiMbox_t)); + mbox = (mpi_mbox_t *)kmalloc(sizeof(mpi_mbox_t)); sprintf(mbox->name,name); mbox->pid = _current->id; @@ -107,16 +107,16 @@ Notes: *****************************************************************************************/ -int mpiSpam(uInt32 type,void *data) { - mpiMbox_t *mbox = 0x0; - mpiMessage_t *message = 0x0; +int mpi_spam(uInt32 type,void *data) { + mpi_mbox_t *mbox = 0x0; + mpi_message_t *message = 0x0; spinLock(&mpiSpinLock); for (mbox = mboxList;mbox;mbox = mbox->next) { - message = (mpiMessage_t *)kmalloc(sizeof(mpiMessage_t)); + message = (mpi_message_t *)kmalloc(sizeof(mpi_message_t)); - message->type = type; + message->header = type; memcpy(message->data,data,MESSAGE_LENGTH); message->next = 0x0; @@ -142,23 +142,24 @@ Notes: *****************************************************************************************/ -int mpiPostMessage(char *name,uInt32 type,void *data) { - mpiMbox_t *mbox = 0x0; - mpiMessage_t *message = 0x0; +int mpi_postMessage(char *name,uInt32 type,mpi_message_t *msg) { + mpi_mbox_t *mbox = 0x0; + mpi_message_t *message = 0x0; spinLock(&mpiSpinLock); - mbox = mpiFindMbox(name); + mbox = mpi_findMbox(name); if (mbox == 0x0) { spinUnlock(&mpiSpinLock); - return(-1); + return(0x1); } - message = (mpiMessage_t *)kmalloc(sizeof(mpiMessage_t)); + message = (mpi_message_t *)kmalloc(sizeof(mpi_message_t)); - message->type = type; - memcpy(message->data,data,MESSAGE_LENGTH); + message->header = msg->header; + memcpy(message->data,msg->data,MESSAGE_LENGTH); + message->pid = _current->id; message->next = 0x0; if (mbox->msg == 0x0) { @@ -170,6 +171,11 @@ } spinUnlock(&mpiSpinLock); + + if (type == 0x2) { + while (mbox->msgLast != 0x0); + } + return(0x0); } @@ -182,13 +188,13 @@ Notes: *****************************************************************************************/ -int mpiFetchMessage(char *name,mpiMessage_t *msg) { - mpiMbox_t *mbox = 0x0; - mpiMessage_t *tmpMsg = 0x0; +int mpi_fetchMessage(char *name,mpi_message_t *msg) { + mpi_mbox_t *mbox = 0x0; + mpi_message_t *tmpMsg = 0x0; spinLock(&mpiSpinLock); - mbox = mpiFindMbox(name); + mbox = mpi_findMbox(name); if (mbox == 0x0) { spinUnlock(&mpiSpinLock); @@ -205,8 +211,9 @@ return(-1); } - msg->type = mbox->msg->type; + msg->header = mbox->msg->header; memcpy(msg->data,mbox->msg->data,MESSAGE_LENGTH); + msg->pid = mbox->msg->pid; tmpMsg = mbox->msg; mbox->msg = mbox->msg->next; @@ -226,8 +233,8 @@ Notes: *****************************************************************************************/ -int mpiDestroyMbox(char *name) { - mpiMbox_t *mbox = 0x0; +int mpi_destroyMbox(char *name) { + mpi_mbox_t *mbox = 0x0; spinLock(&mpiSpinLock); @@ -251,6 +258,9 @@ /*** $Log$ + Revision 1.1 2004/07/28 17:07:25 reddawg + MPI: moved the syscalls + Revision 1.10 2004/06/28 23:12:58 reddawg file format now container:/path/to/file diff --git a/src/sys/sys/idt.c b/src/sys/sys/idt.c index 509bb44..2f01150 100644 --- a/src/sys/sys/idt.c +++ b/src/sys/sys/idt.c @@ -38,6 +38,7 @@ #include #include #include +#include #define FP_TO_LINEAR(seg, off) ((void*) ((((uInt16) (seg)) << 4) + ((uInt16) (off)))) @@ -457,6 +458,9 @@ /*** $Log$ + Revision 1.30 2004/08/06 22:43:04 reddawg + ok + Revision 1.29 2004/08/06 22:32:16 reddawg Ubix Works Again diff --git a/src/sys/ubixfs/block.c b/src/sys/ubixfs/block.c index edb467c..d7d0a64 100644 --- a/src/sys/ubixfs/block.c +++ b/src/sys/ubixfs/block.c @@ -24,6 +24,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. $Log$ + Revision 1.5 2004/07/23 09:10:06 reddawg + ubixfs: cleaned up some functions played with the caching a bit + vfs: renamed a bunch of functions + cleaned up a few misc bugs + Revision 1.4 2004/06/04 10:19:42 reddawg notes: we compile again, thank g-d anyways i was about to cry @@ -74,14 +79,15 @@ } int getFreeBlocks(int count,fileDescriptor *fd) { - int i = 0x0,x = 0x0; + uInt32 i = 0x0; + uInt32 x = 0x0; struct ubixFSInfo *fsInfo = fd->mp->fsInfo; getBlocks: for (i=1;i < fsInfo->batEntries;i++) { if (fsInfo->blockAllocationTable[i].attributes == 0x0) { - for (x = 1; x < count; x++) { + for (x = 1; x < (uInt32)count; x++) { if (fsInfo->blockAllocationTable[i + x].attributes != 0x0) { goto getBlocks; } diff --git a/src/sys/ubixfs/dirCache.c b/src/sys/ubixfs/dirCache.c index bba6d4e..a40b245 100644 --- a/src/sys/ubixfs/dirCache.c +++ b/src/sys/ubixfs/dirCache.c @@ -44,7 +44,7 @@ unsigned int i; if (dirList == NULL || name == NULL) return NULL; - kprintf("dirList: [0x%X],name: [0x%X]\n",dirList,name); + //UBU kprintf("dirList: [0x%X],name: [0x%X]\n",dirList,name); for (i = 0; i < (size / sizeof(struct directoryEntry)) ; i++) { if (strcmp(dirList[i].fileName, name) == 0) return &dirList[i]; } /* for */ @@ -94,7 +94,7 @@ /* kprintf("nextdir: %s -- dirName: %s\n", nextDir, dirName); */ if (*nextDir != '\0') { while (tmp != NULL) { - kprintf("tmp->name: [0x%X],dirName: [0x%X]\n",tmp->name,dirName); + //UBU kprintf("tmp->name: [0x%X],dirName: [0x%X]\n",tmp->name,dirName); if (strcmp(tmp->name, dirName) == 0) { if ((*tmp->attributes & typeFile) == typeFile @@ -132,7 +132,7 @@ assert(tmp->name); assert(name); /* don't forget to check to see if it's a directory */ - kprintf("tmpName: [0x%X], name: [0x%X]\n",tmp->name,name); + //UBU kprintf("tmpName: [0x%X], name: [0x%X]\n",tmp->name,name); if (strcmp(tmp->name, name) == 0) { /* @@ -260,6 +260,9 @@ /*** $Log$ + Revision 1.29 2004/08/09 12:58:05 reddawg + let me know when you got the surce + Revision 1.28 2004/08/01 17:58:39 flameshadow chg: fixed string allocation bug in ubixfs_cacheNew() @@ -329,6 +332,9 @@ Revision 1.5 2004/07/20 19:21:30 reddawg You like leaving out $Log$ + You like leaving out Revision 1.29 2004/08/09 12:58:05 reddawg + You like leaving out let me know when you got the surce + You like leaving out You like leaving out Revision 1.28 2004/08/01 17:58:39 flameshadow You like leaving out chg: fixed string allocation bug in ubixfs_cacheNew() You like leaving out diff --git a/src/sys/ubixfs/directory.c b/src/sys/ubixfs/directory.c index 095e283..22005b7 100644 --- a/src/sys/ubixfs/directory.c +++ b/src/sys/ubixfs/directory.c @@ -64,7 +64,7 @@ int addDirEntry(struct directoryEntry *dir,fileDescriptor *fd) { - int i = 0x0; + uInt32 i = 0x0; uInt32 entries = 0x0; struct directoryEntry *tmp = 0x0; @@ -128,6 +128,9 @@ /*** $Log$ + Revision 1.11 2004/08/01 17:58:39 flameshadow + chg: fixed string allocation bug in ubixfs_cacheNew() + Revision 1.10 2004/07/23 09:10:06 reddawg ubixfs: cleaned up some functions played with the caching a bit vfs: renamed a bunch of functions diff --git a/src/sys/ubixfs/thread.c b/src/sys/ubixfs/thread.c index 25723f0..c6d1a62 100755 --- a/src/sys/ubixfs/thread.c +++ b/src/sys/ubixfs/thread.c @@ -37,18 +37,21 @@ } ubixFS_Info; void ubixfs_thread(vfs_mountPoint_t *mp) { - mpiMessage_t myMsg; + mpi_message_t myMsg; ubixFS_Info.mounts = 0; - if (mpiCreateMbox("ubixfs") != 0x0) { + if (mp == 0x0) + kpanic("bah"); + + if (mpi_createMbox("ubixfs") != 0x0) { kpanic("Error: Error creating mailbox: ubixfs\n"); } while (1) { - if (mpiFetchMessage("ubixfs",&myMsg) == 0x0) { - switch(myMsg.type) { + if (mpi_fetchMessage("ubixfs",&myMsg) == 0x0) { + switch(myMsg.header) { default: - kprintf("Unhandled Message: %i\n",myMsg.type); + kprintf("Unhandled Message: %i\n",myMsg.header); break; } } @@ -57,6 +60,11 @@ /*** $Log$ + Revision 1.2 2004/07/23 09:10:06 reddawg + ubixfs: cleaned up some functions played with the caching a bit + vfs: renamed a bunch of functions + cleaned up a few misc bugs + Revision 1.1 2004/06/28 18:12:44 reddawg We need these files diff --git a/src/sys/ubixfs/ubixfs.c b/src/sys/ubixfs/ubixfs.c index 878dc10..222496b 100644 --- a/src/sys/ubixfs/ubixfs.c +++ b/src/sys/ubixfs/ubixfs.c @@ -66,7 +66,7 @@ if ((fd->mode & fileRead) == fileRead) { do { - cacheNode = ubixfs_cacheFind(fsInfo->dirCache, file); + cacheNode = ubixfs_cacheFind(fsInfo->dirCache,(char *) file); if (cacheNode == NULL) return 0; if (cacheNode->present == 1) break; assert(cacheNode->size); @@ -118,7 +118,8 @@ int writeFileByte(int ch, fileDescriptor *fd, long offset) { - int blockCount = 0x0,batIndex = 0x0,batIndexPrev = 0x0,i = 0x0; + int blockCount = 0x0,batIndex = 0x0,batIndexPrev = 0x0; + uInt32 i = 0x0; struct directoryEntry *dirEntry = 0x0; struct ubixFSInfo *fsInfo = NULL; @@ -169,7 +170,7 @@ fd->buffer[offset-(blockCount*4096)] = ch; fd->mp->device->devInfo->write(fd->mp->device->devInfo->info,fd->buffer,fd->mp->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[batIndex].realSector,8); } - if (offset > fd->size) { + if ((uInt32)offset > fd->size) { fd->size = offset; dirEntry = (struct directoryEntry *)kmalloc(4096); /* @@ -251,7 +252,7 @@ if (fd->size != 0x0) { for (i = 0x0;i < blockOffset;i++) { blockIndex = fsInfo->blockAllocationTable[blockIndexPrev].nextBlock; - if (blockIndex == EOBC) { + if ((int)blockIndex == EOBC) { blockIndex = getFreeBlocks(1,fd); fsInfo->blockAllocationTable[blockIndexPrev].nextBlock = blockIndex; fsInfo->blockAllocationTable[blockIndex].nextBlock = EOBC; @@ -262,7 +263,7 @@ } fd->mp->device->devInfo->read(fd->mp->device->devInfo->info,fd->buffer,fd->mp->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[blockIndex].realSector,blockSize); - for (i = 0x0;i < size;i++) { + for (i = 0x0;i < (uInt32)size;i++) { fd->buffer[(offset- (blockOffset *0x1000))] = data[i]; offset++; @@ -285,7 +286,7 @@ } fd->mp->device->devInfo->write(fd->mp->device->devInfo->info,fd->buffer,fd->mp->diskLabel->partitions[fd->mp->partition].pOffset+fsInfo->blockAllocationTable[blockIndex].realSector,blockSize); - if (offset > fd->size) { + if ((uInt32)offset > fd->size) { fd->size = offset; dirEntry = (struct directoryEntry *)kmalloc(4096); /* @@ -313,7 +314,7 @@ mp->device->devInfo->read(mp->device->devInfo->info,dirEntry,(mp->diskLabel->partitions[mp->partition].pOffset+fsInfo->blockAllocationTable[fsInfo->rootDir].realSector),8); - for (x=0;x<(4096/sizeof(struct directoryEntry));x++) { + for (x=0;(uInt32)x<(4096/sizeof(struct directoryEntry));x++) { if ((int)!strcmp(dirEntry[x].fileName,path)) { dirEntry[x].attributes |= typeDeleted; dirEntry[x].fileName[0] = '?'; @@ -481,6 +482,9 @@ /*** $Log$ + Revision 1.42 2004/08/09 12:58:05 reddawg + let me know when you got the surce + Revision 1.41 2004/08/01 17:58:39 flameshadow chg: fixed string allocation bug in ubixfs_cacheNew() diff --git a/src/sys/vfs/file.c b/src/sys/vfs/file.c index 9ee0cab..b8894ca 100644 --- a/src/sys/vfs/file.c +++ b/src/sys/vfs/file.c @@ -60,7 +60,7 @@ kfree(fd->buffer); kfree(fd); systemVitals->openFiles--; - return(1); + return(0x1); } else { if (tmpFd->prev) @@ -70,7 +70,7 @@ kfree(fd->buffer); kfree(fd); systemVitals->openFiles--; - return(1); + return(0x1); } } } @@ -268,6 +268,9 @@ /*** $Log$ + Revision 1.19 2004/08/09 12:58:05 reddawg + let me know when you got the surce + Revision 1.18 2004/08/06 22:32:16 reddawg Ubix Works Again diff --git a/src/sys/vmm/memory.c b/src/sys/vmm/memory.c index 885dcda..c71c5bb 100644 --- a/src/sys/vmm/memory.c +++ b/src/sys/vmm/memory.c @@ -187,7 +187,7 @@ /* Lets Look For A Free Page */ if (pid < sysID) { - kpanic("Error: invalid PID\n"); + kpanic("Error: invalid PID %i\n",pid); } spinLock(&vmmSpinLock); @@ -329,6 +329,9 @@ /*** $Log$ + Revision 1.12 2004/08/01 20:51:33 reddawg + adjustCowCounter: we no longer need to debug unhandled adjustments they are normal situations now + Revision 1.11 2004/07/28 00:17:05 reddawg Major: Disconnected page 0x0 from the system... Unfortunately this broke many things diff --git a/src/sys/vmm/page_fault.S b/src/sys/vmm/page_fault.S index 0e59503..f9d80fd 100644 --- a/src/sys/vmm/page_fault.S +++ b/src/sys/vmm/page_fault.S @@ -27,38 +27,39 @@ *****************************************************************************************/ +/* + Page fault wrapper this will aquire some values we need for later use + */ + .globl _vmm_pageFault .text .code32 _vmm_pageFault: - xchgl %eax,(%esp) - movl 4(%esp),%eax - pushl %ecx + xchgl %eax,(%esp) /* Save EAX */ + movl 4(%esp),%eax /* Move EIP into EAX to use later */ + pushl %ebx /* Save EBX */ + movl 20(%esp),%ebx /* Save ESP for ring 3 to use later */ + pushl %ecx /* Save ECX,EDX */ pushl %edx - /* - push %ds - push %es - push %fs - */ - push %eax - movl %cr2,%eax + push %ebx /* Push ESP */ + push %eax /* Push EIP */ + movl %cr2,%eax /* Push the faulted address */ pushl %eax - sti - call vmm_pageFault - addl $0x8,%esp - /* - pop %fs - pop %es - pop %ds - */ - popl %edx - popl %ecx - popl %eax - iret + sti /* Turn interrupts back on we are now entrant safe */ + call vmm_pageFault /* Call our page fault handler */ + addl $0xC,%esp /* Adjust the stack to compensate for pushed values */ + popl %edx /* Restore EAX,EBX,ECX,EDX */ + popl %ecx + popl %ebx + popl %eax + iret /* Return from the interrupt */ /*** $Log$ + Revision 1.3 2004/07/28 22:23:02 reddawg + make sure it still works before I goto bed + Revision 1.2 2004/07/26 19:15:49 reddawg test code, fixes and the like diff --git a/src/sys/vmm/pagefault.c b/src/sys/vmm/pagefault.c index 2d17938..35ebf23 100644 --- a/src/sys/vmm/pagefault.c +++ b/src/sys/vmm/pagefault.c @@ -35,91 +35,104 @@ static spinLock_t pageFaultSpinLock = SPIN_LOCK_INITIALIZER; -/************************************************************************ +/***************************************************************************************** -Function: void vmmPageFault(); -Description: This Function Is The Second Half Of The Page Fault ISR - Currently It Handles COW However I Need To Prepar It For - Swapping -Notes: + Function: void vmm_pageFault(uInt32 memAddr,uInt32 eip,uInt32 esp); + Description: This is the page fault handler, it will handle COW and trap all other + exceptions and segfault the thread. + Notes: + 07/30/02 - Fixed COW However I Need To Think Of A Way To Impliment A Paging System Also Start To Add Security Levels + +07/27/04 - Added spin locking to ensure that we are thread safe. I know that spining a + cpu is a waste of resources but for now it prevents errors. -************************************************************************/ -void vmm_pageFault(uInt32 memAddr,uInt32 eip) { - uInt32 i = 0, pageTableIndex = 0,pageDirectoryIndex = 0; +*****************************************************************************************/ +void vmm_pageFault(uInt32 memAddr,uInt32 eip,uInt32 esp) { + uInt32 i = 0x0, pageTableIndex = 0x0,pageDirectoryIndex = 0x0; uInt32 *pageDir = 0x0,*pageTable = 0x0; uInt32 *src = 0x0,*dst = 0x0; + /* Try to aquire lock otherwise spin till we do */ spinLock(&pageFaultSpinLock); + /* Set page dir pointer to the address of the visable page directory */ pageDir = (uInt32 *)parentPageDirAddr; + /* UBU - This is a temp panic for 0x0 read write later on I will handle this differently */ if (memAddr == 0x0) { - kprintf("Segfault At Address: [0x%X][0x%X][%i][0x%X]\n",memAddr,_current->tss.esp,_current->id,eip); + kprintf("Segfault At Address: [0x%X][0x%X][%i][0x%X]\n",memAddr,esp,_current->id,eip); kpanic("Error We Wrote To 0x0\n"); } - //Calculate The Page Directory Index + /* Calculate The Page Directory Index */ pageDirectoryIndex = (memAddr >> 22); - //Calculate The Page Table Index + /* Calculate The Page Table Index */ pageTableIndex = ((memAddr >> 12) & 0x3FF); + /* UBU - This is a temporary routine for handling access to a page of a non existant page table */ if (pageDir[pageDirectoryIndex] == 0x0) { - //Creat A Routine For Non Mapped Memory - kprintf("Segfault At Address: [0x%X][0x%X][%i][0x%X], Not A Valid Page Table\n",memAddr,_current->tss.esp,_current->id,eip); + kprintf("Segfault At Address: [0x%X][0x%X][%i][0x%X], Not A Valid Page Table\n",memAddr,esp,_current->id,eip); spinUnlock(&pageFaultSpinLock); endTask(_current->id); } else { - //Set pageTable To Point To Virtual Address Of Page Table + /* Set pageTable To Point To Virtual Address Of Page Table */ pageTable = (uInt32 *)(tablesBaseAddress + (0x1000 * pageDirectoryIndex)); + + /* Test if this is a COW on page */ if (((uInt32)pageTable[pageTableIndex] & pageCow) == pageCow) { - //Set Src To Base Address Of Page To Copy + /* Set Src To Base Address Of Page To Copy */ src = (uInt32 *)(memAddr & 0xFFFFF000); - //Allocate A Free Page For Destination + /* Allocate A Free Page For Destination */ dst = (uInt32 *) vmmGetFreeVirtualPage(_current->id,1); - //Copy Memory + /* Copy Memory */ for (i=0;itss.esp,_current->id,eip); + kprintf("Segfault At Address: [0x%X][0x%X][%i][0x%X] Non Mapped\n",memAddr,esp,_current->id,eip); spinUnlock(&pageFaultSpinLock); endTask(_current->id); - while (1); } else { spinUnlock(&pageFaultSpinLock); - //Need To Create A Routine For Attempting To Access Non Mapped Memory - kprintf("Segfault At Address: [0x%X][0x%X][%i][0x%X] Non Mapped\n",memAddr,_current->tss.esp,_current->id,eip); + /* Need To Create A Routine For Attempting To Access Non Mapped Memory */ + kprintf("Segfault At Address: [0x%X][0x%X][%i][0x%X] Non Mapped\n",memAddr,esp,_current->id,eip); spinUnlock(&pageFaultSpinLock); endTask(_current->id); - while (1); - //_current->state = DEAD; - //sched(); } } asm volatile( "movl %cr3,%eax\n" "movl %eax,%cr3\n" ); + + /* Release the spin lock */ spinUnlock(&pageFaultSpinLock); + return; } /*** $Log$ + Revision 1.11 2004/07/28 15:05:43 reddawg + Major: + Pages now have strict security enforcement. + Many null dereferences have been resolved. + When apps loaded permissions set for pages rw and ro + Revision 1.10 2004/07/28 00:22:56 reddawg bah diff --git a/src/tools/Makefile b/src/tools/Makefile index 6905326..d06e5c3 100644 --- a/src/tools/Makefile +++ b/src/tools/Makefile @@ -51,7 +51,8 @@ (cp ../sys/boot/mbr/mbr ./) (cp ../bin/ld/ld.so ./) #(cp /lib/libc.so.5 ./) - (./format 50 2000 /dev/fd0 ubix.elf 0 login 3754 ROM8X14.DPF 3754 init 3754 ubistry 3754 shell 3754 userdb 3754 ls 3754 motd 3754 fdisk 3754 mbr 3754 cp 3754 clock 3754 libc_old.so 3754 ld.so 3754) + (cp ../bin/ttyd/ttyd ./) + (./format 50 2000 /dev/fd0 ubix.elf 0 login 3754 ROM8X14.DPF 3754 init 3754 ubistry 3754 shell 3754 userdb 3754 ls 3754 motd 3754 fdisk 3754 mbr 3754 cp 3754 clock 3754 libc_old.so 3754 ld.so 3754 ttyd 3754) # (./format 50 2000 /dev/fd0 ubix.elf 0 login 3754 init 3754 ubistry 3754 shell 3754 userdb 3754 motd 3754 libc_old.so 3754 ld.so 3754 test 3754 libc.so.5 3754) #(./format 263 204361 /dev/md1 ubix.elf 0 format 3754 fdisk 3754 ROM8X14.DPF 3754 init 3754 login 3754 shell 3754 userdb 3754 ls 3754 motd 3754 cp 3754) @@ -71,3 +72,4 @@ (rm -fr ubistry) (rm -fr ld.so) (rm -fr libc.so.5) + (rm -fr ttyd)