diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | interface/crt0.s | 50 | ||||
| -rw-r--r-- | kernel/syscalls.c | 4 | ||||
| -rw-r--r-- | userspace/cpp/Makefile | 13 | ||||
| -rw-r--r-- | userspace/cpp/prep.cpp | 8 | ||||
| -rw-r--r-- | userspace/cpp/testcpp.cpp | 48 | ||||
| -rw-r--r-- | userspace/fsh.c | 2 | ||||
| -rw-r--r-- | userspace/init.c | 3 |
8 files changed, 79 insertions, 51 deletions
@@ -197,7 +197,7 @@ qemu-run: all -net nic,model=e1000 \ -net tap,ifname=tap0,script=no,downscript=no \ -vga virtio \ - -m 1024 + -m 2048 #-nographic \ #-vnc :0 \ #-net dump,file=./netfool diff --git a/interface/crt0.s b/interface/crt0.s index 65123b7..914a99d 100644 --- a/interface/crt0.s +++ b/interface/crt0.s @@ -1,11 +1,8 @@ .global _start -.global myinit //temporary quickfix / test _start: -// ALIGN stack - -//push %ebx +//push %ebx // do we need to persist them??? //push %ecx //cmp $0,_impure_ptr @@ -22,7 +19,8 @@ _start: //skipzero: -/* +// move impure pointer to our special page (check if not htere already!) + mov _impure_ptr,%eax mov $0xf5000000,%ebx @@ -34,11 +32,30 @@ add $4, %eax cmp $0xf5001000,%ebx jne copy -*/ - movl $0xf5000000, _impure_ptr -//call _init +call _init // constructors + +// constructors from array_init +mov $__init_array_start,%eax + +nextctor: + +//cmp (__init_array_end),%eax +cmp $__init_array_end,%eax +je finctor + +push %eax +call *(%eax) +pop %eax + +add $4, %eax +jmp nextctor + +finctor: + +//pop %ecx +//pop %ebx # environment adress was passed on stack @@ -61,15 +78,22 @@ call main and $-16,%esp sub $4,%esp +push %eax + +call _fini //desctructors + +// pop programmm return value +pop %eax + +// ALIGN stack +and $-16,%esp +sub $4,%esp + # push exit code and pass to _exit syscall push %eax call exit -# this should never be reached! +# and this should never be reached!! .wait: hlt jmp .wait - -myinit: -call _init -ret diff --git a/kernel/syscalls.c b/kernel/syscalls.c index d579dc3..29b5b6b 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -519,5 +519,7 @@ uint32_t syscall_generic(uint32_t nr,uint32_t p1, uint32_t p2, uint32_t p3, uint case SYSCALL_GUI_WIN : return syscall_gui_win(p1,p2,p3,pid); } - kpanic("unknown syscall %d",nr); + klog("unknown syscall %s / %d",p1,nr); + return 0; } + diff --git a/userspace/cpp/Makefile b/userspace/cpp/Makefile index 9f4b314..e61438a 100644 --- a/userspace/cpp/Makefile +++ b/userspace/cpp/Makefile @@ -1,15 +1,10 @@ CXX=i686-foolos-g++ -CFLAGS= -CFLAGS+=-O0 -CFLAGS+=-gstabs +CXXFLAGS= +CXXFLAGS+=-O0 +CXXFLAGS+=-gstabs -LDLIBS+=-lgcc - -ASFLAGS= -ASFLAGS+=-gstabs - -testcpp: prep.cpp +testcpp: clean: rm -f testcpp diff --git a/userspace/cpp/prep.cpp b/userspace/cpp/prep.cpp deleted file mode 100644 index a09adbe..0000000 --- a/userspace/cpp/prep.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include <reent.h> -#include <cstring> - -void prep() -{ -_REENT_INIT_PTR(_impure_ptr); -} - diff --git a/userspace/cpp/testcpp.cpp b/userspace/cpp/testcpp.cpp index 53e3a3b..8ed7d55 100644 --- a/userspace/cpp/testcpp.cpp +++ b/userspace/cpp/testcpp.cpp @@ -3,31 +3,51 @@ #include <cstdio> #include <iostream> -void prep(); -void myinit(); +struct test +{ + int i; + test(int ii):i(ii) { printf("test:ctor %i\n",i); } + ~test() { printf("test:dtor %i\n",i ); } +}; + +test t1(1); // global constructor should get called and desctructed on exit from our crt0 + +int somefunc() +{ + test t2(2); +} int main() { - prep(); - myinit(); - int myints[] = {32,71,12,45,26,80,53,33}; - std::vector<int> myvector (myints, myints+8); // 32 71 12 45 26 80 53 33 + printf(" --- testing ctors & dtors ---\n"); - // using default comparison (operator <): - std::sort (myvector.begin(), myvector.begin()+4); //(12 32 45 71)26 80 53 33 + somefunc(); + test t3(3); - for (std::vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it) - printf("%i\n",*it); - printf("hello\n"); -// printf("reent struct size: %d bytes\n",sizeof(struct _reent)); - // printf("reent pointer : 0x%08x\n",_impure_ptr); - //printf("reent pointer : 0x%08x\n",_impure_ptr); std::cout << "bye bye" << std::endl; + + /* + + int myints[] = {32,71,12,45,26,80,53,33}; + + std::vector<int> myvector (myints, myints+8); // 32 71 12 45 26 80 53 33 + std::sort (myvector.begin(), myvector.begin()+4); //(12 32 45 71)26 80 53 33 + + for (std::vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it) + printf("%i\n",*it); + + printf("hello\n"); printf("hello\n"); + */ + printf("-- fin -- \n"); + } +// printf("reent struct size: %d bytes\n",sizeof(struct _reent)); + // printf("reent pointer : 0x%08x\n",_impure_ptr); + //printf("reent pointer : 0x%08x\n",_impure_ptr); // constructing vectors /* #include <iostream> diff --git a/userspace/fsh.c b/userspace/fsh.c index 86184e9..0b3acfd 100644 --- a/userspace/fsh.c +++ b/userspace/fsh.c @@ -19,7 +19,6 @@ #include <string.h> #include <errno.h> #include <string.h> -#include <reent.h> #include "interface/fs.h" #include "newcalls.h" @@ -60,7 +59,6 @@ void prompt() int main(int argc, char **argv) { - _REENT_INIT_PTR(_impure_ptr); for(int i=0;i<argc;i++) { diff --git a/userspace/init.c b/userspace/init.c index 84c47a5..57809a6 100644 --- a/userspace/init.c +++ b/userspace/init.c @@ -2,12 +2,9 @@ #include <time.h> #include "put_pixel.h" #include "newcalls.h" -#include <reent.h> - int main(int argc, char **argv) { - _REENT_INIT_PTR(_impure_ptr); char *argv1[]={"xterm","/bin/fsh",0}; char *env1[]={"HOME=/home/miguel","PS1=\033[34m$\033[37m","PWD=/home/miguel","PATH=/bin","TERM=fool-term",0}; |
