diff options
Diffstat (limited to 'src/user/lib')
-rw-r--r-- | src/user/lib/include/tce/syscall.h | 11 | ||||
-rw-r--r-- | src/user/lib/std/stdio.c | 1 | ||||
-rw-r--r-- | src/user/lib/tce/syscall.c | 41 |
3 files changed, 52 insertions, 1 deletions
diff --git a/src/user/lib/include/tce/syscall.h b/src/user/lib/include/tce/syscall.h index 7bcdd2b..028b544 100644 --- a/src/user/lib/include/tce/syscall.h +++ b/src/user/lib/include/tce/syscall.h @@ -3,6 +3,7 @@ #include <types.h> #include <tce/syscalls.h> +#include <tce/vfs.h> #define NEW_STACK_SIZE 0x8000 @@ -18,4 +19,14 @@ int proc_priv(); void* sbrk(size_t size); void brk(void* ptr); +FILE open(char* filename, int mode); +FILE open_relative(FILE root, char* filename, int mode); +int stat(char* filename, file_info *info); +int stat_relative(FILE root, char* filename, file_info *info); +int statf(FILE file, file_info *info); +void close(FILE file); +int read(FILE file, size_t offset, size_t len, char *buffer); +int write(FILE file, size_t offset, size_t len, char *buffer); +int link(char* from, char* to, int mode); + #endif diff --git a/src/user/lib/std/stdio.c b/src/user/lib/std/stdio.c index 63ad357..c11dd05 100644 --- a/src/user/lib/std/stdio.c +++ b/src/user/lib/std/stdio.c @@ -32,7 +32,6 @@ void printk_int(int number) { } r[order] = 0; printk(s); - free(s); } void printk_hex(unsigned v) { diff --git a/src/user/lib/tce/syscall.c b/src/user/lib/tce/syscall.c index c7965a9..4e81475 100644 --- a/src/user/lib/tce/syscall.c +++ b/src/user/lib/tce/syscall.c @@ -1,6 +1,7 @@ #include <tce/syscall.h> #include <stdlib.h> #include <sched.h> +#include <tce/vfs.h> static size_t call(size_t a, size_t b, size_t c, size_t d, size_t e, size_t f) { size_t ret; @@ -62,6 +63,8 @@ int proc_priv() { return call(SC_PROC_PRIV, 0, 0, 0, 0, 0); } +// ******** memory + void* sbrk(size_t s) { return (void*)call(SC_SBRK, s, 0, 0, 0, 0); } @@ -69,3 +72,41 @@ void* sbrk(size_t s) { void brk(void* ptr) { return call (SC_BRK, ptr, 0, 0, 0, 0); } + +// ********** file + +FILE open(char* filename, int mode) { + return call(SC_OPEN, (unsigned)filename, mode, 0, 0, 0); +} + +FILE open_relative(FILE root, char* filename, int mode) { + return call(SC_OPEN_RELATIVE, root, (unsigned) filename, mode, 0, 0); +} + +int stat(char* filename, file_info *info) { + return call(SC_STAT, (unsigned) filename, (unsigned) info, 0, 0, 0); +} + +int stat_relative(FILE root, char* filename, file_info *info) { + return call(SC_STAT_RELATIVE, root, (unsigned) filename, (unsigned) info, 0, 0); +} + +int statf(FILE file, file_info *info) { + return call(SC_STATF, file, (unsigned)info, 0, 0, 0); +} + +void close(FILE file) { + call(SC_CLOSE, file, 0, 0, 0, 0); +} + +int read(FILE file, size_t offset, size_t len, char *buffer) { + return call(SC_READ, file, offset, len, (unsigned) buffer, 0); +} + +int write(FILE file, size_t offset, size_t len, char* buffer) { + return call(SC_WRITE, file, offset, len, (unsigned) buffer, 0); +} + +int link(char* from, char* to, int mode) { + return call(SC_LINK, (unsigned) from, (unsigned)to, mode, 0, 0); +} |