Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build OpenDOS

on:
push:
branches: [main]
branches: ['**']
pull_request:
branches: [main]

Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
21 changes: 21 additions & 0 deletions src/include/syscalls.h
Original file line number Diff line number Diff line change
@@ -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);
}
*/
26 changes: 26 additions & 0 deletions src/syscall.c
Original file line number Diff line number Diff line change
@@ -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;
}