diff --git a/src/bin/init/main.c b/src/bin/init/main.c index c855966..4ca3fdb 100644 --- a/src/bin/init/main.c +++ b/src/bin/init/main.c @@ -37,9 +37,6 @@ int main(int argc,char **argv) { int i=0x0; mpi_message_t myMsg; - - printf("A\n"); - while (1); /* Create a mailbox for this task */ if (mpi_createMbox("init") != 0x0) { @@ -56,7 +53,16 @@ printf("Initializing UbixOS\n"); /* Start TTYD */ + for (i=0;i<100;i++) { + printf("[%i]",i); + } + printf("\nG\n"); i = fork(); + printf("\nC\n"); + for (i=0;i<100;i++) { + printf("[%i]",i); + } + while (1); if (0x0 == i) { exec("sys:/ttyd",0x0,0x0); printf("Error: Could not start TTYD\n"); @@ -109,6 +115,9 @@ /*** $Log$ + Revision 1.20 2004/08/21 20:21:20 reddawg + *** empty log message *** + Revision 1.19 2004/08/14 11:29:42 reddawg ok diff --git a/src/sys/Makefile.inc b/src/sys/Makefile.inc index 4239ab7..1deafc3 100644 --- a/src/sys/Makefile.inc +++ b/src/sys/Makefile.inc @@ -2,5 +2,5 @@ # global 'sys' options INCLUDES = -I../include -CFLAGS = -Wall -nostdlib -nostdinc -fno-builtin -fomit-frame-pointer -fno-exceptions -O +CFLAGS = -Wall -nostdlib -nostdinc -fno-builtin -fno-exceptions -O KERNEL = ubix.elf diff --git a/src/sys/include/ubixos/sched.h b/src/sys/include/ubixos/sched.h index 50b4641..80662c4 100644 --- a/src/sys/include/ubixos/sched.h +++ b/src/sys/include/ubixos/sched.h @@ -85,7 +85,7 @@ int sched_init(); int sched_setStatus(pidType,tState); -void sched(); +uInt32 sched(struct i386_frame); void sched_yield(); void schedEndTask(pidType pid); @@ -104,6 +104,9 @@ /*** $Log$ + Revision 1.21 2004/08/21 17:36:57 reddawg + updates: converted to software task switching however it is not working yet + Revision 1.20 2004/08/09 12:58:05 reddawg let me know when you got the surce diff --git a/src/sys/init/main.c b/src/sys/init/main.c index fa81e8a..998c572 100644 --- a/src/sys/init/main.c +++ b/src/sys/init/main.c @@ -59,7 +59,7 @@ ubixStandardDescriptor(0x0, 0xFFFFF, (dCode + dRead + dBig + dBiglim)), ubixStandardDescriptor(0x0, 0xFFFFF, (dData + dWrite + dBig + dBiglim)), ubixStandardDescriptor(0x0, 0xFFFFF, (dLdt)), - ubixStandardDescriptor(0x4200, (sizeof(struct tssStruct)), (dTss)), + ubixStandardDescriptor(0x4200, (sizeof(struct tssStruct)), (dTss + dDpl3)), ubixStandardDescriptor(0x0, 0xFFFFF, (dCode + dWrite + dBig + dBiglim + dDpl3)), ubixStandardDescriptor(0x0, 0xFFFFF, (dData + dWrite + dBig + dBiglim + dDpl3)), ubixStandardDescriptor(0x4200, (sizeof(struct tssStruct)), (dTss)), @@ -71,7 +71,7 @@ } loadGDT = { (9 * sizeof(union descriptorTableUnion) - 1), ubixGDT }; void test_thread() { - //kprintf("HOLLER\n"); + kprintf("HOLLER\n"); while (1); } /***************************************************************************************** @@ -107,8 +107,8 @@ } */ initHardDisk(); - //execThread(systemTask,(uInt32)(kmalloc(0x2000)+0x2000),0x0); - + execThread(systemTask,(uInt32)(kmalloc(0x2000)+0x2000),0x0); + //execThread(test_thread,(uInt32)(kmalloc(0x2000)+0x2000),0x0); execFile("sys:/init",0x0,0x0,0x1); //execFile("sys:/login",0x0,0x0,0x1); //execFile("sys:/login",0x0,0x0,0x2); @@ -118,14 +118,17 @@ kprintf("Free Pages: [%i]\n",systemVitals->freePages); kprintf("MemoryMap: [0x%X]\n",vmmMemoryMap); kprintf("Starting Os\n"); - //irqEnable(0x0); - sched(); + irqEnable(0x0); + //sched(); while (1); return(0x0); } /*** $Log$ + Revision 1.75 2004/08/21 20:06:28 reddawg + ok check out exec.c + Revision 1.74 2004/08/21 17:36:57 reddawg updates: converted to software task switching however it is not working yet diff --git a/src/sys/isa/atkbd.c b/src/sys/isa/atkbd.c index bbe59e1..2b4241a 100644 --- a/src/sys/isa/atkbd.c +++ b/src/sys/isa/atkbd.c @@ -173,12 +173,22 @@ ".globl atkbd_isr \n" "atkbd_isr: \n" " pusha \n" /* Save all registers */ + " push %ss \n" + " push %ds \n" + " push %es \n" + " push %fs \n" + " push %gs \n" " call keyboardHandler \n" " mov $0x20,%dx \n" " mov $0x20,%ax \n" " outb %al,%dx \n" /* " sti \n" */ - " popa \n" + " pop %gs \n" + " pop %fs \n" + " pop %es \n" + " pop %ds \n" + " pop %ss \n" + " popa \n" " iret \n" /* Exit interrupt */ ); @@ -304,6 +314,9 @@ /*** $Log$ + Revision 1.22 2004/08/09 12:58:05 reddawg + let me know when you got the surce + Revision 1.21 2004/08/06 22:32:16 reddawg Ubix Works Again diff --git a/src/sys/kernel/exec.c b/src/sys/kernel/exec.c index b30f544..3f63e8b 100644 --- a/src/sys/kernel/exec.c +++ b/src/sys/kernel/exec.c @@ -90,16 +90,16 @@ newProcess->cr3 = (uInt32)kernelPageDirectory; newProcess->iframe->eip = (uInt32)tproc; newProcess->iframe->flags = 0x206; - newProcess->iframe->esp = stack; + newProcess->iframe->esp = &newProcess->kernelStack + 0x2000; newProcess->iframe->ebp = stack; newProcess->iframe->user_esp = stack; newProcess->iframe->user_ss = 0x10; newProcess->iframe->cs = 0x08; - newProcess->iframe->es = 0x10; - newProcess->iframe->ss = 0x10; - newProcess->iframe->ds = 0x10; - newProcess->iframe->fs = 0x10; - newProcess->iframe->gs = 0x10; + newProcess->iframe->es = 0x10; + newProcess->iframe->ss = 0x10; + newProcess->iframe->ds = 0x10; + newProcess->iframe->fs = 0x10; + newProcess->iframe->gs = 0x10; /* Set up default stack for thread here filled with arg list 3 times */ asm volatile( @@ -286,7 +286,7 @@ _current->iframe->eip = (uInt32)binaryHeader->eEntry; _current->iframe->flags = 0x206; - _current->iframe->esp = _current->kernelStack + 0x2000; + _current->iframe->esp = &_current->kernelStack + 0x2000; _current->iframe->ebp = 0x5DD000; _current->iframe->user_esp = 0x5DD000 - 12; _current->iframe->user_ss = 0x30 + 3; @@ -461,6 +461,9 @@ /*** $Log$ + Revision 1.65 2004/08/21 20:21:20 reddawg + *** empty log message *** + Revision 1.64 2004/08/21 20:06:28 reddawg ok check out exec.c diff --git a/src/sys/kernel/fork.c b/src/sys/kernel/fork.c index 528c96c..7b1cf93 100644 --- a/src/sys/kernel/fork.c +++ b/src/sys/kernel/fork.c @@ -48,8 +48,10 @@ ************************************************************************/ asm( - ".globl sysFork \n" - "sysFork: \n" + ".globl sysFork \n" + "sysFork: \n" + "hlt\n" + /* " xor %eax,%eax \n" " call schedNewTask \n" " testl %eax,%eax \n" @@ -58,6 +60,7 @@ " pushl %edi \n" " pushl %ebp \n" " pushl %eax \n" + */ " call forkCopyProcess \n" " movl %eax,(%ebx) \n" " addl $16,%esp \n" @@ -68,44 +71,12 @@ 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); - - /* Set Up New Tasks Information */ - /* - newProcess->tss.eip = eip; - sprintf(newProcess->oInfo.cwd,_current->oInfo.cwd); - newProcess->oInfo.vmStart = _current->oInfo.vmStart; - newProcess->term = _current->term; - newProcess->term->owner = newProcess->id; - newProcess->uid = _current->uid; - newProcess->gid = _current->gid; - newProcess->tss.back_link = 0x0; - newProcess->tss.esp0 = _current->tss.esp0; - newProcess->tss.ss0 = 0x10; - newProcess->tss.esp1 = 0x0; - newProcess->tss.ss1 = 0x0; - newProcess->tss.esp2 = 0x0; - newProcess->tss.ss2 = 0x0; - newProcess->tss.eflags = eflags; - newProcess->tss.eax = 0x0; - newProcess->tss.ebx = ebx; - newProcess->tss.ecx = ecx; - newProcess->tss.edx = edx; - newProcess->tss.esi = esi; - newProcess->tss.edi = edi; - newProcess->tss.ebp = ebp; - newProcess->tss.esp = esp; - newProcess->tss.cs = cs & 0xFF; - newProcess->tss.ss = ss & 0xFF; - newProcess->tss.ds = _current->tss.ds & 0xFF; - newProcess->tss.fs = _current->tss.fs & 0xFF; - newProcess->tss.gs = _current->tss.gs & 0xFF; - newProcess->tss.es = _current->tss.es & 0xFF; - newProcess->tss.ldt = 0x18; - newProcess->tss.trace_bitmap = 0x0000; - newProcess->tss.io_map = 0x8000; - */ + kprintf("A"); + kprintf("A"); newProcess->iframe->gs = _current->iframe->gs; + kprintf("A"); newProcess->iframe->fs = _current->iframe->fs; + kprintf("A"); newProcess->iframe->es = _current->iframe->es; newProcess->iframe->ds = _current->iframe->ds; newProcess->iframe->ss = 0x10; @@ -123,8 +94,11 @@ newProcess->iframe->user_esp = esp; newProcess->iframe->user_ss = ss; /* Create A Copy Of The VM Space For New Task */ - newProcess->cr3 = (uInt32)vmmCopyVirtualSpace(newProcess->id); + //newProcess->cr3 = (uInt32)vmmCopyVirtualSpace(newProcess->id); + kpanic("EIP: [0x%X]\n",eip); + while (1); newProcess->state = FORK; + while (newProcess->state == FORK) sched_yield(); @@ -135,6 +109,9 @@ /*** $Log$ + Revision 1.24 2004/08/21 20:21:20 reddawg + *** empty log message *** + Revision 1.23 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/sched.c b/src/sys/kernel/sched.c index 0737fca..d024dbe 100644 --- a/src/sys/kernel/sched.c +++ b/src/sys/kernel/sched.c @@ -122,24 +122,20 @@ if ((sched_tss = (struct tssStruct *)kmalloc(sizeof(struct tssStruct))) == 0x0) kpanic("malloc: Failed File: %s, Line: %i\n",__FILE__,__LINE__); - /* sched_tss.esp0 = 0x5CC000; */ sched_tss->ss0 = 0x10; - /* sched_tss.eip = (long)binaryHeader->eEntry; */ sched_tss->eflags = 0x206; - - /* Set these up to be ring 3 tasks */ - sched_tss->es = 0x10; - sched_tss->cs = 0x8; - sched_tss->ss = 0x10; - sched_tss->ds = 0x10; - sched_tss->fs = 0x10; - sched_tss->gs = 0x10; /* Adjust the GDT to reflect our new TSS */ ubixGDT[4].descriptor.baseLow = ((uInt32)sched_tss & 0xFFFF); ubixGDT[4].descriptor.baseMed = (((uInt32)sched_tss >> 16) & 0xFF); ubixGDT[4].descriptor.baseHigh = ((uInt32)sched_tss >> 24); ubixGDT[4].descriptor.access = '\x89'; + asm( + "push %eax\n" + "mov $0x20,%ax\n" + "ltr %ax\n" + "pop %eax\n" + ); sched_tss->ldt = 0x18; sched_tss->trace_bitmap = 0x0000; @@ -162,14 +158,13 @@ } -void sched() { +uInt32 sched(struct i386_frame iframe) { uInt32 memAddr = 0x0; kTask_t *tmpTask = 0x0; tmpTask = sched_getRunableTask(); if (tmpTask == 0x0) - kpanic("Error: sched_getRunableTask == 0x0\n"); - + kpanic("Error: sched_getRunableTask == 0x0\n"); /* Make this our now current task */ _current = tmpTask; @@ -177,47 +172,17 @@ /* Test if it is a 16 bit task */ if (_current->oInfo.v86Task == 0x1) irqDisable(0x0); - - /* Update our TSS to new task info */ - /* old - 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'; - */ - - /* Jump to task */ - /* old - asm("ljmp $0x20,$0\n"); - */ /* Switch Tasks */ - //kprintf("Starting Task: [%i]\n",_current->id); sched_tss->esp0 = _current->kernelStack + 0x2000; - //kprintf("EIP: [0x%X:0x%X:0x%X:0x%X:0x%X:0x%X]\n",_current->iframe->eip,_current->cr3,_current->iframe->cs,&_current->iframe->cs,_current->iframe,_current->kernelStack); - //_current->iframe->gs = 0x69; - kprintf("SS: [0x%X]\n",_current->iframe->ss); - memAddr = (uInt32)(_current->iframe); - //kprintf("memAddr: [0x%X]\n",memAddr); - //while (1); asm volatile( "mov %0,%%eax \n" - "mov %1,%%esp \n" "mov %%eax,%%cr3 \n" - "pop %%gs \n" - "pop %%fs \n" - "pop %%es \n" - "pop %%ds \n" - "pop %%ss \n" - "popa \n" - "iret \n" : - : "a" (_current->cr3), "p" ((uInt32)(_current->iframe)) - ); - kprintf("This should not be seen?\n"); - /* Return */ - return; + : "a" (_current->cr3) + ); + + return (&iframe); } @@ -323,9 +288,12 @@ ************************************************************************/ void sched_yield() { + asm("hlt"); + /* asm("cli"); sched(); asm("sti"); + */ } /* @@ -356,6 +324,9 @@ /*** $Log$ + Revision 1.38 2004/08/21 20:21:20 reddawg + *** empty log message *** + Revision 1.37 2004/08/21 20:06:28 reddawg ok check out exec.c diff --git a/src/sys/kernel/sys_call.S b/src/sys/kernel/sys_call.S index 1f38773..effeb17 100644 --- a/src/sys/kernel/sys_call.S +++ b/src/sys/kernel/sys_call.S @@ -30,7 +30,13 @@ .globl _sysCall,invalidCall .text .code32 -_sysCall: +_sysCall: + pusha /* Save all of the registers */ + push %ss + push %ds + push %es + push %fs + push %gs cmpl totalCalls,%eax jae invalidSysCall pushl %edx @@ -43,7 +49,13 @@ done: popl %ebx popl %ecx - popl %edx + popl %edx /* Restore Registers */ + pop %gs + pop %fs + pop %es + pop %ds + pop %ss + popa /* Restore Registers */ iret invalidCall: @@ -55,9 +67,11 @@ /*** $Log$ + Revision 1.2 2004/07/21 20:55:10 reddawg + fixed invalidSyscall + Revision 1.1 2004/07/21 20:36:55 reddawg New syscall interface END ***/ - diff --git a/src/sys/kernel/timer.S b/src/sys/kernel/timer.S index 2d01bb3..c3386e9 100644 --- a/src/sys/kernel/timer.S +++ b/src/sys/kernel/timer.S @@ -56,7 +56,8 @@ div %ebx test %edx,%edx jnz done - call sched + call sched + mov %eax,%esp done: pop %gs pop %fs @@ -68,6 +69,9 @@ /*** $Log$ + Revision 1.7 2004/08/21 20:06:28 reddawg + ok check out exec.c + Revision 1.6 2004/08/14 11:23:02 reddawg Changes diff --git a/src/sys/mpi/system.c b/src/sys/mpi/system.c index a115194..9ef3067 100644 --- a/src/sys/mpi/system.c +++ b/src/sys/mpi/system.c @@ -71,7 +71,7 @@ mpi_mbox_t *mbox = 0x0; spinLock(&mpiSpinLock); - + kprintf("MPI\n"); if (mpi_findMbox(name) != 0x0) { spinUnlock(&mpiSpinLock); return(-1); @@ -258,6 +258,9 @@ /*** $Log$ + Revision 1.2 2004/08/14 11:23:02 reddawg + Changes + Revision 1.1 2004/07/28 17:07:25 reddawg MPI: moved the syscalls diff --git a/src/sys/sde/sde.cc b/src/sys/sde/sde.cc index 3e58b61..588e9fd 100644 --- a/src/sys/sde/sde.cc +++ b/src/sys/sde/sde.cc @@ -24,6 +24,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. $Log$ + Revision 1.2 2004/05/19 04:07:43 reddawg + kmalloc(size,pid) no more it is no kmalloc(size); the way it should of been + Revision 1.1.1.1 2004/04/15 12:07:17 reddawg UbixOS v1.0 @@ -74,7 +77,7 @@ case drawWindow: tmp->status = drawWindow; while (tmp->status != windowReady) { - sched(); + //sched(); //asm("hlt"); } break;