diff --git a/src/sys/Makefile.inc b/src/sys/Makefile.inc index da3bc26..4239ab7 100644 --- a/src/sys/Makefile.inc +++ b/src/sys/Makefile.inc @@ -2,5 +2,5 @@ # global 'sys' options INCLUDES = -I../include -CFLAGS = -Wall -nostdlib -fno-builtin -fomit-frame-pointer -fno-exceptions -O +CFLAGS = -Wall -nostdlib -nostdinc -fno-builtin -fomit-frame-pointer -fno-exceptions -O KERNEL = ubix.elf diff --git a/src/sys/include/assert.h b/src/sys/include/assert.h new file mode 100644 index 0000000..e6c3f51 --- /dev/null +++ b/src/sys/include/assert.h @@ -0,0 +1,70 @@ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. + * + * @(#)assert.h 8.2 (Berkeley) 1/21/94 + * $FreeBSD: src/include/assert.h,v 1.4 2002/03/23 17:24:53 imp Exp $ + */ + +#if defined(__cplusplus) +#define __BEGIN_DECLS extern "C" { +#define __END_DECLS } +#else +#define __BEGIN_DECLS +#define __END_DECLS +#endif + +/* + * Unlike other ANSI header files, may usefully be included + * multiple times, with and without NDEBUG defined. + */ + +#undef assert +#undef _assert + +#ifdef NDEBUG +#define assert(e) ((void)0) +#define _assert(e) ((void)0) +#else +#define _assert(e) assert(e) + +#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \ + __LINE__, #e)) +#endif /* NDEBUG */ + +__BEGIN_DECLS +void __assert(const char *, const char *, int, const char *); +__END_DECLS diff --git a/src/sys/kernel/exec.c b/src/sys/kernel/exec.c index 5dd8ea4..10e655e 100644 --- a/src/sys/kernel/exec.c +++ b/src/sys/kernel/exec.c @@ -128,7 +128,6 @@ int x = 0x0; uInt32 eStart = 0x0; char *newLoc = 0x0; - char *linker = 0x0; fileDescriptor *tmpFd = 0x0; elfHeader *binaryHeader = 0x0; @@ -137,8 +136,8 @@ /* Get A New Task For This Proccess */ _current = schedNewTask(); assert(_current); - _current->gid = 0; - _current->uid = 0; + _current->gid = 0x0; + _current->uid = 0x0; /* Now We Must Create A Virtual Space For This Proccess To Run In */ _current->tss.cr3 = (uInt32)vmmCreateVirtualSpace(_current->id); @@ -154,12 +153,12 @@ tmpFd = fopen(file,"r"); /* If We Dont Find the File Return */ - if (!tmpFd) { + if (tmpFd == 0x0) { // kprintf("Exec Format Error: Binary File Not Executable.\n"); fclose(tmpFd); return; } - if (tmpFd->perms == 0) { + if (tmpFd->perms == 0x0) { //kprintf("Exec Format Error: Binary File Not Executable.\n"); fclose(tmpFd); return; @@ -169,7 +168,6 @@ binaryHeader = (elfHeader *)kmalloc(sizeof(elfHeader)); fread(binaryHeader,sizeof(elfHeader),1,tmpFd); - /* Check If App Is A Real Application */ if ((binaryHeader->eIdent[1] != 'E') && (binaryHeader->eIdent[2] != 'L') && (binaryHeader->eIdent[3] != 'F')) { //kprintf("Exec Format Error: Binary File Not Executable.\n"); @@ -224,6 +222,8 @@ /* Now Lets Make A Clean Stack */ newLoc = (char *)0x5DB000; + i = 0x5DD000; + vmmRemapPage(vmmFindFreePage(_current->id),0x5DC000); vmmSetPageAttribute(0x5DC000,(pageDefault | pageStack)); vmmRemapPage(vmmFindFreePage(_current->id),0x5DB000); @@ -232,9 +232,6 @@ vmmSetPageAttribute(0x5DA000,(pageDefault | pageStack)); vmmRemapPage(vmmFindFreePage(_current->id),0x5D9000); vmmSetPageAttribute(0x5D9000,(pageDefault | pageStack)); - - i = 0x5DD000; - vmmRemapPage(vmmFindFreePage(_current->id),0x5D3000); vmmSetPageAttribute(0x5D3000,(pageDefault | pageStack)); vmmRemapPage(vmmFindFreePage(_current->id),0x5D2000); @@ -273,29 +270,6 @@ sched_setStatus(_current->id,READY); - /* Set up the defaault stack to be used by this new process */ - - /* - asm volatile( - "pusha \n" - "movl %%esp,%%edx \n" - "movl %2,%%ecx \n" - "movl %%ecx,%%esp \n" - "pushl $0x0 \n" - "pushl $0x0 \n" - "pushl $0x0 \n" - "pushl $0x0 \n" - "pushl %%ebx \n" - "pushl %%eax \n" - "movl %%esp,%%ecx \n" - "movl %%ecx,%2 \n" - "movl %%edx,%%esp \n" - "popa \n" - : - : "a" (argc), "b" (argv), "m" (_current->tss.esp) - ); - */ - kfree(binaryHeader); kfree(programHeader); fclose(tmpFd); @@ -442,6 +416,9 @@ /*** $Log$ + Revision 1.43 2004/07/20 21:35:09 reddawg + Let me commit before we start to overlap + Revision 1.42 2004/07/18 05:24:15 reddawg Fixens diff --git a/src/sys/kernel/fork.c b/src/sys/kernel/fork.c index c399cf3..ce5f114 100644 --- a/src/sys/kernel/fork.c +++ b/src/sys/kernel/fork.c @@ -32,6 +32,7 @@ #include #include #include +#include #include /************************************************************************ @@ -108,6 +109,9 @@ /*** $Log$ + Revision 1.11 2004/07/19 01:56:01 reddawg + fork: no mem leaks here + Revision 1.10 2004/07/18 05:24:15 reddawg Fixens diff --git a/src/sys/kernel/ld.c b/src/sys/kernel/ld.c index 81d2f0c..844cfab 100644 --- a/src/sys/kernel/ld.c +++ b/src/sys/kernel/ld.c @@ -90,7 +90,7 @@ */ for (x=0;x < ((programHeader[i].phMemsz)+4095);x += 0x1000) { vmmRemapPage(vmmFindFreePage(_current->id),((programHeader[i].phVaddr & 0xFFFFF000) + x + LD_START)); - memset(((programHeader[i].phVaddr & 0xFFFFF000) + x + LD_START),0x0,0x1000); + memset((uInt32)((programHeader[i].phVaddr & 0xFFFFF000) + x + LD_START),0x0,0x1000); } /* Now Load Section To Memory */ fseek(ldFd,programHeader[i].phOffset,0x0); @@ -161,6 +161,9 @@ /*** $Log$ + Revision 1.28 2004/07/17 03:10:18 reddawg + Added asserts no problems thusfar + Revision 1.27 2004/06/28 23:12:58 reddawg file format now container:/path/to/file diff --git a/src/sys/kernel/systemtask.c b/src/sys/kernel/systemtask.c index c94340b..ba781a4 100644 --- a/src/sys/kernel/systemtask.c +++ b/src/sys/kernel/systemtask.c @@ -84,13 +84,16 @@ break; } } - asm("hlt"); + schedYield(); } return; } /*** $Log$ + Revision 1.6 2004/06/29 11:27:30 reddawg + sdeStop - Turn printf off until modes have changed + Revision 1.5 2004/06/29 11:23:22 reddawg sdeStop - Does this patch help? diff --git a/src/sys/lib/Makefile b/src/sys/lib/Makefile index de49a9f..0f6f061 100644 --- a/src/sys/lib/Makefile +++ b/src/sys/lib/Makefile @@ -8,7 +8,7 @@ INCLUDES += -I../../lib/objgfx40/ # Objects -OBJS = ogprintf.o sqrt.o atan.o divdi3.o libcpp.o strtok.o kmalloc.o kprintf.o vsprintf.o string.o net.o strtol.o +OBJS = assert.o ogprintf.o sqrt.o atan.o divdi3.o libcpp.o strtok.o kmalloc.o kprintf.o vsprintf.o string.o net.o strtol.o all: $(OBJS) diff --git a/src/sys/lib/assert.c b/src/sys/lib/assert.c new file mode 100644 index 0000000..ce59502 --- /dev/null +++ b/src/sys/lib/assert.c @@ -0,0 +1,50 @@ +/***************************************************************************************** + Copyright (c) 2002 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 + +void __assert(const char *func,const char *file,int line,const char *failedexpr) { + if (func == NULL) + (void)kprintf( + "Assertion failed: (%s), file %s, line %d.\n", failedexpr, + file, line); + else + (void)kprintf( + "Assertion failed: (%s), function %s, file %s, line %d.\n", + failedexpr, func, file, line); + kpanic("Asserted\n"); + } + +/*** + $Log$ + END + ***/ + diff --git a/src/sys/lib/kmalloc.c b/src/sys/lib/kmalloc.c index 92cc2ab..69fc327 100644 --- a/src/sys/lib/kmalloc.c +++ b/src/sys/lib/kmalloc.c @@ -31,8 +31,9 @@ #include #include #include -#include #include +#include +#include #include static struct memDescriptor *kernDesc = 0x0; @@ -335,6 +336,9 @@ /*** $Log$ + Revision 1.12 2004/07/20 18:58:24 reddawg + Few fixes + Revision 1.11 2004/07/18 05:24:15 reddawg Fixens diff --git a/src/sys/lib/kprintf.c b/src/sys/lib/kprintf.c index 46b4877..eb4f339 100644 --- a/src/sys/lib/kprintf.c +++ b/src/sys/lib/kprintf.c @@ -53,18 +53,6 @@ return(i); } -int __eprintf(const char *fmt, ...) { - char buf[1024]; - vaList args; - int i = 0x0; - vaStart(args, fmt); - i=vsprintf(buf,fmt,args); - vaEnd(args); - kpanic(buf); - return(i); - } - - int vPrintf(const char *fmt, ...) { vaList args; int i; @@ -88,6 +76,9 @@ /*** $Log$ + Revision 1.4 2004/07/18 03:01:44 reddawg + Few changes to spinlock hopefully it will cure our deadlock + Revision 1.3 2004/07/17 02:45:55 reddawg Modified assert it now invokes kPanic it is very nifty diff --git a/src/sys/vmm/copyvirtualspace.c b/src/sys/vmm/copyvirtualspace.c index 47070b3..2c84d7a 100644 --- a/src/sys/vmm/copyvirtualspace.c +++ b/src/sys/vmm/copyvirtualspace.c @@ -51,7 +51,7 @@ uInt32 *parentPageDirectory = 0x0, *newPageDirectory = 0x0; uInt32 *parentPageTable = 0x0, *newPageTable = 0x0; uInt32 *parentStackPage = 0x0, *newStackPage = 0x0; - int x = 0, i = 0, s = 0; + uInt16 x = 0, i = 0, s = 0; /* Set Address Of Parent Page Directory */ parentPageDirectory = (uInt32 *) parentPageDirAddr; @@ -182,6 +182,9 @@ /*** $Log$ + Revision 1.3 2004/07/19 01:58:12 reddawg + vmmCopyVirtualSpace: cleaned up one full page memory leak we were still using old sysID over pid + Revision 1.2 2004/06/15 12:35:05 reddawg Cleaned Up diff --git a/src/sys/vmm/getfreepage.c b/src/sys/vmm/getfreepage.c index 90d303c..6b66d4c 100644 --- a/src/sys/vmm/getfreepage.c +++ b/src/sys/vmm/getfreepage.c @@ -23,12 +23,6 @@ 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. - $Log$ - Revision 1.6 2004/04/13 16:36:34 reddawg - Changed our copyright, it is all now under a BSD-Style license - - - $Id$ *****************************************************************************************/ @@ -49,7 +43,7 @@ void * vmmGetFreePage(pidType pid) { - int x = 0x0, y = 0x0; + uInt16 x = 0x0, y = 0x0; uInt32 *pageTableSrc = 0x0; /* Lets Search For A Free Page */ @@ -74,6 +68,12 @@ } /*** + $Log$ + Revision 1.1.1.1 2004/04/15 12:06:51 reddawg + UbixOS v1.0 + + Revision 1.6 2004/04/13 16:36:34 reddawg + Changed our copyright, it is all now under a BSD-Style license + END ***/ - diff --git a/src/sys/vmm/setpageattributes.c b/src/sys/vmm/setpageattributes.c index a8607aa..705a3aa 100644 --- a/src/sys/vmm/setpageattributes.c +++ b/src/sys/vmm/setpageattributes.c @@ -23,15 +23,6 @@ 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. - $Log$ - Revision 1.1.1.1 2004/04/15 12:06:53 reddawg - UbixOS v1.0 - - Revision 1.6 2004/04/13 16:36:34 reddawg - Changed our copyright, it is all now under a BSD-Style license - - - $Id$ *****************************************************************************************/ @@ -49,15 +40,15 @@ void vmmSetPageAttribute(uInt32 pageAddr, int attributes) { - int directoryIndex, tableIndex; + uInt16 directoryIndex, tableIndex; uInt32 *pageTable; /* Get Index To Page Directory */ - directoryIndex = (pageAddr / (1024 * 4096)); + directoryIndex = (pageAddr / (1024 * 0x1000)); /* Get Index To Page Table */ - tableIndex = ((pageAddr - (directoryIndex * (1024 * 4096))) / 4096); + tableIndex = ((pageAddr - (directoryIndex * (1024 * 0x1000))) / 0x1000); /* Set Table Pointer */ - pageTable = (uInt32 *) (tablesBaseAddress + (4096 * directoryIndex)); + pageTable = (uInt32 *) (tablesBaseAddress + (0x1000 * directoryIndex)); /* Set Attribute If Page Is Mapped */ if (pageTable[tableIndex] != 0) { pageTable[tableIndex] = ((pageTable[tableIndex] & 0xFFFFF000) | attributes); @@ -72,6 +63,16 @@ } /*** + $Log$ + Revision 1.2 2004/06/10 22:23:56 reddawg + Volatiles + + Revision 1.1.1.1 2004/04/15 12:06:53 reddawg + UbixOS v1.0 + + Revision 1.6 2004/04/13 16:36:34 reddawg + Changed our copyright, it is all now under a BSD-Style license + END ***/