diff --git a/src/sys/include/ubixos/sched.h b/src/sys/include/ubixos/sched.h index 80662c4..4369b6d 100644 --- a/src/sys/include/ubixos/sched.h +++ b/src/sys/include/ubixos/sched.h @@ -30,9 +30,6 @@ #ifndef _SCHED_H #define _SCHED_H -#ifdef __cplusplus -extern "C" { -#endif #include #include @@ -41,8 +38,8 @@ #include -typedef enum { PLACEHOLDER=-2,DEAD=-1,NEW=0,READY=1,RUNNING=2,IDLE=3,FORK=4,WAIT=5 } tState; - +//typedef enum { PLACEHOLDER=-2,DEAD=-1,NEW=0,READY=1,RUNNING=2,IDLE=3,FORK=4,WAIT=5 } tState; +typedef enum { PLACEHOLDER = -2,DEAD,NEW,READY,RUNNING,IDLE,FORK,WAIT } tState; struct osInfo { uInt8 timer; uInt8 v86Task; @@ -55,11 +52,12 @@ }; typedef struct taskStruct { - pidType id; struct taskStruct *prev; struct taskStruct *next; struct i387Struct i387; struct i386_frame *iframe; + pidType id; + pidType parentPid; struct osInfo oInfo; uInt32 cr3; char kernelStack[0x2000]; @@ -67,9 +65,9 @@ tState state; uInt32 gid; uInt32 uid; + uInt32 timeSlice; uInt16 usedMath; uInt16 nice; - uInt32 timeSlice; tty_term *term; } kTask_t; @@ -95,15 +93,15 @@ extern kTask_t *_current; extern kTask_t *_usedMath; - -#ifdef __cplusplus -} -#endif +extern kTask_t *delList; #endif /*** $Log$ + Revision 1.22 2004/08/21 23:47:50 reddawg + *** empty log message *** + Revision 1.21 2004/08/21 17:36:57 reddawg updates: converted to software task switching however it is not working yet diff --git a/src/sys/kernel/endtask.c b/src/sys/kernel/endtask.c index 91d8662..bd088e9 100644 --- a/src/sys/kernel/endtask.c +++ b/src/sys/kernel/endtask.c @@ -43,21 +43,30 @@ ************************************************************************/ void endTask(pidType pid) { + kTask_t *tmpTask = schedFindTask(pid); + + tmpTask->term->owner = tmpTask->parentPid; + vmmFreeProcessPages(pid); + if (_current->imageFd) fclose(_current->imageFd); - //kprintf("FreePage: [0x%X]\n",systemVitals->freePages); - sched_setStatus(_current->id,DEAD); + + sched_setStatus(pid,DEAD); sched_yield(); - - /* incase sched_yield failes */ - while (1) + while (1) { + //kprintf("Should Of Ended: [%i:%i:%i]\n",pid,_current->id,_current->state); asm("hlt"); + } + return; } /*** $Log$ + Revision 1.16 2004/08/09 12:58:05 reddawg + let me know when you got the surce + Revision 1.15 2004/08/06 22:43:04 reddawg ok diff --git a/src/sys/kernel/exec.c b/src/sys/kernel/exec.c index de777e8..a42dfc3 100644 --- a/src/sys/kernel/exec.c +++ b/src/sys/kernel/exec.c @@ -90,7 +90,7 @@ newProcess->cr3 = (uInt32)kernelPageDirectory; newProcess->iframe->eip = (uInt32)tproc; newProcess->iframe->flags = 0x206; - newProcess->iframe->esp = &newProcess->kernelStack + 0x2000 - sizeof(struct i386_frame); + newProcess->iframe->esp = (uInt32)&newProcess->kernelStack + 0x2000 - sizeof(struct i386_frame); newProcess->iframe->ebp = stack; newProcess->iframe->user_esp = stack; newProcess->iframe->user_ss = 0x10; @@ -290,7 +290,7 @@ _current->iframe->eip = (uInt32)binaryHeader->eEntry; _current->iframe->flags = 0x206; - _current->iframe->esp = &_current->kernelStack + 0x2000 - sizeof(struct i386_frame); + _current->iframe->esp = (uInt32)&_current->kernelStack + 0x2000 - sizeof(struct i386_frame); _current->iframe->ebp = 0x5DD000; _current->iframe->user_esp = 0x5DD000 - 12; _current->iframe->user_ss = 0x30 + 3; @@ -459,11 +459,11 @@ /* Now That We Relocated The Binary We Can Unmap And Free Header Info */ - iframe = _current->kernelStack;//(_current->kernelStack + 0x1000) - sizeof(struct i386_frame); + iframe = (struct i386_frame *)_current->kernelStack;//(_current->kernelStack + 0x1000) - sizeof(struct i386_frame); memset(iframe,0x0,sizeof(struct i386_frame)); iframe->eip = (uInt32)binaryHeader->eEntry; iframe->flags = 0x206; - iframe->esp = &_current->kernelStack + 0x2000 - sizeof(struct i386_frame); + iframe->esp = (uInt32)&_current->kernelStack + 0x2000 - sizeof(struct i386_frame); iframe->ebp = 0x5DD000; iframe->user_esp = 0x5DD000 - 12; iframe->user_ss = 0x30 + 3; @@ -495,6 +495,9 @@ /*** $Log$ + Revision 1.68 2004/08/25 22:02:41 reddawg + task switching - We now are using software switching to be consistant with the rest of the world because all of this open source freaks gave me a hard time about something I liked. There doesn't seem to be any gain in performance but it is working fine and flawlessly + Revision 1.67 2004/08/24 05:24:37 reddawg TCA Is A BONER!!!! diff --git a/src/sys/kernel/fork.c b/src/sys/kernel/fork.c index ccab089..b29fc1d 100644 --- a/src/sys/kernel/fork.c +++ b/src/sys/kernel/fork.c @@ -68,13 +68,14 @@ 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); - //memcpy(newProcess->kernelStack,_current->kernelStack,0x2000); - //newProcess->iframe = ((uInt32)newProcess->kernelStack + ((uInt32)_current->iframe - (uInt32)_current->kernelStack)); + sprintf(newProcess->oInfo.cwd,_current->oInfo.cwd); newProcess->oInfo.vmStart = _current->oInfo.vmStart; newProcess->term = _current->term; newProcess->uid = _current->uid; newProcess->gid = _current->gid; + newProcess->parentPid = _current->id; + newProcess->term->owner = newProcess->id; newProcess->iframe->gs = 0x33;//_current->iframe->gs; newProcess->iframe->fs = 0x33;//_current->iframe->gs; newProcess->iframe->es = 0x33;//_current->iframe->es; @@ -83,7 +84,7 @@ newProcess->iframe->edi = edi; newProcess->iframe->esi = esi; newProcess->iframe->ebp = ebp; - newProcess->iframe->esp = (newProcess->kernelStack + 0x2000) - sizeof(struct i386_frame); + newProcess->iframe->esp = (uInt32)(newProcess->kernelStack + 0x2000) - sizeof(struct i386_frame); newProcess->iframe->ebx = ebx; newProcess->iframe->edx = edx; newProcess->iframe->ecx = ecx; @@ -108,6 +109,9 @@ /*** $Log$ + Revision 1.28 2004/08/25 22:02:41 reddawg + task switching - We now are using software switching to be consistant with the rest of the world because all of this open source freaks gave me a hard time about something I liked. There doesn't seem to be any gain in performance but it is working fine and flawlessly + Revision 1.27 2004/08/24 23:33:45 reddawg Fixed diff --git a/src/sys/kernel/sched.c b/src/sys/kernel/sched.c index bfe2ccc..325f842 100644 --- a/src/sys/kernel/sched.c +++ b/src/sys/kernel/sched.c @@ -42,11 +42,11 @@ static spinLock_t sched_spinLock = SPIN_LOCK_INITIALIZER; static kTask_t *runList = 0x0; -static kTask_t *delList = 0x0; -static uInt32 nextID = -1; +static uInt32 nextID = -1; -kTask_t *_current = 0x0; -kTask_t *_usedMath = 0x0; +kTask_t *_current = 0x0; +kTask_t *_usedMath = 0x0; +kTask_t *delList = 0x0; static struct tssStruct *sched_tss = 0x0; @@ -59,11 +59,32 @@ 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); + + /* Fix fork mode we hold one cycle to let the task get a good footing */ + if (tmpTask->state == DEAD) { + if (tmpTask->prev != 0x0) + tmpTask->prev->next = tmpTask->next; + if (tmpTask->next != 0x0) + tmpTask->next->prev = tmpTask->prev; + if (tmpTask == runList) + runList = tmpTask->next; + + delTask = tmpTask; + tmpTask = tmpTask->next; + + delTask->next = delList; + if (delList != 0x0) + delList->prev = delTask; + delList = delTask; + } + if (tmpTask->state == FORK) + tmpTask->state = READY; + + /* Return ready task */ + if (tmpTask->state == READY) + return(tmpTask); + } /* Finished all the tasks, restarting the list */ @@ -134,7 +155,6 @@ } uInt32 sched(struct i386_frame iframe) { - uInt32 memAddr = 0x0; kTask_t *tmpTask = 0x0; _current->iframe = &iframe; @@ -154,7 +174,7 @@ /* Switch Tasks */ - sched_tss->esp0 = _current->kernelStack + 0x2000; + sched_tss->esp0 = (uInt32)_current->kernelStack + 0x2000; asm volatile( "mov %0,%%eax \n" @@ -164,7 +184,7 @@ ); /* Return IFRAME */ - return (_current->iframe); + return ((uInt32)_current->iframe); } kTask_t *schedNewTask() { @@ -190,55 +210,24 @@ runList->prev = tmpTask; runList = tmpTask; - tmpTask->iframe = (tmpTask->kernelStack + 0x2000) - sizeof(struct i386_frame); + tmpTask->iframe = (struct i386_frame *)(tmpTask->kernelStack + 0x2000) - sizeof(struct i386_frame); spinUnlock(&sched_spinLock); return(tmpTask); } -/* - * This is at least O(N)... it was written to - * have it functional; soon it will be changed to O(1). - */ - -int -schedDeleteTask(uInt32 id) { +kTask_t *schedFindTask(uInt32 id) { kTask_t *tmpTask = 0x0; - /* Checking each task from the prio queue */ - for (tmpTask = runList; tmpTask != 0x0; tmpTask = tmpTask->next) { - if (tmpTask->id == id) { - if (_current == tmpTask) - kpanic("you can not delete yourself!!!\n"); - if (tmpTask == runList) - kpanic("Whoa"); - if (tmpTask->prev) - tmpTask->prev->next = tmpTask->next; - if (tmpTask->next) - tmpTask->next->prev = tmpTask->prev; - kfree(tmpTask->oInfo.cwd); - kfree(tmpTask); - return(0x0); - } - } - return(0x1); + for (tmpTask = runList;tmpTask != 0x0;tmpTask = tmpTask->next) { + if (tmpTask->id == id) + return(tmpTask); + } + + return(0x0); } -kTask_t * -schedFindTask(uInt32 id) -{ - kTask_t *tmpTask = 0x0; - - for (tmpTask = runList; tmpTask; tmpTask = tmpTask->next) { - if (tmpTask->id == id) - return(tmpTask); - } - - return(0x0); -} - - /************************************************************************ Function: void schedEndTask() @@ -252,9 +241,9 @@ ************************************************************************/ void schedEndTask(pidType pid) { - endTask(_current->id); - sched_yield(); -} + endTask(_current->id); + sched_yield(); + } /************************************************************************ @@ -269,22 +258,10 @@ ************************************************************************/ void sched_yield() { + //sched(); asm("hlt"); - /* - asm("cli"); - sched(); - asm("sti"); - */ } -/* -asm( - ".globl sched_yield \n" - "sched_yield: \n" - " cli \n" - " call sched \n" - ); -*/ /************************************************************************ @@ -305,6 +282,9 @@ /*** $Log$ + Revision 1.43 2004/08/25 22:02:41 reddawg + task switching - We now are using software switching to be consistant with the rest of the world because all of this open source freaks gave me a hard time about something I liked. There doesn't seem to be any gain in performance but it is working fine and flawlessly + Revision 1.42 2004/08/24 23:33:45 reddawg Fixed diff --git a/src/sys/kernel/systemtask.c b/src/sys/kernel/systemtask.c index f56b896..7809d1d 100644 --- a/src/sys/kernel/systemtask.c +++ b/src/sys/kernel/systemtask.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -42,9 +43,10 @@ void systemTask() { mpi_message_t myMsg; - uInt32 counter = 0x0; - int i = 0x0; - int *x = 0x0; + uInt32 counter = 0x0; + int i = 0x0; + int *x = 0x0; + kTask_t *tmpTask = 0x0; if (mpi_createMbox("system") != 0x0) { kpanic("Error: Error creating mailbox: system\n"); @@ -92,8 +94,14 @@ break; } } - //kprintf("sysTask\n"); - for (i = 0x0;i<0x1000;i++) asm("hlt"); + if (delList != 0x0) { + tmpTask = delList; + delList = tmpTask->next; + + //kfree(tmpTask->oInfo.cwd); + kfree(tmpTask); + } + sched_yield(); } return; @@ -101,6 +109,9 @@ /*** $Log$ + Revision 1.14 2004/08/24 23:33:45 reddawg + Fixed + Revision 1.13 2004/08/24 05:24:37 reddawg TCA Is A BONER!!!! diff --git a/src/sys/lib/kmalloc.c b/src/sys/lib/kmalloc.c index 7e43b00..c71d9e0 100644 --- a/src/sys/lib/kmalloc.c +++ b/src/sys/lib/kmalloc.c @@ -123,7 +123,6 @@ ************************************************************************/ static int insertFreeDesc(struct memDescriptor *freeDesc) { - struct memDescriptor *tmpDesc = 0x0; assert(freeDesc); @@ -368,7 +367,7 @@ kprintf("kfree tmpDesc1: [%i]\n",tmpDesc1->limit); insertFreeDesc(tmpDesc1); - //mergeMemBlocks(); + mergeMemBlocks(); spinUnlock(&mallocSpinLock); return; } @@ -380,6 +379,12 @@ /*** $Log$ + Revision 1.21 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.20 2004/07/28 00:17:05 reddawg Major: Disconnected page 0x0 from the system... Unfortunately this broke many things diff --git a/src/sys/net/core/udp.c b/src/sys/net/core/udp.c index 776324a..a5177ce 100644 --- a/src/sys/net/core/udp.c +++ b/src/sys/net/core/udp.c @@ -61,7 +61,7 @@ /* The list of UDP PCBs. */ static struct udp_pcb *udp_pcbs = NULL; -static struct udp_pcb *pcb_cache = NULL; +// UBU static struct udp_pcb *pcb_cache = NULL; #if UDP_DEBUG int udp_debug_print(struct udp_hdr *udphdr); diff --git a/src/sys/net/net/bot.c b/src/sys/net/net/bot.c index 8b03ac1..12da8d7 100644 --- a/src/sys/net/net/bot.c +++ b/src/sys/net/net/bot.c @@ -43,6 +43,7 @@ #include "net/api.h" #include "net/stats.h" +/* UBU static void sendstr(const char *str, struct netconn *conn) { netconn_write(conn, (void *)str, strlen(str), NETCONN_NOCOPY); } @@ -50,6 +51,7 @@ static void botErr() { kprintf("ERRROR\n"); } +*/ static void bot_thread(void *arg) { struct netconn *conn; diff --git a/src/sys/net/net/shell.c b/src/sys/net/net/shell.c index 32e7ed6..4bea657 100644 --- a/src/sys/net/net/shell.c +++ b/src/sys/net/net/shell.c @@ -52,7 +52,7 @@ #define ECLOSED -4 #define NCONNS 10 -static struct netconn *conns[NCONNS]; +// UBU static struct netconn *conns[NCONNS]; static void sendstr(const char *str, struct netconn *conn) { netconn_write(conn, (void *)str, strlen(str), NETCONN_NOCOPY); @@ -65,8 +65,8 @@ static void shell_main(struct netconn *conn) { struct netbuf *buf = 0x0; uInt32 len; - int i; - char bufr[1500]; + // UBU int i; + // UBU char bufr[1500]; prompt(conn); while (1) { buf = netconn_recv(conn); diff --git a/src/sys/net/netif/tcpdump.c b/src/sys/net/netif/tcpdump.c index 582224f..8fcef44 100644 --- a/src/sys/net/netif/tcpdump.c +++ b/src/sys/net/netif/tcpdump.c @@ -55,6 +55,7 @@ } void tcpdump(struct pbuf *p) { +/* struct ip_hdr *iphdr; struct tcp_hdr *tcphdr; struct udp_hdr *udphdr; @@ -62,7 +63,7 @@ int i; int len; int offset; - +*/ if (file == NULL) { return; } diff --git a/src/sys/pci/hd.c b/src/sys/pci/hd.c index e0d790b..2d1be68 100644 --- a/src/sys/pci/hd.c +++ b/src/sys/pci/hd.c @@ -34,6 +34,7 @@ #include #include #include +#include void initHardDisk() { int i = 0x0; @@ -315,6 +316,9 @@ /*** $Log$ + Revision 1.15 2004/08/15 00:33:02 reddawg + Wow the ide driver works again + Revision 1.14 2004/08/14 21:56:44 reddawg Added initialized byte to the device system to make it easy to add child devices which use parent hardware. diff --git a/src/sys/ubixfs/ubixfs.c b/src/sys/ubixfs/ubixfs.c index 222496b..f512757 100644 --- a/src/sys/ubixfs/ubixfs.c +++ b/src/sys/ubixfs/ubixfs.c @@ -54,7 +54,7 @@ /* kprintf("openFileUbixFS(%s), cwd: %s\n", file, _current->oInfo.cwd); */ -if (fsInfo->dirCache == NULL) kprintf("dirCache is null!\n"); +//if (fsInfo->dirCache == NULL) kprintf("dirCache is null!\n"); assert(fd); assert(fd->mp); assert(fd->mp->device); @@ -71,8 +71,7 @@ if (cacheNode->present == 1) break; assert(cacheNode->size); if (*cacheNode->size != 0 && cacheNode->info == NULL) { - kprintf("caching name(size): %s(%d)\n",cacheNode->name, - *cacheNode->size); + //kprintf("caching name(size): %s(%d)\n",cacheNode->name,*cacheNode->size); cacheNode->info = kmalloc(UBIXFS_ALIGN(*cacheNode->size)); fd->size = *cacheNode->size; assert(cacheNode->startCluster); @@ -482,6 +481,9 @@ /*** $Log$ + Revision 1.43 2004/08/14 11:23:02 reddawg + Changes + Revision 1.42 2004/08/09 12:58:05 reddawg let me know when you got the surce