mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 07:24:37 +00:00
Added syscalls stub
This commit is contained in:
parent
127476ac64
commit
a2da69d777
14
Architecture/aarch64/SystemCalls.cpp
Normal file
14
Architecture/aarch64/SystemCalls.cpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include <syscalls.hpp>
|
||||||
|
|
||||||
|
#include <cpu.hpp>
|
||||||
|
|
||||||
|
extern "C" __attribute__((naked, used, no_stack_protector)) void SystemCallHandlerStub()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" uint64_t SystemCallsHandler(SyscallsRegs *regs);
|
||||||
|
|
||||||
|
void InitializeSystemCalls()
|
||||||
|
{
|
||||||
|
}
|
23
Architecture/amd64/SystemCalls.cpp
Normal file
23
Architecture/amd64/SystemCalls.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include <syscalls.hpp>
|
||||||
|
|
||||||
|
#include <cpu.hpp>
|
||||||
|
|
||||||
|
#include "cpu/gdt.hpp"
|
||||||
|
|
||||||
|
using namespace CPU::x64;
|
||||||
|
|
||||||
|
extern "C" __attribute__((naked, used, no_stack_protector)) void SystemCallHandlerStub()
|
||||||
|
{
|
||||||
|
asmv(".loop\n"
|
||||||
|
"jmp .loop\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" uint64_t SystemCallsHandler(SyscallsRegs *regs);
|
||||||
|
|
||||||
|
void InitializeSystemCalls()
|
||||||
|
{
|
||||||
|
wrmsr(MSR_EFER, rdmsr(MSR_EFER) | 1);
|
||||||
|
wrmsr(MSR_STAR, ((uint64_t)(GDT_KERNEL_CODE) << 32) | ((uint64_t)(GDT_KERNEL_DATA | 3) << 48));
|
||||||
|
wrmsr(MSR_LSTAR, (uint64_t)SystemCallsHandler);
|
||||||
|
wrmsr(MSR_SYSCALL_MASK, 0);
|
||||||
|
}
|
13
Architecture/i686/SystemCalls.cpp
Normal file
13
Architecture/i686/SystemCalls.cpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <syscalls.hpp>
|
||||||
|
|
||||||
|
#include <cpu.hpp>
|
||||||
|
|
||||||
|
#include "cpu/gdt.hpp"
|
||||||
|
|
||||||
|
using namespace CPU::x32;
|
||||||
|
|
||||||
|
extern "C" uint32_t SystemCallsHandler(SyscallsRegs *regs);
|
||||||
|
|
||||||
|
void InitializeSystemCalls()
|
||||||
|
{
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
#include <interrupts.hpp>
|
#include <interrupts.hpp>
|
||||||
|
|
||||||
|
#include <syscalls.hpp>
|
||||||
|
|
||||||
#if defined(__amd64__)
|
#if defined(__amd64__)
|
||||||
#include "../Architecture/amd64/cpu/gdt.hpp"
|
#include "../Architecture/amd64/cpu/gdt.hpp"
|
||||||
#include "../Architecture/amd64/cpu/idt.hpp"
|
#include "../Architecture/amd64/cpu/idt.hpp"
|
||||||
@ -26,6 +28,7 @@ namespace Interrupts
|
|||||||
#if defined(__amd64__)
|
#if defined(__amd64__)
|
||||||
GlobalDescriptorTable::Init(0);
|
GlobalDescriptorTable::Init(0);
|
||||||
InterruptDescriptorTable::Init(0);
|
InterruptDescriptorTable::Init(0);
|
||||||
|
InitializeSystemCalls();
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
#endif
|
#endif
|
||||||
|
15
Core/SystemCalls.cpp
Normal file
15
Core/SystemCalls.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include <syscalls.hpp>
|
||||||
|
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
extern "C" uint64_t SystemCallsHandler(SyscallsRegs *regs)
|
||||||
|
{
|
||||||
|
#if defined(__amd64__)
|
||||||
|
fixme("System call %ld", regs->rax);
|
||||||
|
#elif defined(__i386__)
|
||||||
|
fixme("System call %ld", regs->eax);
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
fixme("System call");
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
@ -1007,7 +1007,7 @@ namespace CPU
|
|||||||
uint64_t raw;
|
uint64_t raw;
|
||||||
} RFLAGS;
|
} RFLAGS;
|
||||||
|
|
||||||
typedef struct _TrapFrame
|
typedef struct TrapFrame
|
||||||
{
|
{
|
||||||
// uint64_t gs; // General-purpose Segment
|
// uint64_t gs; // General-purpose Segment
|
||||||
// uint64_t fs; // General-purpose Segment
|
// uint64_t fs; // General-purpose Segment
|
||||||
|
25
include/syscalls.hpp
Normal file
25
include/syscalls.hpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef __FENNIX_KERNEL_SYSCALLS_H__
|
||||||
|
#define __FENNIX_KERNEL_SYSCALLS_H__
|
||||||
|
|
||||||
|
#include <types.h>
|
||||||
|
|
||||||
|
typedef struct SyscallsRegs
|
||||||
|
{
|
||||||
|
#if defined(__amd64__)
|
||||||
|
uint64_t r15, r14, r13, r12, r11, r10, r9, r8;
|
||||||
|
uint64_t rbp, rdi, rsi, rdx, rcx, rbx, rax;
|
||||||
|
uint64_t int_num, error_code, rip, cs, rflags, rsp, ss;
|
||||||
|
#elif defined(__i386__)
|
||||||
|
uint64_t r15, r14, r13, r12, r11, r10, r9, r8;
|
||||||
|
uint64_t ebp, edi, esi, edx, ecx, ebx, eax;
|
||||||
|
uint64_t int_num, error_code, eip, cs, eflags, esp, ss;
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
#endif
|
||||||
|
} SyscallsRegs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize syscalls for the current CPU. (Function is available on x32, x64 & aarch64)
|
||||||
|
*/
|
||||||
|
void InitializeSystemCalls();
|
||||||
|
|
||||||
|
#endif // !__FENNIX_KERNEL_SYSCALLS_H__
|
Loading…
x
Reference in New Issue
Block a user