diff options
Diffstat (limited to 'interface')
| -rw-r--r-- | interface/syscalls.c | 54 | ||||
| -rw-r--r-- | interface/syscalls.h | 34 |
2 files changed, 55 insertions, 33 deletions
diff --git a/interface/syscalls.c b/interface/syscalls.c index c9964fd..42fba62 100644 --- a/interface/syscalls.c +++ b/interface/syscalls.c @@ -14,40 +14,47 @@ // TODO ? all funct not preceeded with underscore should go as #defines // inside headers! for newlib we define both here now ... // +// TODO: do we want all the wrappers here? +// TODO: how does the underscored and non-underscored versions work in gcc-linux +// lookup : ELF symbol interposion! -// BASICS // +// FIRST SOME TRIVIAL BASICS // +// They do not even call the kernel at all // -// everybody is root +/** everybody is root in Fool Os */ uid_t getuid(void) { return 0; } -// everybody is root +/** everybody is root in Fool Os */ uid_t getgid(void) { return 0; } -// everybody is root +/** everybody is root in Fool Os */ char *getlogin(void) { return "root"; } -// the hostname is hard +/** The hostname is hardcoded here. + * Just recompile if you want to change this ;) + */ int gethostname(char *name, size_t len) { - strcpy(name,"foolcomp"); + strcpy(name,"foolbox"); return 0; //success } -// no sync needed for our ram-image so far (maye once w use DMA?) +/** no sync required by our ram-image **/ void sync(void) { } -// set working directory - we simply save this in PWD environment var +/** set working directory. + * We save it in PWD environment var */ int chdir(const char *path) { char buf[256]; @@ -56,14 +63,14 @@ int chdir(const char *path) return 0; // assume success } -// get working dir (see chdir) +/** get working dir (see chdir) */ char* getwd(char *buf) { return strcpy(buf,getenv("PWD")); } -// HELPER for flushing stdout down the toilet when main exits // -// newlib does not do this ? TODO: check what the standard says. // +/** HELPER for flushing stdout down the toilet when main exits. + newlib does not do this ? TODO: check what the standard says. */ void _flushing() { fflush(stdout); @@ -71,12 +78,12 @@ void _flushing() // C NEWLIB // -// here we have a few posix syscalls required by newlib +// here we have a few posix syscalls, mostly required by newlib // (we use version newlib-3.0.0.20180802) // https://sourceware.org/newlib/libc.html#Syscalls // just check liunx man-pages, how they SHOULD work. -// holds environment variables +/** holds environment variables */ extern char **environ; // terminate caller @@ -250,7 +257,6 @@ int gettimeofday(struct timeval *tv, void *tz) return syscall(SYSCALL_GETTIMEOFDAY,tv,tz,0); } -// not sure if required by newlib ? /// int _lstat(const char *file, struct stat *st) { return syscall(SYSCALL_LSTAT,file,st,0); @@ -260,14 +266,14 @@ int lstat(const char *file, struct stat *st) return syscall(SYSCALL_LSTAT,file,st,0); } -// like fork but keeps runin' on same memory so we have multithreading +/** works like fork() but keeps running mostly on the same memory so we + * have multithreading as well. */ int _clone(void) { return syscall(SYSCALL_CLONE,0,0,0); } // DIRENT // - DIR *opendir(const char *name) { DIR *dir=malloc(sizeof(struct dirent)); @@ -333,26 +339,26 @@ int dup(int oldfd) // PRIMITIVE GUI SYSCALLS // -// create window for running process -int _gui_win() +/** create window for running process */ +int _gui_win(uint32_t xy, uint32_t wh,uint32_t f) { - return syscall(SYSCALL_GUI_WIN,0,0,0); + return syscall(SYSCALL_GUI_WIN,xy,wh,f); } -// swap buffers -int _gui_rect() +/** invalidate screen rectangle and set user framebuffer addy + * we pack x,y and width,height togehter */ +int _gui_inval(uint32_t xy, uint32_t wh, uint32_t addr) { - return syscall(SYSCALL_GUI_RECT,0,0,0); + return syscall(SYSCALL_GUI_RECT,xy,wh,addr); } ////////////////////////////////////////// move along fool /////////// // // ALL calls under this lines are just stubs to let some 3rd party stuff -// compile and fail silently on runtime where applicable. +// compile and fail silently during runtime where applicable. // ///// - long fpathconf(int fd, int name) { return syscall(SYSCALL_UNIMPLEMENTED,"fpathconf",0,0); diff --git a/interface/syscalls.h b/interface/syscalls.h index 604e150..668a3d2 100644 --- a/interface/syscalls.h +++ b/interface/syscalls.h @@ -1,3 +1,19 @@ +/** + * @file + * + * Fool OS System Calls + * ==================== + * + * This is THE way for user programms to communicate with the kernel. + * + * The kernel exhibits a set of a few posix-style calls and some other + * non-standard foolish calls invented by myself. + * + * TODO: DOCUMENT each call! + * reentrant? limitations? posix compilance? implemented fully? + */ + + #define SYSCALL_EXIT 60 #define SYSCALL_CLOSE 66 #define SYSCALL_EXECVE 64 @@ -20,14 +36,14 @@ #define SYSCALL_READDIR 63 #define SYSCALL_KILL 73 #define SYSCALL_POLL 80 -#define SYSCALL_CLONE 83 -#define SYSCALL_PIPE 84 -#define SYSCALL_DUP2 86 -#define SYSCALL_GUI_RECT 87 -#define SYSCALL_GUI_WIN 88 -#define SYSCALL_SELECT 89 -#define SYSCALL_TCGETATTR 90 -#define SYSCALL_TCSETATTR 91 -#define SYSCALL_OPENDIR 92 +#define SYSCALL_CLONE 83 +#define SYSCALL_PIPE 84 +#define SYSCALL_DUP2 86 +#define SYSCALL_GUI_RECT 87 +#define SYSCALL_GUI_WIN 88 +#define SYSCALL_SELECT 89 +#define SYSCALL_TCGETATTR 90 +#define SYSCALL_TCSETATTR 91 +#define SYSCALL_OPENDIR 92 #define SYSCALL_UNIMPLEMENTED 200 |
