This commit is contained in:
2026-09-16 05:12:52 +02:00
parent 3e9bdf72c9
commit 6719239036
5 changed files with 344 additions and 310 deletions
+1 -1
View File
@@ -88,7 +88,7 @@ struct task_start_info {
void arch_sched_preempt_disable();
bool arch_sched_preempt_enable();
void arch_sched_switch(struct task* from, struct task* to);
struct task* arch_sched_switch(struct task* from, struct task* to);
errno_t arch_task_init(
struct arch_task_context* context,
void* entry,
+20 -10
View File
@@ -2,24 +2,34 @@
#include <zinnia/sched.h>
enum syscall_kind {
enum syscall_kind : uint8_t {
SYSKIND_CALL = 0, // Regular call, returns error and/or value.
SYSKIND_CONTEXT, // Consumes the entire register image.
SYSKIND_NORETURN, // Does not resume control to the calling process.
};
struct syscall {
void (*handler)(struct arch_context*);
enum syscall_kind kind;
};
struct syscall_return {
int errno;
uintptr_t value;
int errno;
};
struct syscall {
union {
struct syscall_return (*call)(uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
void (*context)(struct arch_context*);
};
enum syscall_kind kind;
};
struct syscall_return syscall_dispatch_call(
size_t num,
uintptr_t a0,
uintptr_t a1,
uintptr_t a2,
uintptr_t a3,
uintptr_t a4,
uintptr_t a5
);
void syscall_dispatch(struct arch_context* ctx);
#include <zinnia/syscall_list.h>
extern const struct syscall syscall_table[256];
+152 -145
View File
@@ -1,149 +1,156 @@
#pragma once
#include <zinnia/sched.h>
#include <zinnia/syscall.h>
#include <stdint.h>
extern void sys_exit(struct arch_context* ctx);
extern void sys_syslog(struct arch_context* ctx);
extern void sys_getuname(struct arch_context* ctx);
extern void sys_setuname(struct arch_context* ctx);
extern void sys_archctl(struct arch_context* ctx);
extern void sys_reboot(struct arch_context* ctx);
extern void sys_mmap(struct arch_context* ctx);
extern void sys_munmap(struct arch_context* ctx);
extern void sys_mprotect(struct arch_context* ctx);
extern void sys_madvise(struct arch_context* ctx);
extern void sys_sigprocmask(struct arch_context* ctx);
extern void sys_sigsuspend(struct arch_context* ctx);
extern void sys_sigpending(struct arch_context* ctx);
extern void sys_sigaction(struct arch_context* ctx);
extern void sys_sigtimedwait(struct arch_context* ctx);
extern void sys_sigaltstack(struct arch_context* ctx);
extern void sys_sigreturn(struct arch_context* ctx);
extern void sys_sigqueue(struct arch_context* ctx);
extern void sys_execve(struct arch_context* ctx);
extern void sys_fexecve(struct arch_context* ctx);
extern void sys_fork(struct arch_context* ctx);
extern void sys_kill(struct arch_context* ctx);
extern void sys_gettid(struct arch_context* ctx);
extern void sys_getpid(struct arch_context* ctx);
extern void sys_getppid(struct arch_context* ctx);
extern void sys_waitid(struct arch_context* ctx);
extern void sys_waitpid(struct arch_context* ctx);
extern void sys_pread(struct arch_context* ctx);
extern void sys_readv(struct arch_context* ctx);
extern void sys_pwrite(struct arch_context* ctx);
extern void sys_writev(struct arch_context* ctx);
extern void sys_seek(struct arch_context* ctx);
extern void sys_ioctl(struct arch_context* ctx);
extern void sys_openat(struct arch_context* ctx);
extern void sys_close(struct arch_context* ctx);
extern void sys_fstat(struct arch_context* ctx);
extern void sys_fstatat(struct arch_context* ctx);
extern void sys_statvfs(struct arch_context* ctx);
extern void sys_fstatvfs(struct arch_context* ctx);
extern void sys_faccessat(struct arch_context* ctx);
extern void sys_fcntl(struct arch_context* ctx);
extern void sys_ftruncate(struct arch_context* ctx);
extern void sys_truncate(struct arch_context* ctx);
extern void sys_fallocate(struct arch_context* ctx);
extern void sys_fadvise(struct arch_context* ctx);
extern void sys_utimensat(struct arch_context* ctx);
extern void sys_mknodat(struct arch_context* ctx);
extern void sys_getcwd(struct arch_context* ctx);
extern void sys_chdir(struct arch_context* ctx);
extern void sys_fchdir(struct arch_context* ctx);
extern void sys_mkdirat(struct arch_context* ctx);
extern void sys_rmdirat(struct arch_context* ctx);
extern void sys_getdents(struct arch_context* ctx);
extern void sys_renameat(struct arch_context* ctx);
extern void sys_fchmod(struct arch_context* ctx);
extern void sys_fchmodat(struct arch_context* ctx);
extern void sys_fchownat(struct arch_context* ctx);
extern void sys_linkat(struct arch_context* ctx);
extern void sys_symlinkat(struct arch_context* ctx);
extern void sys_unlinkat(struct arch_context* ctx);
extern void sys_readlinkat(struct arch_context* ctx);
extern void sys_flock(struct arch_context* ctx);
extern void sys_ppoll(struct arch_context* ctx);
extern void sys_dup(struct arch_context* ctx);
extern void sys_dup3(struct arch_context* ctx);
extern void sys_sync(struct arch_context* ctx);
extern void sys_fsync(struct arch_context* ctx);
extern void sys_fdatasync(struct arch_context* ctx);
extern void sys_getgroups(struct arch_context* ctx);
extern void sys_setgroups(struct arch_context* ctx);
extern void sys_getsid(struct arch_context* ctx);
extern void sys_setsid(struct arch_context* ctx);
extern void sys_setuid(struct arch_context* ctx);
extern void sys_getuid(struct arch_context* ctx);
extern void sys_setgid(struct arch_context* ctx);
extern void sys_getgid(struct arch_context* ctx);
extern void sys_geteuid(struct arch_context* ctx);
extern void sys_seteuid(struct arch_context* ctx);
extern void sys_getegid(struct arch_context* ctx);
extern void sys_setegid(struct arch_context* ctx);
extern void sys_getpgid(struct arch_context* ctx);
extern void sys_setpgid(struct arch_context* ctx);
extern void sys_getresuid(struct arch_context* ctx);
extern void sys_setresuid(struct arch_context* ctx);
extern void sys_getresgid(struct arch_context* ctx);
extern void sys_setresgid(struct arch_context* ctx);
extern void sys_setreuid(struct arch_context* ctx);
extern void sys_setregid(struct arch_context* ctx);
extern void sys_umask(struct arch_context* ctx);
extern void sys_pipe(struct arch_context* ctx);
extern void sys_futex_wait(struct arch_context* ctx);
extern void sys_futex_wake(struct arch_context* ctx);
extern void sys_thread_create(struct arch_context* ctx);
extern void sys_thread_kill(struct arch_context* ctx);
extern void sys_thread_exit(struct arch_context* ctx);
extern void sys_thread_setname(struct arch_context* ctx);
extern void sys_thread_getname(struct arch_context* ctx);
extern void sys_timer_create(struct arch_context* ctx);
extern void sys_timer_set(struct arch_context* ctx);
extern void sys_timer_get(struct arch_context* ctx);
extern void sys_timer_getoverrun(struct arch_context* ctx);
extern void sys_timer_delete(struct arch_context* ctx);
extern void sys_itimer_get(struct arch_context* ctx);
extern void sys_itimer_set(struct arch_context* ctx);
extern void sys_clock_get(struct arch_context* ctx);
extern void sys_clock_getres(struct arch_context* ctx);
extern void sys_clock_set(struct arch_context* ctx);
extern void sys_sleep(struct arch_context* ctx);
extern void sys_yield(struct arch_context* ctx);
extern void sys_chroot(struct arch_context* ctx);
extern void sys_mount(struct arch_context* ctx);
extern void sys_umount(struct arch_context* ctx);
extern void sys_socket(struct arch_context* ctx);
extern void sys_socketpair(struct arch_context* ctx);
extern void sys_shutdown(struct arch_context* ctx);
extern void sys_bind(struct arch_context* ctx);
extern void sys_connect(struct arch_context* ctx);
extern void sys_accept(struct arch_context* ctx);
extern void sys_listen(struct arch_context* ctx);
extern void sys_getpeername(struct arch_context* ctx);
extern void sys_getsockname(struct arch_context* ctx);
extern void sys_getsockopt(struct arch_context* ctx);
extern void sys_setsockopt(struct arch_context* ctx);
extern void sys_sendmsg(struct arch_context* ctx);
extern void sys_recvmsg(struct arch_context* ctx);
extern void sys_getentropy(struct arch_context* ctx);
extern void sys_getrusage(struct arch_context* ctx);
extern void sys_getrlimit(struct arch_context* ctx);
extern void sys_setrlimit(struct arch_context* ctx);
extern void sys_getpriority(struct arch_context* ctx);
extern void sys_setpriority(struct arch_context* ctx);
extern void sys_sched_getparam(struct arch_context* ctx);
extern void sys_sched_setparam(struct arch_context* ctx);
extern void sys_module_insert(struct arch_context* ctx);
extern void sys_module_remove(struct arch_context* ctx);
extern void sys_epoll_create(struct arch_context* ctx);
extern void sys_epoll_ctl(struct arch_context* ctx);
extern void sys_epoll_pwait(struct arch_context* ctx);
extern void sys_timerfd_create(struct arch_context* ctx);
extern void sys_timerfd_gettime(struct arch_context* ctx);
extern void sys_timerfd_settime(struct arch_context* ctx);
extern void sys_signalfd_create(struct arch_context* ctx);
extern void sys_eventfd_create(struct arch_context* ctx);
extern void sys_msync(struct arch_context* ctx);
extern void sys_sysconf(struct arch_context* ctx);
#define __SYSCALL_CALL(name) \
struct syscall_return sys_##name(uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t)
#define __SYSCALL_CONTEXT(name) void sys_##name(struct arch_context*)
__SYSCALL_CALL(exit);
__SYSCALL_CALL(syslog);
__SYSCALL_CALL(getuname);
__SYSCALL_CALL(setuname);
__SYSCALL_CALL(archctl);
__SYSCALL_CALL(reboot);
__SYSCALL_CALL(mmap);
__SYSCALL_CALL(munmap);
__SYSCALL_CALL(mprotect);
__SYSCALL_CALL(madvise);
__SYSCALL_CALL(sigprocmask);
__SYSCALL_CALL(sigsuspend);
__SYSCALL_CALL(sigpending);
__SYSCALL_CALL(sigaction);
__SYSCALL_CALL(sigtimedwait);
__SYSCALL_CALL(sigaltstack);
__SYSCALL_CALL(sigreturn);
__SYSCALL_CALL(sigqueue);
__SYSCALL_CALL(execve);
__SYSCALL_CALL(fexecve);
__SYSCALL_CONTEXT(fork);
__SYSCALL_CALL(kill);
__SYSCALL_CALL(gettid);
__SYSCALL_CALL(getpid);
__SYSCALL_CALL(getppid);
__SYSCALL_CALL(waitid);
__SYSCALL_CALL(waitpid);
__SYSCALL_CALL(pread);
__SYSCALL_CALL(readv);
__SYSCALL_CALL(pwrite);
__SYSCALL_CALL(writev);
__SYSCALL_CALL(seek);
__SYSCALL_CALL(ioctl);
__SYSCALL_CALL(openat);
__SYSCALL_CALL(close);
__SYSCALL_CALL(fstat);
__SYSCALL_CALL(fstatat);
__SYSCALL_CALL(statvfs);
__SYSCALL_CALL(fstatvfs);
__SYSCALL_CALL(faccessat);
__SYSCALL_CALL(fcntl);
__SYSCALL_CALL(ftruncate);
__SYSCALL_CALL(truncate);
__SYSCALL_CALL(fallocate);
__SYSCALL_CALL(fadvise);
__SYSCALL_CALL(utimensat);
__SYSCALL_CALL(mknodat);
__SYSCALL_CALL(getcwd);
__SYSCALL_CALL(chdir);
__SYSCALL_CALL(fchdir);
__SYSCALL_CALL(mkdirat);
__SYSCALL_CALL(rmdirat);
__SYSCALL_CALL(getdents);
__SYSCALL_CALL(renameat);
__SYSCALL_CALL(fchmod);
__SYSCALL_CALL(fchmodat);
__SYSCALL_CALL(fchownat);
__SYSCALL_CALL(linkat);
__SYSCALL_CALL(symlinkat);
__SYSCALL_CALL(unlinkat);
__SYSCALL_CALL(readlinkat);
__SYSCALL_CALL(flock);
__SYSCALL_CALL(ppoll);
__SYSCALL_CALL(dup);
__SYSCALL_CALL(dup3);
__SYSCALL_CALL(sync);
__SYSCALL_CALL(fsync);
__SYSCALL_CALL(fdatasync);
__SYSCALL_CALL(getgroups);
__SYSCALL_CALL(setgroups);
__SYSCALL_CALL(getsid);
__SYSCALL_CALL(setsid);
__SYSCALL_CALL(setuid);
__SYSCALL_CALL(getuid);
__SYSCALL_CALL(setgid);
__SYSCALL_CALL(getgid);
__SYSCALL_CALL(geteuid);
__SYSCALL_CALL(seteuid);
__SYSCALL_CALL(getegid);
__SYSCALL_CALL(setegid);
__SYSCALL_CALL(getpgid);
__SYSCALL_CALL(setpgid);
__SYSCALL_CALL(getresuid);
__SYSCALL_CALL(setresuid);
__SYSCALL_CALL(getresgid);
__SYSCALL_CALL(setresgid);
__SYSCALL_CALL(setreuid);
__SYSCALL_CALL(setregid);
__SYSCALL_CALL(umask);
__SYSCALL_CALL(pipe);
__SYSCALL_CALL(futex_wait);
__SYSCALL_CALL(futex_wake);
__SYSCALL_CALL(thread_create);
__SYSCALL_CALL(thread_kill);
__SYSCALL_CALL(thread_exit);
__SYSCALL_CALL(thread_setname);
__SYSCALL_CALL(thread_getname);
__SYSCALL_CALL(timer_create);
__SYSCALL_CALL(timer_set);
__SYSCALL_CALL(timer_get);
__SYSCALL_CALL(timer_getoverrun);
__SYSCALL_CALL(timer_delete);
__SYSCALL_CALL(itimer_get);
__SYSCALL_CALL(itimer_set);
__SYSCALL_CALL(clock_get);
__SYSCALL_CALL(clock_getres);
__SYSCALL_CALL(clock_set);
__SYSCALL_CALL(sleep);
__SYSCALL_CALL(yield);
__SYSCALL_CALL(chroot);
__SYSCALL_CALL(mount);
__SYSCALL_CALL(umount);
__SYSCALL_CALL(socket);
__SYSCALL_CALL(socketpair);
__SYSCALL_CALL(shutdown);
__SYSCALL_CALL(bind);
__SYSCALL_CALL(connect);
__SYSCALL_CALL(accept);
__SYSCALL_CALL(listen);
__SYSCALL_CALL(getpeername);
__SYSCALL_CALL(getsockname);
__SYSCALL_CALL(getsockopt);
__SYSCALL_CALL(setsockopt);
__SYSCALL_CALL(sendmsg);
__SYSCALL_CALL(recvmsg);
__SYSCALL_CALL(getentropy);
__SYSCALL_CALL(getrusage);
__SYSCALL_CALL(getrlimit);
__SYSCALL_CALL(setrlimit);
__SYSCALL_CALL(getpriority);
__SYSCALL_CALL(setpriority);
__SYSCALL_CALL(sched_getparam);
__SYSCALL_CALL(sched_setparam);
__SYSCALL_CALL(module_insert);
__SYSCALL_CALL(module_remove);
__SYSCALL_CALL(epoll_create);
__SYSCALL_CALL(epoll_ctl);
__SYSCALL_CALL(epoll_pwait);
__SYSCALL_CALL(timerfd_create);
__SYSCALL_CALL(timerfd_gettime);
__SYSCALL_CALL(timerfd_settime);
__SYSCALL_CALL(signalfd_create);
__SYSCALL_CALL(eventfd_create);
__SYSCALL_CALL(msync);
__SYSCALL_CALL(sysconf);