mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
Kernel/riscv64: Implement the signal trampoline
This commit is contained in:
parent
66f8d0f031
commit
496a7541a2
Notes:
sideshowbarker
2024-07-17 23:07:41 +09:00
Author: https://github.com/spholz Commit: https://github.com/SerenityOS/serenity/commit/496a7541a2 Pull-request: https://github.com/SerenityOS/serenity/pull/23515 Reviewed-by: https://github.com/ADKaster ✅
1 changed files with 20 additions and 2 deletions
|
@ -458,13 +458,31 @@ void signal_trampoline_dummy()
|
|||
"asm_signal_trampoline_end: \n" ::[sigreturn_syscall_number] "i"(Syscall::SC_sigreturn),
|
||||
[offset_to_first_register_slot] "i"(offset_to_first_register_slot));
|
||||
#elif ARCH(RISCV64)
|
||||
constexpr static auto offset_to_a0_slot = align_up_to(sizeof(__ucontext) + sizeof(siginfo) + sizeof(FPUState) + 3 * sizeof(FlatPtr), 16);
|
||||
constexpr static auto offset_to_a0_slot = sizeof(__ucontext) + sizeof(siginfo) + sizeof(FPUState) + 4 * sizeof(FlatPtr);
|
||||
asm(
|
||||
".global asm_signal_trampoline\n"
|
||||
"asm_signal_trampoline:\n"
|
||||
// stack state: 0, ucontext, signal_info (alignment = 16), fpu_state (alignment = 16), ucontext*, siginfo*, signal, handler
|
||||
|
||||
// FIXME: Implement this
|
||||
// Load the handler address into t0.
|
||||
"ld t0, 0(sp)\n"
|
||||
// Store a0 (return value from a syscall) into the register slot, such that we can return the correct value in sys$sigreturn.
|
||||
"sd a0, %[offset_to_first_register_slot](sp)\n"
|
||||
// Load the signal number into the first argument.
|
||||
"ld a0, 8(sp)\n"
|
||||
// Load a pointer to the signal_info structure into the second argument.
|
||||
"ld a1, 16(sp)\n"
|
||||
// Load a pointer to the ucontext into the third argument.
|
||||
"ld a2, 24(sp)\n"
|
||||
// Pop the values off the stack.
|
||||
"addi sp, sp, 32\n"
|
||||
// Call the signal handler.
|
||||
"jalr t0\n"
|
||||
|
||||
// Call sys$sigreturn.
|
||||
"li a7, %[sigreturn_syscall_number]\n"
|
||||
"ecall\n"
|
||||
// We should never return, so trap if we do return.
|
||||
"unimp\n"
|
||||
|
||||
"\n"
|
||||
|
|
Loading…
Reference in a new issue