mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:58:12 +00:00
Kernel: Consolidate a bunch of i386/x86_64 code paths
Add some arch-specific getters and setters that allow us to merge blocks that were previously specific to either ARCH(I386) or ARCH(X86_64).
This commit is contained in:
parent
3f5a42b3dd
commit
961f727448
6 changed files with 64 additions and 117 deletions
|
@ -195,11 +195,10 @@ RefPtr<Process> Process::create_kernel_process(RefPtr<Thread>& first_thread, Str
|
|||
auto process = Process::create(first_thread, move(name), (uid_t)0, (gid_t)0, ProcessID(0), true);
|
||||
if (!first_thread || !process)
|
||||
return {};
|
||||
first_thread->regs().set_ip((FlatPtr)entry);
|
||||
#if ARCH(I386)
|
||||
first_thread->regs().eip = (FlatPtr)entry;
|
||||
first_thread->regs().esp = FlatPtr(entry_data); // entry function argument is expected to be in regs.esp
|
||||
#else
|
||||
first_thread->regs().rip = (FlatPtr)entry;
|
||||
first_thread->regs().rdi = FlatPtr(entry_data); // entry function argument is expected to be in regs.rdi
|
||||
#endif
|
||||
|
||||
|
@ -769,13 +768,8 @@ RefPtr<Thread> Process::create_kernel_thread(void (*entry)(void*), void* entry_d
|
|||
thread->detach();
|
||||
|
||||
auto& regs = thread->regs();
|
||||
#if ARCH(I386)
|
||||
regs.eip = (FlatPtr)entry;
|
||||
regs.esp = FlatPtr(entry_data); // entry function argument is expected to be in regs.rsp
|
||||
#else
|
||||
regs.rip = (FlatPtr)entry;
|
||||
regs.rsp = FlatPtr(entry_data); // entry function argument is expected to be in regs.rsp
|
||||
#endif
|
||||
regs.set_ip((FlatPtr)entry);
|
||||
regs.set_sp((FlatPtr)entry_data); // entry function argument is expected to be in the SP register
|
||||
|
||||
ScopedSpinLock lock(g_scheduler_lock);
|
||||
thread->set_state(Thread::State::Runnable);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue