diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/include/syscall.h | 6 | ||||
-rw-r--r-- | src/lib/libkogata/start.c | 8 | ||||
-rw-r--r-- | src/lib/libkogata/syscall.c | 15 |
3 files changed, 23 insertions, 6 deletions
diff --git a/src/lib/include/syscall.h b/src/lib/include/syscall.h index d6df4ec..37d7302 100644 --- a/src/lib/include/syscall.h +++ b/src/lib/include/syscall.h @@ -4,9 +4,15 @@ #include <stdint.h> #include <stdbool.h> +#include <syscallid.h> + #include <fs.h> #include <debug.h> void dbg_print(const char* str); void yield(); +void exit(int code); + +// more todo +/* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/lib/libkogata/start.c b/src/lib/libkogata/start.c index 030423c..9ba7edf 100644 --- a/src/lib/libkogata/start.c +++ b/src/lib/libkogata/start.c @@ -1,12 +1,12 @@ -#include <stddef.h> -#include <stdint.h> -#include <stdbool.h> +#include <syscall.h> extern int main(int, char**); void __libkogata_start() { // TODO : setup - main(0, 0); + int ret = main(0, 0); + + exit(ret); } diff --git a/src/lib/libkogata/syscall.c b/src/lib/libkogata/syscall.c index 234b9ff..dc7e648 100644 --- a/src/lib/libkogata/syscall.c +++ b/src/lib/libkogata/syscall.c @@ -1,10 +1,21 @@ #include <debug.h> #include <syscall.h> +#include <string.h> + void dbg_print(const char* str) { - // TODO + + char buf[256]; + strncpy(buf, str, 256); + buf[255] = 0; + + asm volatile("int $0x40"::"a"(SC_DBG_PRINT),"b"(buf)); } void yield() { - // TODO + asm volatile("int $0x40"::"a"(SC_YIELD)); +} + +void exit(int code) { + asm volatile("int $0x40"::"a"(SC_EXIT),"b"(code)); } |