diff --git a/src/bin/Makefile b/src/bin/Makefile index 457973d..d374f73 100755 --- a/src/bin/Makefile +++ b/src/bin/Makefile @@ -1,10 +1,14 @@ # $Id$ # The System Makefile (C) 2002 The UbixOS Project -all: init-bin +all: init-bin shell-bin init-bin: init (cd init;make) +shell-bin: shell + (cd shell;make) + clean: (cd init;make clean) + (cd shell;make clean) diff --git a/src/bin/init/main.c b/src/bin/init/main.c index d941036..e5bb732 100755 --- a/src/bin/init/main.c +++ b/src/bin/init/main.c @@ -12,6 +12,7 @@ #include #include #include +#include int main(); @@ -30,8 +31,10 @@ printf("Sorry This Program Must Be Started By The Kernel!!!!\n"); exit(1); } + printf("Initializing system.\n"); + exec("shell"); while(1) { - printf("Test"); + printf("."); } exit(1); } \ No newline at end of file diff --git a/src/bin/shell/Makefile b/src/bin/shell/Makefile new file mode 100755 index 0000000..b9361df --- /dev/null +++ b/src/bin/shell/Makefile @@ -0,0 +1,43 @@ +# $Id$ +# Kernel Makefile (C) 2002 The UbixOS Project + + +#Compiler +GCC = gcc +G++ = gcc + +#Linker +LD = ld + +#Kernel File Name +BINARY = shell + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = main.o + +# Link the kernel statically with fixed text+data address @1M +$(BINARY) : $(OBJS) + $(LD) -o $@ ../../lib/libc/stdio/*.o ../../lib/libc/stdlib/*.o ../../lib/libc/sys/*.o $(OBJS) #-Ttext 0x9C0000 + +# Compile the source files +.cc.o: + $(G++) -Wall -fomit-frame-pointer -O -I../../lib/libc/include -c -o $@ $< + +.cc.s: + $(G++) -Wall -fomit-frame-pointer -O -I../../lib/libc/include -S -o $@ $< + +.c.o: + $(GCC) -Wall -O -I../../lib/libc/include -c -o $@ $< + +.c.s: + $(GCC) -Wall -fomit-frame-pointer -O -I../../lib/libc/include -S -o $@ $< + +.S.o: + $(GCC) -Wall -fomit-frame-pointer -c -o $@ $< + +# Clean up the junk +clean: + $(REMOVE) $(OBJS) $(BINARY) diff --git a/src/bin/shell/main.c b/src/bin/shell/main.c new file mode 100755 index 0000000..945511e --- /dev/null +++ b/src/bin/shell/main.c @@ -0,0 +1,24 @@ +/************************************************************************************** + Copyright (c) 2002 The UbixOS Project + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are prohibited. + + $Id$ + +**************************************************************************************/ + +int main(); + +#include + +void _start() { + main(); + } + +int main() { + while (1) { + printf("Fucken A\n"); + } + } \ No newline at end of file diff --git a/src/lib/libc/sys/exec.c b/src/lib/libc/sys/exec.c index fee174d..d25ad0b 100755 --- a/src/lib/libc/sys/exec.c +++ b/src/lib/libc/sys/exec.c @@ -1,2 +1,6 @@ -void exec() { +void exec(char *file) { + asm( + "int %0\n" + : : "i" (0x80),"a" (3),"b" (file) + ); } diff --git a/src/sys/include/ubixos/schedule.h b/src/sys/include/ubixos/schedule.h index 015a924..68a1f49 100755 --- a/src/sys/include/ubixos/schedule.h +++ b/src/sys/include/ubixos/schedule.h @@ -77,6 +77,7 @@ uShort cpuTime; uShort uid; uShort gid; + uLong pageDirectory; }; extern struct taskStruct taskList[numTasks]; diff --git a/src/sys/include/ubixos/syscalls.h b/src/sys/include/ubixos/syscalls.h index 31640c1..5a5bca0 100755 --- a/src/sys/include/ubixos/syscalls.h +++ b/src/sys/include/ubixos/syscalls.h @@ -15,11 +15,12 @@ void sysFwrite(); void sysGetpid(); void sysExit(); +void sysExec(); typedef void (*functionPTR)(); functionPTR systemCalls[] = { - sysFwrite,sysGetpid,sysExit + sysFwrite,sysGetpid,sysExit,sysExec }; int totalCalls = sizeof(systemCalls)/sizeof(functionPTR); diff --git a/src/sys/init/main.c b/src/sys/init/main.c index f30497f..549e9aa 100755 --- a/src/sys/init/main.c +++ b/src/sys/init/main.c @@ -60,6 +60,15 @@ while(1); } +int test() { +// disableIrq(0); +// execFile("shell"); +// enableIrq(0); + while (1) { + kprintf("Kernel Test Thread\n"); + } + } + int main() { clearScreen(); outputVersion(); //Display Version Info @@ -72,7 +81,9 @@ initFloppy(); //Initialize Floppy Controller initUbixFS(); execThread(idleThread,0xBFFF,"Idle Thread"); - execFile("init"); + execThread(test,0xAFFF,"test"); + execFile("shell"); + //execThread(test,0xCFFF,"Test"); /* while(1) { fd = fopen("COPYRIGHT",1); diff --git a/src/sys/kernel/exec.c b/src/sys/kernel/exec.c index 4b6433d..cc53fa1 100755 --- a/src/sys/kernel/exec.c +++ b/src/sys/kernel/exec.c @@ -22,17 +22,21 @@ char *newLoc; elfHeader *binaryHeader = (elfHeader *)0x7C0000; elfProgramheader *programHeader; + kprintf("Test [%s]",file); fd = fopen(file,1); + kprintf("Test2"); for (i=0;feof(fd) == 0;i++) { binarySpace[i] = fgetc(fd); } - programHeader = (elfProgramheader *)0x7C0034;// + binaryHeader->ePhoff; + kprintf("Test4"); + programHeader = (elfProgramheader *)(0x7C0000 + binaryHeader->ePhoff); newLoc = (char *)programHeader->phVaddr; for (x=0;xeEntry; - execThread((void *)eStart,0xAFFF,file); + kprintf("Fuck[%s][%i][%i]",file,eStart,programHeader->phVaddr); + execThread((void *)eStart,eStart-1,file); return(0); } diff --git a/src/sys/kernel/idlethread.c b/src/sys/kernel/idlethread.c index 0e56c56..fb76eeb 100755 --- a/src/sys/kernel/idlethread.c +++ b/src/sys/kernel/idlethread.c @@ -1,4 +1,4 @@ -/************************************************************************************** +/**************\************************************************************************ Copyright (c) 2002 The UbixOS Project @@ -11,6 +11,7 @@ void idleThread() { /* This thread is for maintinance */ while (1) { + kprintf("Testing\n"); //checkTasks(); /* Looks for run away proccesses and kills thems */ } } \ No newline at end of file diff --git a/src/sys/kernel/syscall.c b/src/sys/kernel/syscall.c index 74f63f3..01d673d 100755 --- a/src/sys/kernel/syscall.c +++ b/src/sys/kernel/syscall.c @@ -74,4 +74,16 @@ _current->status = AVAILABLE; schedule(); kprintf("Status: [%i]\n",status); + } + +void sysExec() { + char *file; + asm("":"=b" (file)); + kprintf("File [%s]\n",file); + disableIrq(0); + asm("sti"); + execFile(file); + kprintf("Executed File\n"); +// while(1); + enableIrq(0); } \ No newline at end of file diff --git a/src/sys/ubixfs/file.c b/src/sys/ubixfs/file.c index 52376f0..d7e1ab1 100755 --- a/src/sys/ubixfs/file.c +++ b/src/sys/ubixfs/file.c @@ -33,10 +33,14 @@ int fopen(char *file,int mode) { int i=0; + kprintf("Test-fopen\n"); for (i=0;i