Files
opencoreC/kernel/asm/syscall_entry.S
T
RarDog eed05c1eca feat(boot+shell): add bootable disk image, unified scheduler and interactive user-space shell
- Implement Limine v8 boot protocol requests in dedicated PT_LOAD RW segment
- Configure IOPL=3 and SSE in arch setup for Ring 3 drivers and libc
- Unify scheduler context switching via switch_to and preempt_tick
- Support dual-source keyboard/serial input in sys_key_read
- Add automated 'make image' and 'make run' targets for instant QEMU launch
- Complete interactive UNIX-like shell (osh) with built-in commands & ramdisk
2026-09-02 19:47:57 +03:00

73 lines
1.5 KiB
ArmAsm

/* opencoreC - Fast Syscall Entry Trampoline (x86_64) */
.global syscall_entry
.extern kernel_syscall_dispatcher
/* Per-CPU scratch: user RSP saved here on syscall entry */
.section .bss
.align 8
.global cpu0_scratch_user_rsp
cpu0_scratch_user_rsp: .quad 0
.section .text
/*
* syscall_entry:
* On entry (SYSCALL from Ring 3):
* RCX = user RIP
* R11 = user RFLAGS
* RAX = syscall number
* RDI,RSI,RDX,R10,R8,R9 = args
* RSP = user RSP
*
* Strategy:
* 1. Save user RSP into scratch area
* 2. Load kernel RSP from TSS.RSP0 via gdt.rs TSS symbol
* 3. Build SyscallRegisters on kernel stack
* 4. Dispatch to Rust handler
* 5. Restore & sysretq
*/
syscall_entry:
/* Save user RSP */
mov [rip + cpu0_scratch_user_rsp], rsp
/* Load kernel stack from TSS.rsp0.
* TSS is exported as 'TSS' from gdt.rs.
* Layout: _reserved1(u32=4 bytes), rsp0(u64=8 bytes)
* So TSS.rsp0 is at offset 4 from TSS start.
*/
lea rsp, [rip + TSS]
mov rsp, [rsp + 4]
/* Push user RIP and RFLAGS */
push rcx
push r11
/* Push syscall arguments as SyscallRegisters */
push rax
push rdi
push rsi
push rdx
push r8
push r9
push r10
mov rdi, rsp
call kernel_syscall_dispatcher
/* Restore args */
pop r10
pop r9
pop r8
pop rdx
pop rsi
pop rdi
pop rax
/* Restore user context */
pop r11
pop rcx
/* Restore user RSP */
mov rsp, [rip + cpu0_scratch_user_rsp]
sysretq