diff --git a/arch/at91sam3x8e/atomic.c b/arch/at91sam3x8e/atomic.c index 6bab9cb..f80da00 100644 --- a/arch/at91sam3x8e/atomic.c +++ b/arch/at91sam3x8e/atomic.c @@ -3,7 +3,7 @@ #include #include -static ATOM_DEFINE(atomic_context); +static ATOM(atomic_context); void atomic_enter(void) { diff --git a/include/arch-generic/entry.h b/include/arch-generic/entry.h index 2d81f1d..920ac00 100644 --- a/include/arch-generic/entry.h +++ b/include/arch-generic/entry.h @@ -3,15 +3,18 @@ #pragma once /** - * Perform a syscall. + * @brief Perform a syscall. * - * This is the first and only method called by the irq handler for system calls. - * It is responsible for finishing the context switch, obtaining the syscall - * number and arguments, and invoking the respective system call. + * This is called by the syscall exception handler. It is responsible for + * finishing the context switch, obtaining the syscall number and arguments, + * and invoking the respective system call. If the return value of this + * function is nonzero, the scheduler is invoked after the call and before + * returning to userspace. * - * @param sp: The current stack pointer. + * @param sp current stack pointer + * @returns Whether rescheduling is required */ -void arch_enter(void *sp); +int arch_enter(void *sp); /* * This file is part of Ardix. diff --git a/include/arch-generic/syscall.h b/include/arch-generic/syscall.h index 3d9e707..60536c9 100644 --- a/include/arch-generic/syscall.h +++ b/include/arch-generic/syscall.h @@ -2,8 +2,8 @@ #pragma once -#define ARCH_SYSCALL_READ 0 -#define ARCH_SYSCALL_WRITE 1 +#define ARCH_SYS_read 0 +#define ARCH_SYS_write 1 /* * This file is part of Ardix. diff --git a/include/ardix/atom.h b/include/ardix/atom.h index 756fca0..a8d6d3f 100644 --- a/include/ardix/atom.h +++ b/include/ardix/atom.h @@ -5,7 +5,7 @@ #include #include -#define ATOM_DEFINE(name) atom_t name = { .count = 0, } +#define ATOM(name) atom_t name = { .count = 0, } void atom_init(atom_t *atom); diff --git a/include/ardix/syscall.h b/include/ardix/syscall.h index 4d8640c..658697c 100644 --- a/include/ardix/syscall.h +++ b/include/ardix/syscall.h @@ -10,8 +10,8 @@ #include enum syscall { - SYSCALL_READ = ARCH_SYSCALL_READ, - SYSCALL_WRITE = ARCH_SYSCALL_WRITE, + SYS_read = ARCH_SYS_read, + SYS_write = ARCH_SYS_write, NSYSCALLS }; diff --git a/kernel/syscall.c b/kernel/syscall.c index 871cf40..e59d499 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -10,8 +10,8 @@ __rodata int (*const sys_table[NSYSCALLS])(sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, sysarg_t arg6) = { - sys_table_entry(SYSCALL_READ, &sys_read), - sys_table_entry(SYSCALL_WRITE, &sys_write), + sys_table_entry(SYS_read, sys_read), + sys_table_entry(SYS_write, sys_write), }; int sys_stub(void) diff --git a/lib/unistd.c b/lib/unistd.c index 5a0eb2e..77f7fc6 100644 --- a/lib/unistd.c +++ b/lib/unistd.c @@ -6,12 +6,12 @@ ssize_t read(int fildes, void *buf, size_t nbyte) { - return syscall(SYSCALL_READ, (sysarg_t)fildes, (sysarg_t)buf, (sysarg_t)nbyte); + return syscall(SYS_read, (sysarg_t)fildes, (sysarg_t)buf, (sysarg_t)nbyte); } ssize_t write(int fildes, const void *buf, size_t nbyte) { - return syscall(SYSCALL_WRITE, (sysarg_t)fildes, (sysarg_t)buf, (sysarg_t)nbyte); + return syscall(SYS_write, (sysarg_t)fildes, (sysarg_t)buf, (sysarg_t)nbyte); } /*