mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-30 14:08:21 +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_libc_log
|
||||||
extern syscall_mmap
|
extern syscall_mmap
|
||||||
func_count equ 2
|
extern syscall_arch_ctl
|
||||||
|
func_count equ 3
|
||||||
|
|
||||||
|
|
||||||
func_table:
|
func_table:
|
||||||
dq syscall_libc_log
|
dq syscall_libc_log
|
||||||
dq syscall_mmap
|
dq syscall_mmap
|
||||||
|
dq syscall_arch_ctl
|
||||||
section .text
|
section .text
|
||||||
global asm_syscall_entry
|
global asm_syscall_entry
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
#ifndef _SYSCALLS_H_INCLUDE
|
#ifndef _SYSCALLS_H_INCLUDE
|
||||||
#define _SYSCALLS_H_INCLUDE
|
#define _SYSCALLS_H_INCLUDE
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
long ret;
|
long ret;
|
||||||
long errno;
|
long errno;
|
||||||
|
|||||||
Reference in New Issue
Block a user