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

Kernel: Move ThreadRegisters into arch-specific directory

These are architecture-specific anyway, so they belong in the Arch
directory. This commit also adds ThreadRegisters::set_initial_state to
factor out the logic in Thread.cpp.
This commit is contained in:
Timon Kruiper 2022-12-27 14:04:07 +01:00 committed by Andrew Kaster
parent 0d2dffb95b
commit a3cbaa3449
6 changed files with 133 additions and 75 deletions

View file

@ -55,15 +55,17 @@ ErrorOr<FlatPtr> Process::sys$create_thread(void* (*entry)(void*), Userspace<Sys
auto& regs = thread->regs();
regs.set_ip((FlatPtr)entry);
regs.set_flags(0x0202);
regs.set_sp(user_sp.value());
#if ARCH(X86_64)
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;
#endif
regs.cr3 = address_space().with([](auto& space) { return space->page_directory().cr3(); });
TRY(thread->make_thread_specific_region({}));