diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0d108fe..357ce1b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: Build OpenDOS on: push: - branches: [main] + branches: ['**'] pull_request: branches: [main] diff --git a/build.sh b/build.sh index e507071..aa1aad2 100755 --- a/build.sh +++ b/build.sh @@ -9,7 +9,7 @@ MOUNT_POINT="img" GRUB_CFG="grub.cfg" ASM_FILES=("kernel.asm") -C_FILES=("kernel.c" "string.c" "io.c" "ata.c" "keyboard.c" "fat12.c" "fs.c" "speaker.c") +C_FILES=("kernel.c" "string.c" "io.c" "ata.c" "keyboard.c" "fat12.c" "fs.c" "speaker.c" "syscall.c") RED='\033[31m' GREEN='\033[32m' diff --git a/src/include/syscalls.h b/src/include/syscalls.h new file mode 100644 index 0000000..06462a6 --- /dev/null +++ b/src/include/syscalls.h @@ -0,0 +1,21 @@ +#define SYS_INPUT 0 +#define SYS_PRINT 1 +#define SYS_PRINTERR 2 +#define SYS_EXIT 5 + +/* +// future use: +static inline uint32_t syscall(uint32_t number, uint32_t arg1, uint32_t arg2) { + uint32_t ret; + asm volatile ( + "int $0x80" + : "=a"(ret) + : "a"(number), "b"(arg1), "c"(arg2) + ); + return ret; +} + +void hello() { + syscall(SYS_PRINT, (uint32_t)"Hello from user space!\n", 0); +} +*/ diff --git a/src/syscall.c b/src/syscall.c new file mode 100644 index 0000000..f327846 --- /dev/null +++ b/src/syscall.c @@ -0,0 +1,26 @@ +#include "os.h" +#include "syscalls.h" + +uint32_t handle_syscall(uint32_t number, uint32_t arg1) { + switch (number) { + case SYS_INPUT: + // TODO: return text from input + break; + + case SYS_PRINT: + k_printf("%s", (char*)arg1); + break; + + case SYS_PRINTERR: + k_printf("\x1b[31m%s\x1b[0m\n", (char*)arg1); + break; + + case SYS_EXIT: + // TODO: exit from program + break; + + default: + return -1; // unknown syscall + } + return 0; +}