diff --git a/lib/objgfx40/objgfx40.cpp b/lib/objgfx40/objgfx40.cpp index 8eddb5a..3279417 100644 --- a/lib/objgfx40/objgfx40.cpp +++ b/lib/objgfx40/objgfx40.cpp @@ -28,7 +28,7 @@ #include #ifdef __UBIXOS_KERNEL__ -#include +#include #endif const @@ -105,8 +105,7 @@ // #include "../ubixos-home/src/sys/include/ubixos/types.h" -// #define ROUND(f) (int -)((f) + ((f) > 0 ? 0.5 : -0.5)) +// #define ROUND(f) (int)((f) + ((f) > 0 ? 0.5 : -0.5)) struct ogHLine { int32 xStart; diff --git a/sys/Makefile.incl b/sys/Makefile.incl index c370d8d..4191881 100644 --- a/sys/Makefile.incl +++ b/sys/Makefile.incl @@ -8,5 +8,5 @@ KMAKE= ${MAKE} ${KERNEL_FLAGS} INCLUDE=${KERNEL_INC} KERNEL=${KERNEL_NAME} INCLUDES = -I${INCLUDE} -CFLAGS = ${KFLAGS} -m32 -Wall -nostdlib -nostdinc -nostdinc++ -fno-builtin -fno-exceptions -ffreestanding +CFLAGS = ${KFLAGS} -Wall -nostdlib -nostdinc -fno-builtin -fno-exceptions -ffreestanding ROOT=/ubixos diff --git a/sys/fs/ubixfs/ubixfs.c b/sys/fs/ubixfs/ubixfs.c index 56a5ecb..602331c 100644 --- a/sys/fs/ubixfs/ubixfs.c +++ b/sys/fs/ubixfs/ubixfs.c @@ -427,7 +427,7 @@ /* Start our ubixfs_thread to manage the mount point */ /* UBU disable for now - execThread(ubixfs_Thread,(uInt32)(kmalloc(0x2000)+0x2000),0x0); + execThread(ubixfs_Thread,0x2000),0x0); */ kprintf(" Offset: [%i], Partition: [%i]\n", mp->diskLabel->partitions[mp->partition].pOffset,mp->partition); diff --git a/sys/i386/Makefile b/sys/i386/Makefile index 95a8bcb..0ce7291 100644 --- a/sys/i386/Makefile +++ b/sys/i386/Makefile @@ -6,7 +6,7 @@ include ../Makefile.incl # Objects -OBJS = support.o strcpy.o strcmp.o strncmp.o memset.o memcmp.o schedyield.o kpanic.o timer.o spinlock.o i386_exec.o sys_call_posix.o sys_call.o bioscall.o fork.o systemtask.o sched.o cpu.o trap.o +OBJS = support.o strcpy.o strcmp.o strncmp.o memset.o memcmp.o schedyield.o kpanic.o timer.o spinlock.o i386_exec.o sys_call_posix.o sys_call.o bioscall.o fork.o systemtask.o sched.o cpu.o trap.o bios16code.o # ap-boot.o smp.o vitals.o(obsolete) all: $(OBJS) diff --git a/sys/i386/bioscall.c b/sys/i386/bioscall.c index 1e17018..594c6a4 100644 --- a/sys/i386/bioscall.c +++ b/sys/i386/bioscall.c @@ -29,24 +29,16 @@ #include #include #include -#include #include #include #include #include - -asm( - ".globl bios16Code\n" -// ".code16 \n" - "bios16Code: \n" - "int $0x10 \n" - "int $0x69 \n" -// ".code32 \n" -); +#include +#include void biosCall(int biosInt, int eax, int ebx, int ecx, int edx, int esi, int edi, int es, int ds) { short segment = 0x0, offset = 0x0; - uInt32 tmpAddr = (uInt32) &bios16Code; + uint32_t tmpAddr = (uint32_t) &bios16Code; kTask_t *newProcess = 0x0; offset = tmpAddr & 0xF; // lower 4 bits @@ -56,13 +48,13 @@ assert(newProcess); newProcess->tss.back_link = 0x0; - newProcess->tss.esp0 = (uInt32) kmalloc(0x2000) + 0x2000; + newProcess->tss.esp0 = (uint32_t)vmm_getFreeKernelPage(_current->id, 2) + (0x2000 - 0x4); newProcess->tss.ss0 = 0x10; newProcess->tss.esp1 = 0x0; newProcess->tss.ss1 = 0x0; newProcess->tss.esp2 = 0x0; newProcess->tss.ss2 = 0x0; - newProcess->tss.cr3 = (uInt32) _current->tss.cr3; //(uInt32)vmmCreateVirtualSpace(newProcess->id); + newProcess->tss.cr3 = (uint32_t)_current->tss.cr3; //(uInt32)vmmCreateVirtualSpace(newProcess->id); newProcess->tss.eip = offset & 0xFFFF; newProcess->tss.eflags = 2 | EFLAG_IF | EFLAG_VM; newProcess->tss.eax = eax & 0xFFFF; @@ -85,15 +77,15 @@ newProcess->tss.io_map = sizeof(struct tssStruct) - 8192; newProcess->oInfo.v86Task = 0x1; - newProcess->state = READY; + + kprintf("EIP: [0x%X] 0x%X:0x%X", tmpAddr, newProcess->tss.eip, newProcess->tss.cs); + newProcess->state = READY; while (newProcess->state > 0) - ; + asm("nop"); + kprintf("EIP: [0x%X] 0x%X:0x%X!", tmpAddr, newProcess->tss.eip, newProcess->tss.cs); + + kprintf("CALL DONE: %i 0x%X 0x%X!", newProcess->state, newProcess->tss.esp, newProcess->tss.ss); return; } - -/*** - END - ***/ - diff --git a/sys/i386/i386_exec.c b/sys/i386/i386_exec.c index 25b8520..7a16b87 100644 --- a/sys/i386/i386_exec.c +++ b/sys/i386/i386_exec.c @@ -148,13 +148,20 @@ uint32_t execThread(void (*tproc)(void), uint32_t stack, char *arg) { kTask_t * newProcess = 0x0; + uint32_t stackAddr = 0x0; /* Find A New Thread */ newProcess = schedNewTask(); assert(newProcess); + stackAddr = vmm_getFreeKernelPage(newProcess->id, stack / PAGE_SIZE); + + kprintf("stackAddr: 0x%X", stackAddr); + + /* if (stack < 0x100000) kpanic("exec: stack not in valid area: [0x%X]\n", stack); + */ /* Set All The Correct Thread Attributes */ newProcess->tss.back_link = 0x0; @@ -167,7 +174,7 @@ newProcess->tss.cr3 = (unsigned int) kernelPageDirectory; newProcess->tss.eip = (unsigned int) tproc; newProcess->tss.eflags = 0x206; - newProcess->tss.esp = stack; + newProcess->tss.esp = stackAddr + (stack - 0x4); //stack; newProcess->tss.ebp = 0x0;//stack; newProcess->tss.esi = 0x0; newProcess->tss.edi = 0x0; diff --git a/sys/i386/sched.c b/sys/i386/sched.c index d55e857..09eba04 100644 --- a/sys/i386/sched.c +++ b/sys/i386/sched.c @@ -125,8 +125,10 @@ if (_current->state == READY || _current->state == RUNNING) { - if (_current->oInfo.v86Task == 0x1) + if (_current->oInfo.v86Task == 0x1) { irqDisable(0x0); + kprintf("IRQ DISABLED"); + } asm("cli"); diff --git a/sys/i386/systemtask.c b/sys/i386/systemtask.c index 948fcbb..d9d61ed 100644 --- a/sys/i386/systemtask.c +++ b/sys/i386/systemtask.c @@ -81,7 +81,7 @@ case 0x80: if (!strcmp(myMsg.data, "sdeStart")) { kprintf("Starting SDE\n"); - //execThread(sdeThread,(uInt32)(kmalloc(0x2000)+0x2000),0x0); + //execThread(sdeThread,0x2000),0x0); } else if (!strcmp(myMsg.data, "freePage")) { kprintf("kkk Free Pages"); diff --git a/sys/i386/trap.c b/sys/i386/trap.c index bcb4139..82e6b7e 100644 --- a/sys/i386/trap.c +++ b/sys/i386/trap.c @@ -36,6 +36,7 @@ #define KERNEL_STACK 0x2000 +/* #define TRAP_CODE(trap_nr, signr, str, trap_name, tsk) void do_##trap_name(struct trapframe *regs, long error_code) { \ die_if_kernel(str, regs, error_code); \ } @@ -47,12 +48,13 @@ TRAP_CODE(6, SIGILL, "invalid operand", invalid_op, _current) TRAP_CODE(7, SIGSEGV, "device not available", device_not_available, _current) TRAP_CODE(8, SIGSEGV, "double fault", double_fault, _current) -//TRAP_CODE( 9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun, last_task_used_math) +TRAP_CODE( 9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun, last_task_used_math) TRAP_CODE(10, SIGSEGV, "invalid TSS", invalid_TSS, _current) TRAP_CODE(11, SIGBUS, "segment not present", segment_not_present, _current) TRAP_CODE(12, SIGBUS, "stack segment", stack_segment, _current) TRAP_CODE(15, SIGSEGV, "reserved", reserved, _current) TRAP_CODE(17, SIGSEGV, "alignment check", alignment_check, _current) +*/ #define FIRST_TSS_ENTRY 6 #define VM_MASK 0x00020000 @@ -98,23 +100,12 @@ ss = 0x10; } + kprintf("0x%X str", str); kprintf("\n%s: 0x%X:%i, CPU %d, EIP: 0x%X, EFLAGS: 0x%X\n", str, regs->tf_err, regs->tf_trapno, 0x0, regs->tf_eip, regs->tf_eflags); kprintf("eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n", regs->tf_eax, regs->tf_ebx, regs->tf_ecx, regs->tf_edx); kprintf("esi: %08lx edi: %08lx ebp: %08lx esp: %08lx\n", regs->tf_esi, regs->tf_edi, regs->tf_ebp, esp); kprintf("cs: 0x%X ds: 0x%X es: 0x%X fs: 0x%X gs: 0x%X ss: 0x%X\n", regs->tf_cs, regs->tf_ds, regs->tf_es, regs->tf_fs, regs->tf_gs, ss); kprintf("cr0: 0x%X, cr2: 0x%X, cr3: 0x%X, cr4: 0x%X\n", rcr0(), rcr2(), rcr3(), rcr4()); - - /* - struct gdtDescriptor *taskLDT = (struct gdtDescriptor *)(VMM_USER_LDT + sizeof(struct gdtDescriptor)); - uint32_t data_addr = 0x0; - - data_addr += taskLDT->baseLow; - data_addr += taskLDT->baseMed << 16; - data_addr += taskLDT->baseHigh << 24; - - kprintf("LDT: 0x%X", data_addr); - while (1) asm("nop"); - */ store_TR(i); kprintf("Process %s (pid: %i, process nr: %d, stackpage=%08lx)\nStack:", _current->name, _current->id, 0xffff & i, KERNEL_STACK); @@ -138,6 +129,8 @@ cr2 = rcr2(); kprintf("CR2: 0x%X[0x%X]", cr2,_current->tss.ldt); + if (_current->id == 7) + while(1) asm("nop"); if ((frame->tf_eflags & PSL_I) == 0) { if (SEL_GET_PL(frame->tf_cs) == SEL_PL_USER || (frame->tf_eflags & PSL_VM)) { diff --git a/sys/include/sde/sde.h b/sys/include/sde/sde.h index 7827d8a..95d0222 100644 --- a/sys/include/sde/sde.h +++ b/sys/include/sde/sde.h @@ -41,7 +41,7 @@ void sdeThread(); -void sysSDE(uInt32 cmd, void *ptr); +void sysSDE(uint32_t cmd, void *ptr); struct sdeWindows { struct sdeWindows *next; diff --git a/sys/include/vmm/paging.h b/sys/include/vmm/paging.h index 608f68e..6186705 100644 --- a/sys/include/vmm/paging.h +++ b/sys/include/vmm/paging.h @@ -79,7 +79,7 @@ void *vmm_mapFromTask(pidType, void *, uint32_t); void *vmm_copyVirtualSpace(pidType); void *vmm_getFreePage(pidType); -void *vmmGetFreeKernelPage(pidType pid, uint16_t count); +void *vmm_getFreeKernelPage(pidType pid, uint16_t count); void *vmm_createVirtualSpace(pidType); void *vmm_getFreeVirtualPage(pidType, int, int); diff --git a/sys/init/main.c b/sys/init/main.c index b18a840..4dfcee3 100644 --- a/sys/init/main.c +++ b/sys/init/main.c @@ -106,7 +106,6 @@ int kmain(uInt32 rootdev) { /* Set up counter for startup routine */ int i = 0x0; - uInt32 *sysTask = 0x0; /* Do A Clear Screen Just To Make The TEXT Buffer Nice And Empty */ clearScreen(); @@ -142,28 +141,14 @@ kprintf("MemoryMap: [0x%X]\n", vmmMemoryMap); kprintf("Starting OS\n"); - sysTask = kmalloc(0x2000); - - if (sysTask == 0x0) - kprintf("OS: Unable to allocate memory\n"); - else - kprintf("OS Stack: 0x%X\n", sysTask); - - execThread(systemTask, (uint32_t) sysTask + 0x2000, 0x0); + execThread(systemTask, 0x2000, 0x0); kprintf("Thread Start!\n"); //execFile("sys:/bin/init", argv_init, envp_init, 0x0); /* OS Initializer */ //kprintf("File Start!\n"); - sysTask = kmalloc(0x2000); - - if (sysTask == 0x0) - kprintf("OS: Unable to allocate memory\n"); - else - kprintf("SDE Stack: 0x%X\n", sysTask); - - execThread(sdeThread, sysTask + 0x2000,0x0); - kprintf("SDE Thread Start!\n"); + kprintf("SDE Thread Start! [0x%X]\n", &sdeThread); + execThread(&sdeThread, 0x2000,0x0); irqEnable(0x0); diff --git a/sys/kernel/syscall.c b/sys/kernel/syscall.c index ac168ed..0564eba 100644 --- a/sys/kernel/syscall.c +++ b/sys/kernel/syscall.c @@ -231,7 +231,7 @@ for (i = 0; i < 1400; i++) { asm("hlt"); } - //execThread(sdeThread,(uInt32)(kmalloc(0x2000)+0x2000),0x0); + //execThread(sdeThread,0x2000),0x0); for (i = 0; i < 1400; i++) { asm("hlt"); } diff --git a/sys/kernel/ubthread.c b/sys/kernel/ubthread.c index 31449c2..1ec5c3b 100644 --- a/sys/kernel/ubthread.c +++ b/sys/kernel/ubthread.c @@ -81,7 +81,7 @@ } int ubthread_create(kTask_t **thread, const uInt32 *attr, void (*tproc)(void), void *arg) { - *thread = (void *) execThread(tproc, (int) (kmalloc(0x2000) + 0x2000), arg); + *thread = (void *) execThread(tproc,0x2000, arg); return (0x0); } diff --git a/sys/net/net/sys_arch.c b/sys/net/net/sys_arch.c index 3b5c93b..254c2fb 100644 --- a/sys/net/net/sys_arch.c +++ b/sys/net/net/sys_arch.c @@ -401,7 +401,6 @@ thread_param->arg = arg; thread_param->thread = thread; */ - //execThread((void *)function,0x0,0x0); if (ubthread_create(&new_thread->ubthread, 0x0, (void *) (thread), arg) != 0x0) { kpanic("sys_thread_new: ubthread_create"); } diff --git a/sys/sde/Makefile b/sys/sde/Makefile index 33a0de1..d01a088 100644 --- a/sys/sde/Makefile +++ b/sys/sde/Makefile @@ -12,10 +12,10 @@ REMOVE = rm -fr # Objects -OBJS = ogFont.o ogPixelFmt.o ogPixCon.o objgfx40.o ogDisplay_UbixOS.o main.o sde.o +OBJS = objgfx40.o ogFont.o ogPixelFmt.o ogPixCon.o ogDisplay_UbixOS.o sde.o main.o # colours.o -CFLAGS += -fno-rtti +CFLAGS += -fno-rtti -nostdinc++ INCLUDES += -I../../lib/objgfx40 all: diff --git a/sys/sde/main.cc b/sys/sde/main.cc index a456f04..0d91cc5 100644 --- a/sys/sde/main.cc +++ b/sys/sde/main.cc @@ -43,10 +43,14 @@ extern "C" void sdeThread() { ogSurface *screen = new ogDisplay_UbixOS(); + + struct sdeWindows *tmp = 0x0; ogSurface *buf = 0x0; ogBitFont * font = new ogBitFont(); + + font->Load("ROM8X14.DPF", 0); font->SetFGColor(255, 255, 255, 255); font->SetBGColor(0, 0, 0, 255); @@ -55,6 +59,8 @@ screen->ogCreate(800, 600, OG_PIXFMT_16BPP); screen->ogClear(screen->ogPack(122, 140, 163)); + //kprintf("HERE!"); + //while (1) asm("nop"); systemVitals->screen = screen; systemVitals->font = font; diff --git a/sys/sde/ogDisplay_UbixOS.cc b/sys/sde/ogDisplay_UbixOS.cc index 51371f9..1eab764 100755 --- a/sys/sde/ogDisplay_UbixOS.cc +++ b/sys/sde/ogDisplay_UbixOS.cc @@ -62,6 +62,7 @@ VESAInfo = (ogVESAInfo *) 0x11000; modeInfo = (ogModeInfo *) 0x11200; + GetVESAInfo(); return; } // ogDisplay_UbixOS::ogDisplay_UbixOS @@ -78,9 +79,9 @@ VESAInfo->VBESignature[1] = 'B'; VESAInfo->VBESignature[2] = 'E'; VESAInfo->VBESignature[3] = '2'; - //kprintf("Pre-getVESAInfo\n"); + kprintf("Pre-getVESAInfo\n"); biosCall(0x10, 0x4F00, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1100, 0x0); - //kprintf("Post-getVESAInfo\n"); + kprintf("Post-getVESAInfo\n"); return; } // ogDisplay_UbixOS::GetVESAInfo diff --git a/sys/sys/idt.c b/sys/sys/idt.c index 58f0942..24fe98e 100644 --- a/sys/sys/idt.c +++ b/sys/sys/idt.c @@ -75,6 +75,11 @@ : "r" ((char *)&loadidt) ); + /* + for (int i = 0;i < 256;i++) + setVector(intNull, i, dPresent + dTrap + dDpl3); + */ + /* Set up the basic vectors for the reserved ints */ setVector(_int0, 0, dPresent + dInt + dDpl0); setVector(_int1, 1, dPresent + dInt + dDpl0); @@ -194,6 +199,7 @@ ); void __int0(struct trapframe *frame) { +kpanic("BALLS"); die_if_kernel("Divid-by-Zer0", frame, 0); kpanic("int0: Divide-by-Zero [%i]\n", _current->id); endTask(_current->id); @@ -259,15 +265,15 @@ asm( ".globl _int8 \n" - "_int8: \n" -// " pushl $0x8 \n" + "_int8: \n" + " pushl $0x8 \n" " pushal \n" /* Save all registers */ " push %ds \n" " push %es \n" " push %fs \n" " push %gs \n" " push %esp \n" - " call __int8 \n" + " call __int8 \n" " pop %gs \n" " pop %fs \n" " pop %es \n" @@ -446,12 +452,13 @@ break; default: /* something wrong */ kprintf("NonHandled OpCode [0x%X:0x%X]\n", _current->id, ip[0]); +while(1) asm("nop"); _current->state = DEAD; break; } irqEnable(0); while (1) - ; + asm("nop"); } /* Removed static however this is the only place it's called from */ diff --git a/sys/vmm/paging.c b/sys/vmm/paging.c index 0fd8bfd..bc8a910 100644 --- a/sys/vmm/paging.c +++ b/sys/vmm/paging.c @@ -90,7 +90,7 @@ /* MrOlsen (2016-01-15) NOTE: I'm Mappying It For Now Until I Can Figure Out Why FS:0x0 */ for (i = 0x0; i < (PD_ENTRIES / 0x4); i++) { - pageTable[i] = (uint32_t) ((i * 0x1000) | KERNEL_PAGE_DEFAULT); //MrOlsen 2018-01-14 PAGE_DEFAULT + pageTable[i] = (uint32_t) ((i * 0x1000) | PAGE_DEFAULT); //FIXME: This is temp becauseo f bios callKERNEL_PAGE_DEFAULT); //MrOlsen 2018-01-14 PAGE_DEFAULT } /* end for */ /* Allocate a page for the first 4MB of memory */