diff --git a/src/bin/Makefile b/src/bin/Makefile index b657cf1..8b93a9c 100755 --- a/src/bin/Makefile +++ b/src/bin/Makefile @@ -1,7 +1,7 @@ # $Id$ # The System Makefile (C) 2002 The UbixOS Project -all: init-bin login-bin shell-bin test-bin ls-bin pwd-bin +all: init-bin login-bin shell-bin test-bin ls-bin pwd-bin cat-bin ld-dyn-bin init-bin: init (cd init;make) @@ -21,6 +21,12 @@ pwd-bin: pwd (cd pwd;make) +cat-bin: cat + (cd cat;make) + +ld-dyn-bin: ld-dyn + (cd ld-dyn;make) + clean: (cd init;make clean) (cd shell;make clean) @@ -28,3 +34,5 @@ (cd ls;make clean) (cd pwd;make clean) (cd login;make clean) + (cd cat;make clean) + (cd ld-dyn;make clean) diff --git a/src/bin/cat/Makefile b/src/bin/cat/Makefile new file mode 100755 index 0000000..34c2c0a --- /dev/null +++ b/src/bin/cat/Makefile @@ -0,0 +1,53 @@ +# $Id$ +# Application Makefile (C) 2002 The UbixOS Project + + +#Compiler +GCC = gcc +G++ = gcc + +#Compiler Flags +CFLAGS = -I../../lib/libc/include -fno-builtin + +#Linker +LD = ld + +#Binary File Name +BINARY = cat + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = main.o + +#Libraries +LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o ../../lib/libc/generic/*.o + +#Startup File +STARTUP = ../../lib/ubix/startup.o + +# Link The Binary +$(BINARY) : $(OBJS) + $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS) +# ld -o $@ $(STARTUP) ../../lib/libc/libc.so $(OBJS) + +# Compile the source files +.cc.o: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $< + +.cc.s: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.c.o: + $(GCC) -Wall -O $(CFLAGS) -c -o $@ $< + +.c.s: + $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.S.o: + $(GCC) -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean Up The junk +clean: + $(REMOVE) $(OBJS) $(BINARY) diff --git a/src/bin/cat/main.c b/src/bin/cat/main.c new file mode 100755 index 0000000..9eae776 --- /dev/null +++ b/src/bin/cat/main.c @@ -0,0 +1,40 @@ +/************************************************************************************** + 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 + +int main(int argc,char **argv) { + int i = 0x0; + FILE *fd; + fd = fopen("userdb","r"); + for (i=0;i #include -int main() { +int main(int argc,char **argv) { int i=0; i = getpid(); if (getpid() != 1) { diff --git a/src/bin/ld-dyn/Makefile b/src/bin/ld-dyn/Makefile new file mode 100755 index 0000000..cc11e01 --- /dev/null +++ b/src/bin/ld-dyn/Makefile @@ -0,0 +1,52 @@ +# $Id$ +# Application Makefile (C) 2002 The UbixOS Project + + +#Compiler +GCC = gcc +G++ = gcc + +#Compiler Flags +CFLAGS = -I../../lib/libc/include -fno-builtin + +#Linker +LD = ld + +#Binary File Name +BINARY = ld-dyn + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = main.o + +#Libraries +LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o ../../lib/libc/generic/*.o + +#Startup File +STARTUP = ../../lib/ubix/startup.o + +# Link The Binary +$(BINARY) : $(OBJS) + $(GCC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS) + +# Compile the source files +.cc.o: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -c -o $@ $< + +.cc.s: + $(G++) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.c.o: + $(GCC) -Wall -O $(CFLAGS) -c -o $@ $< + +.c.s: + $(GCC) -Wall -fomit-frame-pointer -O $(CFLAGS) -S -o $@ $< + +.S.o: + $(GCC) -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean Up The junk +clean: + $(REMOVE) $(OBJS) $(BINARY) diff --git a/src/bin/ld-dyn/main.c b/src/bin/ld-dyn/main.c new file mode 100755 index 0000000..a7ac8ff --- /dev/null +++ b/src/bin/ld-dyn/main.c @@ -0,0 +1,37 @@ +/************************************************************************************** + 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 +//#include "../../sys/include/ubixos/elf.h" + +int main(int argc,char *argv) { + /* + elfHeader *eHeader = 0x0; + elfProgramheader *ePheader = 0x0; + elfSectionheader *eSheader = 0x0; + elfPltInfo *pltInfo = 0x0; + elfDynsym *dynSym = 0x0; + */ + } diff --git a/src/bin/shell/Makefile b/src/bin/shell/Makefile index 9bb73ec..fd4cc06 100755 --- a/src/bin/shell/Makefile +++ b/src/bin/shell/Makefile @@ -19,7 +19,7 @@ REMOVE = rm -f #Objects -OBJS = main.o +OBJS = main.o error.o commands.o exec.o input.o #Libraries LIBRARIES = ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o ../../lib/libc/string/*.o diff --git a/src/bin/shell/commands.c b/src/bin/shell/commands.c new file mode 100755 index 0000000..544acec --- /dev/null +++ b/src/bin/shell/commands.c @@ -0,0 +1,72 @@ +/************************************************************************************** + 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 +#include +#include +#include "shell.h" + +int commands(inputBuffer *data) { + int cPid = 0x0; + printf("Test: [%s]\n",data->argv[0]); + if (0 == memcmp(data->argv[0], "uname", 5)) { + printf("UbixOS v0.01a " __DATE__" " __TIME__ " \n"); + return(1); + } + else if (0 == memcmp(data->argv[0], "exit", 4)) { + exit(1); + } + else if (0 == memcmp(data->argv[0], "mypid", 5)) { + printf("My Pid: [%i]\n",getpid()); + return(1); + } + else if (memcmp(data->argv[0],"stress", 6) == 0) { + while (1) { + cPid = fork(); + printf("Pid: [%i]\n",cPid); + if (!cPid) { + exec("test"); + exit(1); + } + else { + while (pidStatus(cPid)); + } + + } + } + else if (memcmp(data->argv[0],"echo",4) == 0) { + printf("%s",data->argv[1]); + } + else if (memcmp(data->argv[0],"about",5) == 0) { + printf("UbixOS Shell v0.99 (C) 2002\n"); + printf("Base Command Line Interface\n"); + //printf("UbixOS Shell v0.99 (C) 2002\n"); + //printf("Base Command Line Interface\n"); + } + else { + return(0); + } + return(1); + } \ No newline at end of file diff --git a/src/bin/shell/error.c b/src/bin/shell/error.c new file mode 100755 index 0000000..a0a074d --- /dev/null +++ b/src/bin/shell/error.c @@ -0,0 +1,29 @@ +/************************************************************************************** + 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 + +void error(int errorCode,char *errorMsg) { + printf("ERROR: #%i Message: %s\n"); + exit(errorCode); + } \ No newline at end of file diff --git a/src/bin/shell/exec.c b/src/bin/shell/exec.c new file mode 100755 index 0000000..97c4978 --- /dev/null +++ b/src/bin/shell/exec.c @@ -0,0 +1,38 @@ +/************************************************************************************** + 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 + +void execProgram(char *program,int argc,char **argv) { + int cPid = 0x0; + cPid = fork(); + if (!cPid) { + if (exec(program) == 0) { + printf("%s: Command Not Found.\n",program); + } + exit(1); + } + else { + while (pidStatus(cPid)); + } + } \ No newline at end of file diff --git a/src/bin/shell/input.c b/src/bin/shell/input.c new file mode 100755 index 0000000..1aa5d9c --- /dev/null +++ b/src/bin/shell/input.c @@ -0,0 +1,40 @@ +/************************************************************************************** + 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 "shell.h" + +void parseInput(inputBuffer *buffer,char *data) { + char *tmp = 0x0; + while (data[0] == ' ') { + data++; + } + for (tmp = data;*tmp > 0;tmp++) { + if (*tmp == ' ') { + *tmp = '\0'; + buffer->argc++; + } + } + buffer->argv = &data; + printf("Data: %s\n",data); + } \ No newline at end of file diff --git a/src/bin/shell/main.c b/src/bin/shell/main.c index 856dc63..44abadf 100755 --- a/src/bin/shell/main.c +++ b/src/bin/shell/main.c @@ -26,47 +26,23 @@ #include #include #include +#include "shell.h" int main() { - unsigned char buffer[256],*tmp; - int cPid = 0; + unsigned char buffer[256],*data; + int x = 0x0; + inputBuffer *inBuf = (inputBuffer *)malloc(sizeof(inputBuffer)); while (1) { printf("UbixOS: "); gets((char *)&buffer); - tmp = (uChar *)&buffer; - while (tmp[0] == ' ') { - tmp++; + data = (uChar *)&buffer; + parseInput(inBuf,data); + while (data[0] == ' ') { + data++; } - if (0 == memcmp(tmp, "uname", 5)) - printf("UbixOS v0.01a " __DATE__" " __TIME__ " \n"); - else if (0 == memcmp(tmp, "exit", 4)) - exit(1); - else if (0 == memcmp(tmp, "mypid", 5)) - printf("My Pid: [%i]\n",getpid()); - else if (memcmp(tmp,"stress", 6) == 0) { - while (1) { - cPid = fork(); - printf("Pid: [%i]\n",cPid); - if (!cPid) { - exec("test"); - exit(1); - } - else { - while (pidStatus(cPid)); - } - } - } - else if (*tmp > 0) { - cPid = fork(); - if (!cPid) { - if (exec(tmp) == 0) { - printf("%s: Command Not Found.\n",tmp); - } - exit(1); - } - else { - while (pidStatus(cPid)); - } + if (*data > 0) { + if (!commands(inBuf)) execProgram(data,0x0,0x0); } } + exit(0); } \ No newline at end of file diff --git a/src/bin/shell/shell.h b/src/bin/shell/shell.h new file mode 100755 index 0000000..1b52bea --- /dev/null +++ b/src/bin/shell/shell.h @@ -0,0 +1,4 @@ +typedef struct { + int argc; + char **argv; + } inputBuffer; \ No newline at end of file diff --git a/src/lib/ubix/startup.c b/src/lib/ubix/startup.c index 6952908..da23166 100755 --- a/src/lib/ubix/startup.c +++ b/src/lib/ubix/startup.c @@ -25,6 +25,10 @@ extern int main(); -void _start() { - exit(main()); +void _start(char *args, ...) { + int argc = 0x1; + char **argv = 0x0; + argv = &args; + //argc = * (int *) (argv); + exit(main(argc,argv)); } \ No newline at end of file diff --git a/src/sys/include/ubixos/elf.h b/src/sys/include/ubixos/elf.h index d990d1d..fc51d71 100755 --- a/src/sys/include/ubixos/elf.h +++ b/src/sys/include/ubixos/elf.h @@ -26,6 +26,9 @@ #include +#define elfExecutable 0x002 +#define elfLibrary 0x003 + typedef struct { uChar eIdent[16]; /* File identification. */ uShort eType; /* File type. */ @@ -67,4 +70,17 @@ uLong shEntsize; /* Size of each entry in section. */ } elfSectionheader; +typedef struct { + uLong pltOffset; + uLong pltInfo; + } elfPltInfo; + +typedef struct { + uLong dynName; + uLong dynValue; + uLong dynSize; + uLong dynInfo; + } elfDynsym; + + #endif \ No newline at end of file diff --git a/src/sys/kernel/idt.c b/src/sys/kernel/idt.c index e867c33..33722c4 100755 --- a/src/sys/kernel/idt.c +++ b/src/sys/kernel/idt.c @@ -74,35 +74,69 @@ /* Null Intterupt Descriptor */ void intNull() { kprintf("Woot Invalid Interrupt\n"); + /* + freeProcessPages(_current->id); + _current->status = EMPTY; + schedule(); + */ while(1); } void _int0() { kprint("int0: Divide-by-Zero\n"); + /* + freeProcessPages(_current->id); + _current->status = EMPTY; + schedule(); + */ while(1); } void _int1() { kprint("int1: Debug exception\n"); + freeProcessPages(_current->id); + _current->status = EMPTY; + schedule(); while(1); } void _int2() { kprint("int2: unknown error\n"); + /* + freeProcessPages(_current->id); + _current->status = EMPTY; + schedule(); + */ while(1); } void _int3() { kprint("int3: Breakpoint\n"); + /* + freeProcessPages(_current->id); + _current->status = EMPTY; + schedule(); + */ while(1); } void _int4() { kprint("int4: Overflow\n"); + /* + freeProcessPages(_current->id); + _current->status = EMPTY; + schedule(); + */ while(1); } void _int5() { kprint("int5: Bounds check\n"); + /* + freeProcessPages(_current->id); + _current->status = EMPTY; + schedule(); + */ while(1); } void _int6() { kprintf("int6: Invalid opcode!\n"); - _current->status = EXITING; + freeProcessPages(_current->id); + _current->status = EMPTY; schedule(); while(1); } diff --git a/src/sys/kernel/syscall.c b/src/sys/kernel/syscall.c index cbb118a..3afd2cc 100755 --- a/src/sys/kernel/syscall.c +++ b/src/sys/kernel/syscall.c @@ -43,7 +43,7 @@ ); void invalidCall() { - kprintf("Invalid System Call!!\n"); + kprintf("Invalid Sys Call!\n"); //_current->status = AVAILABLE; //schedule(); } @@ -114,18 +114,23 @@ programHeader = (elfProgramheader *)(0x7C0000 + binaryHeader->ePhoff); //Loop Through The Header And Load Sections Which Need To Be Loaded for (i=0;iePhnum;i++) { - newLoc = (char *)programHeader[i].phVaddr; - /* - Allocate Memory Im Going To Have To Make This Load Memory With Corrent - Settings so it helps us in the future - */ - for (x=0;x<=((programHeader[i].phMemsz & 0xFFFFF000)+4095);x+=4096) { - remapPage(findFreePage(_current->id),((programHeader[i].phVaddr & 0xFFFFF000) + (0x1000 * x))); - _current->vmStart = ((programHeader[i].phVaddr & 0xFFFFF000) + (0x1000 * x) + 0x1000); + if (programHeader[i].phType == 1) { + newLoc = (char *)programHeader[i].phVaddr; + /* + Allocate Memory Im Going To Have To Make This Load Memory With Corrent + Settings so it helps us in the future + */ + for (x=0;x<=((programHeader[i].phMemsz & 0xFFFFF000)+4095);x+=4096) { + remapPage(findFreePage(_current->id),((programHeader[i].phVaddr & 0xFFFFF000) + (0x1000 * x))); + _current->vmStart = ((programHeader[i].phVaddr & 0xFFFFF000) + (0x1000 * x) + 0x1000); + } + //Now Copy The Binary To Its Correct Location + for (x=0;xsize+4095)/4096);i++) { unmapPage((0x7C0000 + (0x1000 * i)),0); } + //Set Up Args + //Jump To Start Of New Binary asm( - "jmp *%0\n" + "pushl %0\n" + "jmp *%1\n" : - : "g" (eStart) + : "g" (file), "g" (eStart) ); } diff --git a/src/tools/Makefile b/src/tools/Makefile index 182f24f..89de6e3 100755 --- a/src/tools/Makefile +++ b/src/tools/Makefile @@ -49,10 +49,12 @@ (cp ../bin/ls/ls ./) (cp ../bin/pwd/pwd ./) (cp ../bin/login/login ./) - (./format 257 2000 init shell test ls pwd userdb login) + (cp ../bin/cat/cat ./) + (./format 257 2000 init shell test ls pwd userdb login cat) (rm init) (rm shell) (rm test) (rm ls) (rm pwd) + (rm cat) (rm login) diff --git a/ubixos.kdevprj b/ubixos.kdevprj index 24ecae6..c617797 100755 --- a/ubixos.kdevprj +++ b/ubixos.kdevprj @@ -44,7 +44,7 @@ kdevprj_version=1.3 lfv_open_groups=Others make_options=\s-j1 clean all install -makefiles=./Makefile.am,src/Makefile.am,src/sys/Makefile.am,src/sys/include/Makefile.am,src/lib/Makefile.am,src/lib/libc/Makefile.am,src/lib/libc/include/Makefile.am,src/bin/Makefile.am,src/bin/shell/Makefile.am,Makefile.am,src/sys/boot/Makefile.am,src/sys/init/Makefile.am,src/sys/include/ubixos/Makefile.am,src/sys/drivers/Makefile.am,src/sys/kernel/Makefile.am,src/sys/compile/Makefile.am,src/sys/include/version/Makefile.am,src/sys/include/drivers/Makefile.am,src/sys/vmm/Makefile.am,src/sys/include/vmm/Makefile.am,src/sys/include/ubixfs/Makefile.am,src/sys/ubixfs/Makefile.am,src/tools/Makefile.am,src/bin/init/Makefile.am,src/lib/libc/stdio/Makefile.am,src/lib/libc/include/sys/Makefile.am,src/lib/libc/sys/Makefile.am,src/lib/libc/stdlib/Makefile.am,src/bin/test/Makefile.am,src/lib/ubix/Makefile.am,src/bin/ls/Makefile.am,src/bin/pwd/Makefile.am,src/lib/libc/generic/Makefile.am,src/bin/login/Makefile.am +makefiles=./Makefile.am,src/Makefile.am,src/sys/Makefile.am,src/sys/include/Makefile.am,src/lib/Makefile.am,src/lib/libc/Makefile.am,src/lib/libc/include/Makefile.am,src/bin/Makefile.am,src/bin/shell/Makefile.am,Makefile.am,src/sys/boot/Makefile.am,src/sys/init/Makefile.am,src/sys/include/ubixos/Makefile.am,src/sys/drivers/Makefile.am,src/sys/kernel/Makefile.am,src/sys/compile/Makefile.am,src/sys/include/version/Makefile.am,src/sys/include/drivers/Makefile.am,src/sys/vmm/Makefile.am,src/sys/include/vmm/Makefile.am,src/sys/include/ubixfs/Makefile.am,src/sys/ubixfs/Makefile.am,src/tools/Makefile.am,src/bin/init/Makefile.am,src/lib/libc/stdio/Makefile.am,src/lib/libc/include/sys/Makefile.am,src/lib/libc/sys/Makefile.am,src/lib/libc/stdlib/Makefile.am,src/bin/test/Makefile.am,src/lib/ubix/Makefile.am,src/bin/ls/Makefile.am,src/bin/pwd/Makefile.am,src/lib/libc/generic/Makefile.am,src/bin/login/Makefile.am,src/bin/cat/Makefile.am,src/bin/ld-dyn/Makefile.am modifyMakefiles=true project_name=UbixOS project_type=normal_empty @@ -105,9 +105,28 @@ [src/bin/Makefile.am] files=src/bin/Makefile -sub_dirs=shell,init,test,ls,pwd,login +sub_dirs=shell,init,test,ls,pwd,login,cat,ld-dyn type=normal +[src/bin/cat/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/bin/cat/Makefile.am] +files=src/bin/cat/main.c,src/bin/cat/Makefile +sharedlib_LDFLAGS=-version-info 0:0:0 +sharedlib_rootname=cat +sub_dirs= +type=static_library + +[src/bin/cat/main.c] +dist=true +install=false +install_location= +type=SOURCE + [src/bin/init/Makefile] dist=true install=false @@ -125,6 +144,25 @@ install_location= type=SOURCE +[src/bin/ld-dyn/Makefile] +dist=true +install=false +install_location= +type=DATA + +[src/bin/ld-dyn/Makefile.am] +files=src/bin/ld-dyn/main.c,src/bin/ld-dyn/Makefile +sharedlib_LDFLAGS=-version-info 0:0:0 +sharedlib_rootname=ld-dyn +sub_dirs= +type=static_library + +[src/bin/ld-dyn/main.c] +dist=true +install=false +install_location= +type=SOURCE + [src/bin/login/Makefile] dist=true install=false @@ -187,16 +225,46 @@ type=DATA [src/bin/shell/Makefile.am] -files=src/bin/shell/main.c,src/bin/shell/Makefile +files=src/bin/shell/main.c,src/bin/shell/Makefile,src/bin/shell/error.c,src/bin/shell/commands.c,src/bin/shell/exec.c,src/bin/shell/input.c,src/bin/shell/shell.h sub_dirs= type=static_library +[src/bin/shell/commands.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/bin/shell/error.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/bin/shell/exec.c] +dist=true +install=false +install_location= +type=SOURCE + +[src/bin/shell/input.c] +dist=true +install=false +install_location= +type=SOURCE + [src/bin/shell/main.c] dist=true install=false install_location= type=SOURCE +[src/bin/shell/shell.h] +dist=true +install=false +install_location= +type=HEADER + [src/bin/test/Makefile] dist=true install=false @@ -461,8 +529,14 @@ install_location= type=SOURCE +[src/lib/ubix/Makefile] +dist=true +install=false +install_location= +type=DATA + [src/lib/ubix/Makefile.am] -files=src/lib/ubix/startup.c +files=src/lib/ubix/startup.c,src/lib/ubix/Makefile sharedlib_LDFLAGS=-version-info 0:0:0 sharedlib_rootname=ubix sub_dirs=