diff options
| author | Michal Idziorek <m.i@gmx.at> | 2014-11-23 19:28:40 +0100 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2014-11-23 19:28:40 +0100 |
| commit | 9a13aedd4ef04711fc5139c86025272e9648cc4c (patch) | |
| tree | 49cf0f4e6923df17f023abd5dbb50bd8fa53e8e5 /kernel | |
| parent | 6b8c02a9cf4ac36e42d07c668a2be27d2bf1a733 (diff) | |
double indirect block support to ELF and check sum calc
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/config.h | 2 | ||||
| -rw-r--r-- | kernel/kernel.c | 6 | ||||
| -rw-r--r-- | kernel/syscalls.c | 91 | ||||
| -rw-r--r-- | kernel/syscalls.h | 10 |
4 files changed, 38 insertions, 71 deletions
diff --git a/kernel/config.h b/kernel/config.h index e48c63c..ef0fa71 100644 --- a/kernel/config.h +++ b/kernel/config.h @@ -6,7 +6,7 @@ //#define FOOLOS_COMPILE_FLOPPY // compile floppy drivers #define FOOLOS_CONSOLE_AUTOBREAK // add newline automatically at end of line -#define FOOLOS_LOG_OFF // do not log anything +//#define FOOLOS_LOG_OFF // do not log anything #define FOOLOS_CONSOLE // otherwise VESA will be used! #define MEM_PRINT_MEMORYMAP #define LOG_BUF_SIZE 4069 diff --git a/kernel/kernel.c b/kernel/kernel.c index 6daa625..f788cee 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -5,7 +5,7 @@ */ #ifdef __linux__ -#error "watchout! this is not linux but FoolOS. Use a cross-compiler" +#error "Watchout! this is not Linux but FoolOS. Use a cross-compiler" #endif #define FOOLOS_MODULE_NAME "kernel" @@ -36,10 +36,6 @@ #include "task.h" -#ifdef FOOLOS_COMPILE_FLOPPY -#include "floppy.h" -#endif - // // KERNEL MAIN diff --git a/kernel/syscalls.c b/kernel/syscalls.c index 9ad07e2..0e4ee66 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -79,6 +79,20 @@ int syscall_unhandled(int nr) log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"syscall: %d", nr); panic(FOOLOS_MODULE_NAME,"unhandled syscall"); } + +int syscall_lseek(int file,int ptr,int dir) +{ + + #ifdef LOG_SYSCALLS + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"lseek (file=%d, ptr=%d, dir=%d)", file,ptr,dir); + #endif + + panic(FOOLOS_MODULE_NAME,"unhandled syscall"); + + return 0; + +} + int syscall_write(int file, char *buf, int len) { @@ -86,6 +100,8 @@ int syscall_write(int file, char *buf, int len) log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"write(file=%d, buf=0x%08X, len=%d)", file,buf,len); #endif + if(file!=1&&file!=2) panic(FOOLOS_MODULE_NAME,"unhandled syscall"); + // ALL output to stdout for(int i=0;i<len;i++) { @@ -103,8 +119,9 @@ int syscall_read(int file, char *buf, int len) log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"read(file=%d, buf=0x%08X, len=%d)", file,buf,len); #endif + if(file!=0) panic(FOOLOS_MODULE_NAME,"unhandled syscall"); + // stdin TODO: other descroptiors! - if(file==1||file!=1) { char c; @@ -127,7 +144,7 @@ int syscall_read(int file, char *buf, int len) } - +//TODO: replace with dirent! int syscall_readdir(const char *name,fs_dirent *dirs,int max) { #ifdef LOG_SYSCALLS @@ -214,11 +231,16 @@ int syscall_execve(char *name, char **argv, char **env) // iterate over section headers for(int phidx=0;phidx<elf->e_phnum;phidx++) { + Elf32_Phdr *phdr=0x800000+elf->e_phoff+phidx*elf->e_phentsize; + + if(phidx==0) + { + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"text: 0x%08X-0x%08X",phdr->p_vaddr,phdr->p_vaddr+phdr->p_filesz); + } if(phidx==1) { - Elf32_Phdr *phdr=0x800000+elf->e_phoff+phidx*elf->e_phentsize; /* log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"-- PROGRAMM HEADER %d --",phidx+1); @@ -229,6 +251,7 @@ int syscall_execve(char *name, char **argv, char **env) log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"p-memsz: 0x%08X",phdr->p_memsz); */ + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"data: 0x%08X-0x%08X",phdr->p_vaddr,phdr->p_vaddr+phdr->p_filesz); log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"bss: 0x%08X-0x%08X",phdr->p_vaddr+phdr->p_filesz,phdr->p_vaddr+phdr->p_memsz); @@ -270,8 +293,8 @@ int syscall_open(char *name, int flags, int mode) #ifdef LOG_SYSCALLS log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"open (name=0x%08X(\"%s\"), flags=%d, mode=%d)",name, name,flags,mode); #endif + panic(FOOLOS_MODULE_NAME,"unhandled syscall"); - return 99; } @@ -284,10 +307,13 @@ int syscall_close(int file,int none1,int none2) log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"close (file=%d)", file); #endif + if(file!=0&&file!=1&&file!=2) + panic(FOOLOS_MODULE_NAME,"unhandled syscall"); + return -1; } - +// TODO: check if file is termminal! int syscall_isatty(int file,int none1,int none2) { #ifdef LOG_SYSCALLS @@ -297,44 +323,9 @@ int syscall_isatty(int file,int none1,int none2) return 1; } - -int syscall_lseek(int file,int ptr,int dir) -{ - - #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"lseek (file=%d, ptr=%d, dir=%d)", file,ptr,dir); - #endif -/* - if(dir==0)preread=ptr; - else{ while(1);} -*/ - return 0; - -} - - uint32_t syscall_sbrk(int incr, int none1, int none2) { - - // fool-os-convention to set bss_end: - /* - if(incr==0) - { - alloc=0; - return 0; - } - if(alloc==0) - { - #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"sbrk RESET to 0x%08X", incr); - #endif - - alloc=incr; - return alloc; - } - */ - uint32_t oldalloc=alloc; alloc+=incr; @@ -344,26 +335,6 @@ uint32_t syscall_sbrk(int incr, int none1, int none2) return oldalloc; - /* - - extern char end; -// char _end; - static char *heap_end; - char *prev_heap_end; - - if (heap_end == 0) { - heap_end = &end; - } - prev_heap_end = heap_end; - - if (heap_end + incr > stack_ptr) { - write (1, "Heap and stack collision\n", 25); - abort (); - } - - heap_end += incr; - return (caddr_t) prev_heap_end; - */ } diff --git a/kernel/syscalls.h b/kernel/syscalls.h index f42a34b..432bd2c 100644 --- a/kernel/syscalls.h +++ b/kernel/syscalls.h @@ -18,20 +18,20 @@ #define SYSCALL_ISATTY 68 #define SYSCALL_LSEEK 69 #define SYSCALL_SBRK 70 +#define SYSCALL_STAT 74 +#define SYSCALL_LSTAT 79 // stubs only so far! #define SYSCALL_GETTIMEOFDAY 71 #define SYSCALL_FORK 72 #define SYSCALL_KILL 73 #define SYSCALL_LINK 73 -#define SYSCALL_STAT 74 #define SYSCALL_TIMES 75 #define SYSCALL_UNLINK 76 #define SYSCALL_WAIT 77 #define SYSCALL_GETPID 78 -#define SYSCALL_LSTAT 79 - +/* int syscall_readdir(const char *name,struct fs_dirent *dirs,int max); int syscall_exit(int ret, int none1, int none2); @@ -43,6 +43,7 @@ int syscall_close(int file,int none1,int none2); int syscall_fstat(int file, struct stat *st,int none); int syscall_isatty(int file,int none1,int none2); int syscall_lseek(int file,int ptr,int dir); +int syscall_stat(char *file, struct stat *st); int syscall_sbrk(int incr, int none1, int none2); // int syscall_gettimeofday(struct timeval *tv, struct timezone *tz); @@ -50,7 +51,6 @@ int syscall_fork(void); int syscall_getpid(void); int syscall_kill(int pid, int sig); int syscall_link(char *old, char *ne); -int syscall_stat(char *file, struct stat *st); int syscall_times(struct tms *buf); int syscall_unlink(char *name); int syscall_wait(int *status); @@ -58,7 +58,7 @@ int syscall_wait(int *status); int syscall_unhandled(int nr); - +*/ |
