1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 22:48:11 +00:00

Kernel+LibC: Implement pthread_create for AArch64

Instead of storing x86_64 register names in `SC_create_thread_params`,
let the Kernel figure out how to pass the parameters to
`pthread_create_helper`.
This commit is contained in:
Daniel Bertalan 2023-04-22 16:29:17 +02:00 committed by Andreas Kling
parent 9b9cc76b1d
commit d205814da6
3 changed files with 20 additions and 22 deletions

View file

@ -63,10 +63,21 @@ ErrorOr<FlatPtr> Process::sys$create_thread(void* (*entry)(void*), Userspace<Sys
regs.set_flags(0x0202);
regs.cr3 = address_space().with([](auto& space) { return space->page_directory().cr3(); });
regs.rdi = params.rdi;
regs.rsi = params.rsi;
regs.rdx = params.rdx;
regs.rcx = params.rcx;
// Set up the argument registers expected by pthread_create_helper.
regs.rdi = (FlatPtr)params.entry;
regs.rsi = (FlatPtr)params.entry_argument;
regs.rdx = (FlatPtr)params.stack_location;
regs.rcx = (FlatPtr)params.stack_size;
#elif ARCH(AARCH64)
regs.ttbr0_el1 = address_space().with([](auto& space) { return space->page_directory().ttbr0(); });
// Set up the argument registers expected by pthread_create_helper.
regs.x[0] = (FlatPtr)params.entry;
regs.x[1] = (FlatPtr)params.entry_argument;
regs.x[2] = (FlatPtr)params.stack_location;
regs.x[3] = (FlatPtr)params.stack_size;
#else
# error Unknown architecture
#endif
TRY(thread->make_thread_specific_region({}));