misc: cleanup

This commit is contained in:
K. Lange 2021-06-04 20:38:27 +09:00
parent 413d22f6f2
commit 1b8d5b5d32
4 changed files with 25 additions and 44 deletions

View File

@ -1,14 +0,0 @@
#include <stdint.h>
#include <stddef.h>
#include <sys/sysfunc.h>
#define _XLOG(_msg) do { \
char * msg[] = { \
__FILE__, \
(char*)__LINE__, \
(char*)2, \
_msg, \
}; \
sysfunc(TOARU_SYS_FUNC_DEBUGPRINT, msg); \
} while (0);

View File

@ -12,8 +12,6 @@
/* Privileged */ /* Privileged */
#define TOARU_SYS_FUNC_SYNC 3 #define TOARU_SYS_FUNC_SYNC 3
#define TOARU_SYS_FUNC_LOGHERE 4 #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_KDEBUG 7
#define TOARU_SYS_FUNC_INSMOD 8 #define TOARU_SYS_FUNC_INSMOD 8
@ -21,7 +19,6 @@
#define TOARU_SYS_FUNC_SETHEAP 9 #define TOARU_SYS_FUNC_SETHEAP 9
#define TOARU_SYS_FUNC_MMAP 10 #define TOARU_SYS_FUNC_MMAP 10
#define TOARU_SYS_FUNC_THREADNAME 11 #define TOARU_SYS_FUNC_THREADNAME 11
#define TOARU_SYS_FUNC_DEBUGPRINT 12
#define TOARU_SYS_FUNC_SETVGACURSOR 13 #define TOARU_SYS_FUNC_SETVGACURSOR 13
#define TOARU_SYS_FUNC_SETGSBASE 14 #define TOARU_SYS_FUNC_SETGSBASE 14

View File

@ -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 */ /* FIXME: Most of these should be top-level, many are hacks/broken in Misaka */
switch (fn) { switch (fn) {
case TOARU_SYS_FUNC_SYNC: 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"); printf("sync: not implemented\n");
return -EINVAL; return -EINVAL;
case TOARU_SYS_FUNC_LOGHERE: 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"); printf("loghere: not implemented\n");
return -EINVAL; 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: 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"); printf("kdebug: not implemented\n");
return -EINVAL; return -EINVAL;
case TOARU_SYS_FUNC_INSMOD: case TOARU_SYS_FUNC_INSMOD:
/* FIXME: Load module */ /* Linux has init_module as a system call? */
return elf_module(args[0]); return elf_module(args[0]);
/* Begin unpriv */
case TOARU_SYS_FUNC_SETHEAP: { 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; volatile process_t * volatile proc = this_core->current_process;
if (proc->group != 0) proc = process_from_pid(proc->group); if (proc->group != 0) proc = process_from_pid(proc->group);
spin_lock(proc->image.lock); spin_lock(proc->image.lock);
@ -88,8 +93,11 @@ static long sys_sysfunc(long fn, char ** args) {
spin_unlock(proc->image.lock); spin_unlock(proc->image.lock);
return 0; return 0;
} }
case TOARU_SYS_FUNC_MMAP: { 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; volatile process_t * volatile proc = this_core->current_process;
if (proc->group != 0) proc = process_from_pid(proc->group); if (proc->group != 0) proc = process_from_pid(proc->group);
spin_lock(proc->image.lock); spin_lock(proc->image.lock);
@ -104,6 +112,7 @@ static long sys_sysfunc(long fn, char ** args) {
spin_unlock(proc->image.lock); spin_unlock(proc->image.lock);
return 0; return 0;
} }
case TOARU_SYS_FUNC_THREADNAME: { case TOARU_SYS_FUNC_THREADNAME: {
/* This should probably be moved to a new system call. */ /* This should probably be moved to a new system call. */
int count = 0; int count = 0;
@ -123,23 +132,14 @@ static long sys_sysfunc(long fn, char ** args) {
this_core->current_process->cmdline[i] = NULL; this_core->current_process->cmdline[i] = NULL;
return 0; 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: case TOARU_SYS_FUNC_SETGSBASE:
/* This should be a new system call; see what Linux, et al., call it. */
PTR_VALIDATE(args); PTR_VALIDATE(args);
this_core->current_process->thread.context.tls_base = (uintptr_t)args[0]; this_core->current_process->thread.context.tls_base = (uintptr_t)args[0];
arch_set_tls_base(this_core->current_process->thread.context.tls_base); arch_set_tls_base(this_core->current_process->thread.context.tls_base);
return 0; return 0;
case 99:
arch_wakeup_others();
return 0;
default: default:
printf("Bad system function: %ld\n", fn); printf("Bad system function: %ld\n", fn);
return -EINVAL; return -EINVAL;

View File

@ -6,8 +6,6 @@
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <_xlog.h>
struct _FILE { struct _FILE {
int fd; int fd;