ptos/amd64+ke: Add system call groundwork + exit syscall

Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
2026-07-15 21:20:35 +00:00
parent d72df46f64
commit d4390c6a1b
9 changed files with 146 additions and 0 deletions
+1
View File
@@ -38,6 +38,7 @@ InitInterrupts(VOID)
MdIdtSetGate(0x0C, (UPTR)TrapStackSegmentFault, IDT_TRAP_GATE, 0);
MdIdtSetGate(0x0D, (UPTR)TrapGeneralProtection, IDT_TRAP_GATE, 0);
MdIdtSetGate(0x0E, (UPTR)TrapPageFault, IDT_TRAP_GATE, 0);
MdIdtSetGate(0x2E, (UPTR)TrapLegacySyscall, IDT_USER_GATE, 0);
MdIdtLoad();
}
+7
View File
@@ -151,3 +151,10 @@ LapicTmrIsr:
call HalContextSwitch
call MdLapicSendEoi
INTR_EXIT()
.globl TrapLegacySyscall
TrapLegacySyscall:
INTR_ENTRY($0x2C)
mov %rsp, %rdi
call MdSyscallDispatch
INTR_EXIT()
+39
View File
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause.
*
* Description: System call dispatch
* Author: Chloe M.
*/
#include <ke/syscall.h>
#include <machine/frame.h>
/*
* Dispatch incoming system calls
*
* @Frame: Trapframe snapshot
*/
VOID
MdSyscallDispatch(TRAP_FRAME *Frame)
{
SYSCALL_ARGS ScArgs;
if (Frame == NULL) {
return;
}
/* Is this system call number valid? */
if (Frame->Rax == 0 || Frame->Rax >= _SYSCALL_MAX) {
Frame->Rax = STATUS_INVALID_PARAM;
return;
}
ScArgs.Arg[0] = Frame->Rdi;
ScArgs.Arg[1] = Frame->Rsi;
ScArgs.Arg[2] = Frame->Rdx;
ScArgs.Arg[3] = Frame->Rcx;
ScArgs.Arg[4] = Frame->R8;
ScArgs.Arg[5] = Frame->R9;
SystemCallTable[Frame->Rax](&ScArgs);
}