From 1b8d5b5d32c9423216931d0b0a87127d7c40cb81 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Fri, 4 Jun 2021 20:38:27 +0900 Subject: [PATCH] misc: cleanup --- base/usr/include/_xlog.h | 14 ---------- base/usr/include/sys/sysfunc.h | 3 -- kernel/sys/syscall.c | 50 +++++++++++++++++----------------- libc/stdio/stdio.c | 2 -- 4 files changed, 25 insertions(+), 44 deletions(-) delete mode 100644 base/usr/include/_xlog.h diff --git a/base/usr/include/_xlog.h b/base/usr/include/_xlog.h deleted file mode 100644 index 71c3ee59..00000000 --- a/base/usr/include/_xlog.h +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include - -#define _XLOG(_msg) do { \ - char * msg[] = { \ - __FILE__, \ - (char*)__LINE__, \ - (char*)2, \ - _msg, \ - }; \ - sysfunc(TOARU_SYS_FUNC_DEBUGPRINT, msg); \ -} while (0); - diff --git a/base/usr/include/sys/sysfunc.h b/base/usr/include/sys/sysfunc.h index cb4b9860..30d37475 100644 --- a/base/usr/include/sys/sysfunc.h +++ b/base/usr/include/sys/sysfunc.h @@ -12,8 +12,6 @@ /* Privileged */ #define TOARU_SYS_FUNC_SYNC 3 #define TOARU_SYS_FUNC_LOGHERE 4 -#define TOARU_SYS_FUNC_SETFDS 5 -#define TOARU_SYS_FUNC_WRITESDB 6 #define TOARU_SYS_FUNC_KDEBUG 7 #define TOARU_SYS_FUNC_INSMOD 8 @@ -21,7 +19,6 @@ #define TOARU_SYS_FUNC_SETHEAP 9 #define TOARU_SYS_FUNC_MMAP 10 #define TOARU_SYS_FUNC_THREADNAME 11 -#define TOARU_SYS_FUNC_DEBUGPRINT 12 #define TOARU_SYS_FUNC_SETVGACURSOR 13 #define TOARU_SYS_FUNC_SETGSBASE 14 diff --git a/kernel/sys/syscall.c b/kernel/sys/syscall.c index 17559963..7e1a1e13 100644 --- a/kernel/sys/syscall.c +++ b/kernel/sys/syscall.c @@ -57,30 +57,35 @@ static long sys_sysfunc(long fn, char ** args) { /* FIXME: Most of these should be top-level, many are hacks/broken in Misaka */ switch (fn) { case TOARU_SYS_FUNC_SYNC: - /* FIXME: There is no sync ability in the VFS at the moment. */ + /* FIXME: There is no sync ability in the VFS at the moment. + * XXX: Should this just be an ioctl on individual devices? + * Or possibly even an ioctl we can send to arbitrary files? */ printf("sync: not implemented\n"); return -EINVAL; + case TOARU_SYS_FUNC_LOGHERE: - /* FIXME: Needs to redirect kprintf to the argument */ + /* FIXME: The entire kernel logging system needs to be revamped as + * Misaka switched everything to raw printfs, and then also + * removed most of them for cleanliness... first task would + * be to reintroduce kernel fprintf() to printf to fs_nodes. */ printf("loghere: not implemented\n"); return -EINVAL; - case TOARU_SYS_FUNC_SETFDS: - /* XXX Unused */ - printf("setfds: not implemented\n"); - return -EINVAL; - case TOARU_SYS_FUNC_WRITESDB: - /* XXX Unused */ - printf("writesdb: not implemented\n"); - return -EINVAL; + case TOARU_SYS_FUNC_KDEBUG: - /* FIXME: Starts kernel debugger as a child task of this process */ + /* FIXME: The kernel debugger is completely deprecated and fully removed + * in Misaka, and I'm not sure I want to add it back... */ printf("kdebug: not implemented\n"); return -EINVAL; + case TOARU_SYS_FUNC_INSMOD: - /* FIXME: Load module */ + /* Linux has init_module as a system call? */ return elf_module(args[0]); - /* Begin unpriv */ + case TOARU_SYS_FUNC_SETHEAP: { + /* I'm not really sure how this should be done... + * traditional brk() would be expected to map everything in-between, + * but we use this to move the heap in ld.so, and we don't want + * the stuff in the middle to be mapped necessarily... */ volatile process_t * volatile proc = this_core->current_process; if (proc->group != 0) proc = process_from_pid(proc->group); spin_lock(proc->image.lock); @@ -88,8 +93,11 @@ static long sys_sysfunc(long fn, char ** args) { spin_unlock(proc->image.lock); return 0; } + case TOARU_SYS_FUNC_MMAP: { - /* FIXME: This whole thing should be removed, tbh */ + /* FIXME: This whole thing should be removed; we need a proper mmap interface, + * preferrably with all of the file mapping options, too. And it should + * probably also interact with the SHM subsystem... */ volatile process_t * volatile proc = this_core->current_process; if (proc->group != 0) proc = process_from_pid(proc->group); spin_lock(proc->image.lock); @@ -104,6 +112,7 @@ static long sys_sysfunc(long fn, char ** args) { spin_unlock(proc->image.lock); return 0; } + case TOARU_SYS_FUNC_THREADNAME: { /* This should probably be moved to a new system call. */ int count = 0; @@ -123,23 +132,14 @@ static long sys_sysfunc(long fn, char ** args) { this_core->current_process->cmdline[i] = NULL; return 0; } - case TOARU_SYS_FUNC_DEBUGPRINT: - /* XXX I think _xlog uses this? */ - printf("debugprint: not implemented\n"); - return -EINVAL; - case TOARU_SYS_FUNC_SETVGACURSOR: - /* XXX This should be a device driver, along with the text-mode window... */ - printf("setvgacursor: not implemented\n"); - return -EINVAL; + case TOARU_SYS_FUNC_SETGSBASE: + /* This should be a new system call; see what Linux, et al., call it. */ PTR_VALIDATE(args); this_core->current_process->thread.context.tls_base = (uintptr_t)args[0]; arch_set_tls_base(this_core->current_process->thread.context.tls_base); return 0; - case 99: - arch_wakeup_others(); - return 0; default: printf("Bad system function: %ld\n", fn); return -EINVAL; diff --git a/libc/stdio/stdio.c b/libc/stdio/stdio.c index 54758d90..0f31399a 100644 --- a/libc/stdio/stdio.c +++ b/libc/stdio/stdio.c @@ -6,8 +6,6 @@ #include #include -#include <_xlog.h> - struct _FILE { int fd;