diff --git a/src/bin/init/main.c b/src/bin/init/main.c index 2f571b1..504a694 100644 --- a/src/bin/init/main.c +++ b/src/bin/init/main.c @@ -55,18 +55,17 @@ //startSDE(); printf("Initializing System.\n"); - /* + i = fork(); - if (0 == i) { + if (0x0 == i) { printf("Starting Ubix Registry (ubistry)\n"); exec("sys:/ubistry",0x0,0x0); printf("Error: Error Starting ubistry\n"); - exit(-1); + exit(0x0); } while (pidStatus(i) > 0x0) { sched_yield(); } - */ startup: i = fork(); @@ -74,7 +73,7 @@ printf("Starting Login Daemon.\n"); exec("sys:/login",0x0,0x0); printf("Error Starting System\n"); - exit(-1); + exit(0x0); } else { while (pidStatus(i) > 0x0) { @@ -94,11 +93,20 @@ } goto startup; } - return(0); + return(0x0); } /*** $Log$ + Revision 1.14 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.13 2004/07/17 18:16:45 reddawg Hmm diff --git a/src/bin/shell/commands.c b/src/bin/shell/commands.c index 5a119b9..0aab32b 100644 --- a/src/bin/shell/commands.c +++ b/src/bin/shell/commands.c @@ -111,10 +111,8 @@ } } else if (memcmp(data->args->arg,"msg",3) == 0x0) { + printf("Posting Message\n"); mpiPostMessage(data->argv[1],atoi(data->argv[2]),data->argv[3]); - for (i=0;i<10;i++) { - sched_yield(); - } } else if (memcmp(data->args->arg,"mkdir",5) == 0x0) { if (data->argv[1]) { diff --git a/src/sys/isa/atkbd.c b/src/sys/isa/atkbd.c index 454b2d3..459bfa7 100644 --- a/src/sys/isa/atkbd.c +++ b/src/sys/isa/atkbd.c @@ -176,10 +176,10 @@ " mov $0x60,%dx \n" " inb %dx,%al \n" " push %eax \n" - " mov $0x20,%dx \n" /* The Following Sends Our EOI To The MPIC */ + " call keyboardHandler \n" + " mov $0x20,%dx \n" /* The Following Sends Our EOI To The MPIC */ " mov $0x20,%ax \n" " outb %al,%dx \n" - " call keyboardHandler \n" " pop %eax \n" " popa \n" " iret \n" /* Exit interrupt */ @@ -289,6 +289,9 @@ /*** $Log$ + Revision 1.15 2004/07/26 19:15:49 reddawg + test code, fixes and the like + Revision 1.14 2004/07/25 05:32:58 reddawg fixed diff --git a/src/sys/kernel/exec.c b/src/sys/kernel/exec.c index ab14306..238b9f5 100644 --- a/src/sys/kernel/exec.c +++ b/src/sys/kernel/exec.c @@ -295,8 +295,6 @@ elfProgramHeader *programHeader = 0x0; elfSectionHeader *sectionHeader = 0x0; elfDynamic *elfDynamicS = 0x0; - - //tmp = (uInt32 *)0x5D1FA0; tmpFd = fopen(file,"r"); _current->imageFd = tmpFd; @@ -420,6 +418,12 @@ /*** $Log$ + Revision 1.55 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.54 2004/07/28 00:24:20 reddawg removed debug code diff --git a/src/sys/kernel/file.c b/src/sys/kernel/file.c index ea17d6b..c030b6f 100644 --- a/src/sys/kernel/file.c +++ b/src/sys/kernel/file.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -272,6 +273,12 @@ /*** $Log$ + Revision 1.9 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.8 2004/07/28 00:17:05 reddawg Major: Disconnected page 0x0 from the system... Unfortunately this broke many things diff --git a/src/sys/kernel/syscall.c b/src/sys/kernel/syscall.c index fdf0ee2..3d24fbc 100644 --- a/src/sys/kernel/syscall.c +++ b/src/sys/kernel/syscall.c @@ -175,38 +175,14 @@ return; } -void sysMpiCreateMbox(uInt32 *status,char *name) { - if (status && name) - *status = mpiCreateMbox(name); - return; - } - -void sysMpiDestroyMbox(uInt32 *status,char *name) { - if (status && name) - *status = mpiDestroyMbox(name); - return; - } - -void sysMpiPostMessage(char *name,uInt32 *type,void *data) { - if (type && name && data) - *type = mpiPostMessage(name,*type,data); - return; - } - -void sysMpiFetchMessage(char *name,mpiMessage_t *msg,uInt32 *status) { - if (status && name && msg) - *status = mpiFetchMessage(name,msg); - return; - } - -void sysMpiSpam(uInt32 type,void *data,uInt32 *status) { - if (status && data) - *status = mpiSpam(type,data); - return; - } - /*** $Log$ + Revision 1.23 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.22 2004/07/21 21:03:03 reddawg we now check all the pointers diff --git a/src/sys/kernel/systemtask.c b/src/sys/kernel/systemtask.c index ba781a4..24810a2 100644 --- a/src/sys/kernel/systemtask.c +++ b/src/sys/kernel/systemtask.c @@ -50,6 +50,7 @@ while(1) { if (mpiFetchMessage("system",&myMsg) == 0x0) { + kprintf("A"); switch(myMsg.type) { case 1000: kprintf("Restarting the system in 5 seconds\n"); @@ -91,6 +92,9 @@ /*** $Log$ + Revision 1.7 2004/07/20 22:29:55 reddawg + assert: remade assert + Revision 1.6 2004/06/29 11:27:30 reddawg sdeStop - Turn printf off until modes have changed diff --git a/src/sys/mpi/Makefile b/src/sys/mpi/Makefile index c6584c5..c06a5a4 100644 --- a/src/sys/mpi/Makefile +++ b/src/sys/mpi/Makefile @@ -6,7 +6,7 @@ include ../Makefile.inc # Objects -OBJS = message.o +OBJS = system.o message.o all: $(OBJS) diff --git a/src/sys/mpi/message.c b/src/sys/mpi/message.c index 3bb41a7..2dd767d 100644 --- a/src/sys/mpi/message.c +++ b/src/sys/mpi/message.c @@ -28,254 +28,39 @@ *****************************************************************************************/ #include -#include -#include -#include -static mpiMbox_t *mboxList = 0x0; -static spinLock_t mpiSpinLock = SPIN_LOCK_INITIALIZER; - -/***************************************************************************************** - - Function: static mpiMbox_t * mpiFindMbox(char *name) - - Description: This function will find a mail box that matches the supplied name - - Notes: - -*****************************************************************************************/ -static mpiMbox_t * mpiFindMbox(char *name) { - mpiMbox_t *mbox = 0x0; - - for (mbox = mboxList;mbox;mbox = mbox->next) { - if (!strcmp(mbox->name,name)) { - spinUnlock(&mpiSpinLock); - return(mbox); - } - } - - return(0x0); +void sysMpiCreateMbox(uInt32 *status,char *name) { + if (status && name) + *status = mpiCreateMbox(name); + return; } -/***************************************************************************************** - - Function: int mpiCreateMbox(char *name) - - Description: This function will create a new mailbox if it fails it will return -1 - otherwise it returns 0x0 - - Notes: - -*****************************************************************************************/ -int mpiCreateMbox(char *name) { - mpiMbox_t *mbox = 0x0; - - spinLock(&mpiSpinLock); - - if (mpiFindMbox(name) != 0x0) { - spinUnlock(&mpiSpinLock); - return(-1); - } - - mbox = (mpiMbox_t *)kmalloc(sizeof(mpiMbox_t)); - - sprintf(mbox->name,name); - mbox->pid = _current->id; - - if (mboxList == 0x0) { - mbox->prev = 0x0; - mbox->next = 0x0; - mboxList = mbox; - } - else { - mbox->next = mboxList; - mbox->prev = 0x0; - mboxList->prev = mbox; - mboxList = mbox; - } - - spinUnlock(&mpiSpinLock); - return(0x0); +void sysMpiDestroyMbox(uInt32 *status,char *name) { + if (status && name) + *status = mpiDestroyMbox(name); + return; } -/***************************************************************************************** - - Function: int mpiSpam(uInt32 type,void *data) - - Description: This function will send a message to every mailbox - - Notes: - -*****************************************************************************************/ -int mpiSpam(uInt32 type,void *data) { - mpiMbox_t *mbox = 0x0; - mpiMessage_t *message = 0x0; - - spinLock(&mpiSpinLock); - - for (mbox = mboxList;mbox;mbox = mbox->next) { - message = (mpiMessage_t *)kmalloc(sizeof(mpiMessage_t)); - - message->type = type; - memcpy(message->data,data,MESSAGE_LENGTH); - message->next = 0x0; - - if (mbox->msg == 0x0) { - mbox->msg = message; - } - else { - mbox->msgLast->next = message; - mbox->msgLast = message; - } - } - - spinUnlock(&mpiSpinLock); - return(0x0); +void sysMpiPostMessage(char *name,uInt32 *type,void *data) { + if (type && name && data) + *type = mpiPostMessage(name,*type,data); + return; } -/***************************************************************************************** - - Function: int mpiPostMessage(char *name,uInt32 type,void *data) - - Description: This function will post a message to specified mailbox - - Notes: - -*****************************************************************************************/ -int mpiPostMessage(char *name,uInt32 type,void *data) { - mpiMbox_t *mbox = 0x0; - mpiMessage_t *message = 0x0; - - spinLock(&mpiSpinLock); - - mbox = mpiFindMbox(name); - - if (mbox == 0x0) { - spinUnlock(&mpiSpinLock); - return(-1); - } - - message = (mpiMessage_t *)kmalloc(sizeof(mpiMessage_t)); - - message->type = type; - memcpy(message->data,data,MESSAGE_LENGTH); - message->next = 0x0; - - if (mbox->msg == 0x0) { - mbox->msg = message; - } - else { - mbox->msgLast->next = message; - mbox->msgLast = message; - } - - spinUnlock(&mpiSpinLock); - return(0x0); +void sysMpiFetchMessage(char *name,mpiMessage_t *msg,uInt32 *status) { + if (status && name && msg) + *status = mpiFetchMessage(name,msg); + return; } -/***************************************************************************************** - - Function: int mpiFetchMessage(char *name,mpiMessage_t *msg) - - Description: This function will fetch the next message out of the specified mailbox - - Notes: - -*****************************************************************************************/ -int mpiFetchMessage(char *name,mpiMessage_t *msg) { - mpiMbox_t *mbox = 0x0; - mpiMessage_t *tmpMsg = 0x0; - - spinLock(&mpiSpinLock); - - mbox = mpiFindMbox(name); - - if (mbox == 0x0) { - spinUnlock(&mpiSpinLock); - return(-1); - } - - if (mbox->msg == 0x0) { - spinUnlock(&mpiSpinLock); - return(-1); - } - - if (mbox->pid != _current->id) { - spinUnlock(&mpiSpinLock); - return(-1); - } - - msg->type = mbox->msg->type; - memcpy(msg->data,mbox->msg->data,MESSAGE_LENGTH); - - tmpMsg = mbox->msg; - mbox->msg = mbox->msg->next; - - kfree(tmpMsg); - - spinUnlock(&mpiSpinLock); - return(0x0); - } - -/***************************************************************************************** - - Function: int mpiDestroyMbox(char *name) - - Description: This function will fetch the next message out of the specified mailbox - - Notes: - -*****************************************************************************************/ -int mpiDestroyMbox(char *name) { - mpiMbox_t *mbox = 0x0; - - spinLock(&mpiSpinLock); - - for (mbox = mboxList;mbox;mbox=mbox->next) { - if (!strcmp(mbox->name,name)) { - if (mbox->pid != _current->id) { - spinUnlock(&mpiSpinLock); - return(-1); - } - mbox->prev->next = mbox->next; - mbox->next->prev = mbox->prev; - kfree(mbox); - spinUnlock(&mpiSpinLock); - return(0x0); - } - } - - spinUnlock(&mpiSpinLock); - return(-1); +void sysMpiSpam(uInt32 type,void *data,uInt32 *status) { + if (status && data) + *status = mpiSpam(type,data); + return; } /*** $Log$ - Revision 1.9 2004/05/26 15:34:29 reddawg - mpi: oops forgot a spinUnlock - - Revision 1.8 2004/05/26 11:58:37 reddawg - mpi: Fixed security now the pid used at time of mpiCreateMbox is the only pid - allowed to do mpiFetchMessage and mpiDestroyMbox against that mail box - - Revision 1.7 2004/05/25 22:25:39 reddawg - Typo Fix - - Revision 1.6 2004/05/25 18:32:02 reddawg - Made MESSAGE_LENGTH define instead of hard coded message size - - Revision 1.4 2004/05/25 16:52:22 reddawg - We now have mpiDestroyMbox(char *) This will of course destroy a mail box - - Revision 1.3 2004/05/25 16:33:26 reddawg - Added some basic documentation - - Revision 1.2 2004/05/25 15:42:18 reddawg - Enabled mpiSpam(); - - Revision 1.1 2004/05/25 14:03:22 reddawg - First insertion of the MPI into our kernel - END ***/ diff --git a/src/sys/mpi/system.c b/src/sys/mpi/system.c new file mode 100644 index 0000000..986ff72 --- /dev/null +++ b/src/sys/mpi/system.c @@ -0,0 +1,284 @@ +/***************************************************************************************** + Copyright (c) 2002-2004 The UbixOS Project + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are + permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of + conditions, the following disclaimer and the list of authors. Redistributions in binary + form must reproduce the above copyright notice, this list of conditions, the following + disclaimer and the list of authors in the documentation and/or other materials provided + with the distribution. Neither the name of the UbixOS Project nor the names of its + contributors may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id$ + +*****************************************************************************************/ + +#include +#include +#include +#include + +static mpiMbox_t *mboxList = 0x0; +static spinLock_t mpiSpinLock = SPIN_LOCK_INITIALIZER; + +/***************************************************************************************** + + Function: static mpiMbox_t * mpiFindMbox(char *name) + + Description: This function will find a mail box that matches the supplied name + + Notes: + +*****************************************************************************************/ +static mpiMbox_t * mpiFindMbox(char *name) { + mpiMbox_t *mbox = 0x0; + + for (mbox = mboxList;mbox;mbox = mbox->next) { + if (!strcmp(mbox->name,name)) { + spinUnlock(&mpiSpinLock); + return(mbox); + } + } + + return(0x0); + } + +/***************************************************************************************** + + Function: int mpiCreateMbox(char *name) + + Description: This function will create a new mailbox if it fails it will return -1 + otherwise it returns 0x0 + + Notes: + +*****************************************************************************************/ +int mpiCreateMbox(char *name) { + mpiMbox_t *mbox = 0x0; + + spinLock(&mpiSpinLock); + + if (mpiFindMbox(name) != 0x0) { + spinUnlock(&mpiSpinLock); + return(-1); + } + + mbox = (mpiMbox_t *)kmalloc(sizeof(mpiMbox_t)); + + sprintf(mbox->name,name); + mbox->pid = _current->id; + + if (mboxList == 0x0) { + mbox->prev = 0x0; + mbox->next = 0x0; + mboxList = mbox; + } + else { + mbox->next = mboxList; + mbox->prev = 0x0; + mboxList->prev = mbox; + mboxList = mbox; + } + + spinUnlock(&mpiSpinLock); + return(0x0); + } + +/***************************************************************************************** + + Function: int mpiSpam(uInt32 type,void *data) + + Description: This function will send a message to every mailbox + + Notes: + +*****************************************************************************************/ +int mpiSpam(uInt32 type,void *data) { + mpiMbox_t *mbox = 0x0; + mpiMessage_t *message = 0x0; + + spinLock(&mpiSpinLock); + + for (mbox = mboxList;mbox;mbox = mbox->next) { + message = (mpiMessage_t *)kmalloc(sizeof(mpiMessage_t)); + + message->type = type; + memcpy(message->data,data,MESSAGE_LENGTH); + message->next = 0x0; + + if (mbox->msg == 0x0) { + mbox->msg = message; + } + else { + mbox->msgLast->next = message; + mbox->msgLast = message; + } + } + + spinUnlock(&mpiSpinLock); + return(0x0); + } + +/***************************************************************************************** + + Function: int mpiPostMessage(char *name,uInt32 type,void *data) + + Description: This function will post a message to specified mailbox + + Notes: + +*****************************************************************************************/ +int mpiPostMessage(char *name,uInt32 type,void *data) { + mpiMbox_t *mbox = 0x0; + mpiMessage_t *message = 0x0; + + spinLock(&mpiSpinLock); + + mbox = mpiFindMbox(name); + + if (mbox == 0x0) { + spinUnlock(&mpiSpinLock); + return(-1); + } + + message = (mpiMessage_t *)kmalloc(sizeof(mpiMessage_t)); + + message->type = type; + memcpy(message->data,data,MESSAGE_LENGTH); + message->next = 0x0; + + if (mbox->msg == 0x0) { + mbox->msg = message; + } + else { + mbox->msgLast->next = message; + mbox->msgLast = message; + } + + spinUnlock(&mpiSpinLock); + return(0x0); + } + +/***************************************************************************************** + + Function: int mpiFetchMessage(char *name,mpiMessage_t *msg) + + Description: This function will fetch the next message out of the specified mailbox + + Notes: + +*****************************************************************************************/ +int mpiFetchMessage(char *name,mpiMessage_t *msg) { + mpiMbox_t *mbox = 0x0; + mpiMessage_t *tmpMsg = 0x0; + + spinLock(&mpiSpinLock); + + mbox = mpiFindMbox(name); + + if (mbox == 0x0) { + spinUnlock(&mpiSpinLock); + return(-1); + } + + if (mbox->msg == 0x0) { + spinUnlock(&mpiSpinLock); + return(-1); + } + + if (mbox->pid != _current->id) { + spinUnlock(&mpiSpinLock); + return(-1); + } + + msg->type = mbox->msg->type; + memcpy(msg->data,mbox->msg->data,MESSAGE_LENGTH); + + tmpMsg = mbox->msg; + mbox->msg = mbox->msg->next; + + kfree(tmpMsg); + + spinUnlock(&mpiSpinLock); + return(0x0); + } + +/***************************************************************************************** + + Function: int mpiDestroyMbox(char *name) + + Description: This function will fetch the next message out of the specified mailbox + + Notes: + +*****************************************************************************************/ +int mpiDestroyMbox(char *name) { + mpiMbox_t *mbox = 0x0; + + spinLock(&mpiSpinLock); + + for (mbox = mboxList;mbox;mbox=mbox->next) { + if (!strcmp(mbox->name,name)) { + if (mbox->pid != _current->id) { + spinUnlock(&mpiSpinLock); + return(-1); + } + mbox->prev->next = mbox->next; + mbox->next->prev = mbox->prev; + kfree(mbox); + spinUnlock(&mpiSpinLock); + return(0x0); + } + } + + spinUnlock(&mpiSpinLock); + return(-1); + } + +/*** + $Log$ + Revision 1.10 2004/06/28 23:12:58 reddawg + file format now container:/path/to/file + + Revision 1.9 2004/05/26 15:34:29 reddawg + mpi: oops forgot a spinUnlock + + Revision 1.8 2004/05/26 11:58:37 reddawg + mpi: Fixed security now the pid used at time of mpiCreateMbox is the only pid + allowed to do mpiFetchMessage and mpiDestroyMbox against that mail box + + Revision 1.7 2004/05/25 22:25:39 reddawg + Typo Fix + + Revision 1.6 2004/05/25 18:32:02 reddawg + Made MESSAGE_LENGTH define instead of hard coded message size + + Revision 1.4 2004/05/25 16:52:22 reddawg + We now have mpiDestroyMbox(char *) This will of course destroy a mail box + + Revision 1.3 2004/05/25 16:33:26 reddawg + Added some basic documentation + + Revision 1.2 2004/05/25 15:42:18 reddawg + Enabled mpiSpam(); + + Revision 1.1 2004/05/25 14:03:22 reddawg + First insertion of the MPI into our kernel + + END + ***/ +