mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-28 13:18:22 +00:00
kernel: archctl syscall
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#include <kernel/syscalls.h>
|
||||
#include <arch/msr.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define ARCH_CTL_GSBASE 0
|
||||
#define ARCH_CTL_FSBASE 1
|
||||
|
||||
syscallret_t syscall_archctl(context_t *context, int func, void *arg) {
|
||||
syscallret_t ret = {
|
||||
.errno = 0,
|
||||
.ret = 0
|
||||
};
|
||||
|
||||
switch (func) {
|
||||
case ARCH_CTL_GSBASE:
|
||||
// kernelgsbase because it will be switched out to user
|
||||
wrmsr(MSR_KERNELGSBASE, (uint64_t)arg);
|
||||
break;
|
||||
case ARCH_CTL_FSBASE:
|
||||
wrmsr(MSR_FSBASE, (uint64_t)arg);
|
||||
break;
|
||||
default:
|
||||
ret.errno = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -5,6 +5,7 @@ extern syscall_openat
|
||||
extern syscall_read
|
||||
extern syscall_seek
|
||||
extern syscall_close
|
||||
extern syscall_archctl
|
||||
syscalltab:
|
||||
dq syscall_print
|
||||
dq syscall_mmap
|
||||
@@ -12,7 +13,8 @@ dq syscall_openat
|
||||
dq syscall_read
|
||||
dq syscall_seek
|
||||
dq syscall_close
|
||||
syscallcount equ 6
|
||||
dq syscall_archctl
|
||||
syscallcount equ 7
|
||||
section .text
|
||||
global arch_syscall_entry
|
||||
; on entry:
|
||||
|
||||
Reference in New Issue
Block a user