mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
arch_ctl syscall
it controls architecture specific things such as the GSBASE in x86_64
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#include <kernel/syscalls.h>
|
||||
#include <arch/msr.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define ARCH_CTL_GSBASE 0
|
||||
|
||||
|
||||
syscallret syscall_arch_ctl(int func, void* arg){
|
||||
|
||||
syscallret retv;
|
||||
|
||||
retv.errno = 0;
|
||||
retv.ret = 0;
|
||||
|
||||
switch(func){
|
||||
case ARCH_CTL_GSBASE:
|
||||
wrmsr(MSR_KERNELGSBASE, (uint64_t)arg);
|
||||
break;
|
||||
default:
|
||||
retv.errno = EINVAL;
|
||||
|
||||
}
|
||||
|
||||
if(retv.errno)
|
||||
retv.ret = -1;
|
||||
|
||||
return retv;
|
||||
|
||||
}
|
||||
@@ -3,12 +3,14 @@ section .rodata
|
||||
|
||||
extern syscall_libc_log
|
||||
extern syscall_mmap
|
||||
func_count equ 2
|
||||
extern syscall_arch_ctl
|
||||
func_count equ 3
|
||||
|
||||
|
||||
func_table:
|
||||
dq syscall_libc_log
|
||||
dq syscall_mmap
|
||||
dq syscall_arch_ctl
|
||||
section .text
|
||||
global asm_syscall_entry
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#ifndef _SYSCALLS_H_INCLUDE
|
||||
#define _SYSCALLS_H_INCLUDE
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef struct {
|
||||
long ret;
|
||||
long errno;
|
||||
|
||||
Reference in New Issue
Block a user