#define FOOLOS_MODULE_NAME "syscalls" #include "lib/buffer/ringbuffer.h" #include "lib/logger/log.h" #include "lib/bool/bool.h" #include "fs/fs.h" #include "fs/ext2.h" #include "kernel/console.h" #include "kernel/config.h" #include int syscall_write(int file, char *buf, int len) { #ifdef LOG_SYSCALLS log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"write(file=%d, buf=0x%08X, len=%d)", file,buf,len); #endif // ALL output to stdout for(int i=0;ist_mode = S_IFCHR; return 0; } int syscall_isatty(int file,int none1,int none2) { #ifdef LOG_SYSCALLS log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"isatty (file=%d)", file); #endif 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) { static uint32_t alloc; // 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; #ifdef LOG_SYSCALLS log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"sbrk (incr=%d) = 0x%08X", incr,oldalloc); #endif 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; */ } int syscall_exit(int ret, int none1, int none2) { #ifdef LOG_SYSCALLS log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"exit (ret=%d)", ret); #endif syscall_execve(15,0,0); // start shell }