mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
Kernel: Add stubs for missing x86_64 functionality
This adds just enough stubs to make the kernel compile on x86_64. Obviously it won't do anything useful - in fact it won't even attempt to boot because Multiboot doesn't support ELF64 binaries - but it gets those compiler errors out of the way so more progress can be made getting all the missing functionality in place.
This commit is contained in:
parent
f2eb759901
commit
38fca26f54
21 changed files with 295 additions and 40 deletions
|
@ -11,6 +11,7 @@
|
|||
#include <Kernel/Debug.h>
|
||||
#include <Kernel/FileSystem/Custody.h>
|
||||
#include <Kernel/FileSystem/FileDescription.h>
|
||||
#include <Kernel/Panic.h>
|
||||
#include <Kernel/PerformanceManager.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/Random.h>
|
||||
|
@ -635,6 +636,7 @@ KResult Process::do_exec(NonnullRefPtr<FileDescription> main_program_description
|
|||
}
|
||||
new_main_thread->reset_fpu_state();
|
||||
|
||||
#if ARCH(I386)
|
||||
auto& tss = new_main_thread->m_tss;
|
||||
tss.cs = GDT_SELECTOR_CODE3 | 3;
|
||||
tss.ds = GDT_SELECTOR_DATA3 | 3;
|
||||
|
@ -646,6 +648,10 @@ KResult Process::do_exec(NonnullRefPtr<FileDescription> main_program_description
|
|||
tss.esp = new_userspace_esp;
|
||||
tss.cr3 = space().page_directory().cr3();
|
||||
tss.ss2 = pid().value();
|
||||
#else
|
||||
(void)new_userspace_esp;
|
||||
PANIC("Process::do_exec() not implemented");
|
||||
#endif
|
||||
|
||||
{
|
||||
TemporaryChange profiling_disabler(m_profiling, was_profiling);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <Kernel/Debug.h>
|
||||
#include <Kernel/FileSystem/Custody.h>
|
||||
#include <Kernel/FileSystem/FileDescription.h>
|
||||
#include <Kernel/Panic.h>
|
||||
#include <Kernel/PerformanceManager.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/VM/Region.h>
|
||||
|
@ -43,6 +44,7 @@ KResultOr<pid_t> Process::sys$fork(RegisterState& regs)
|
|||
dbgln_if(FORK_DEBUG, "fork: child={}", child);
|
||||
child->space().set_enforces_syscall_regions(space().enforces_syscall_regions());
|
||||
|
||||
#if ARCH(I386)
|
||||
auto& child_tss = child_first_thread->m_tss;
|
||||
child_tss.eax = 0; // fork() returns 0 in the child :^)
|
||||
child_tss.ebx = regs.ebx;
|
||||
|
@ -62,6 +64,10 @@ KResultOr<pid_t> Process::sys$fork(RegisterState& regs)
|
|||
child_tss.ss = regs.userspace_ss;
|
||||
|
||||
dbgln_if(FORK_DEBUG, "fork: child will begin executing at {:04x}:{:08x} with stack {:04x}:{:08x}, kstack {:04x}:{:08x}", child_tss.cs, child_tss.eip, child_tss.ss, child_tss.esp, child_tss.ss0, child_tss.esp0);
|
||||
#else
|
||||
(void)regs;
|
||||
PANIC("Process::sys$fork() not implemented.");
|
||||
#endif
|
||||
|
||||
{
|
||||
ScopedSpinLock lock(space().get_lock());
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <Kernel/Panic.h>
|
||||
#include <Kernel/PerformanceManager.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/VM/MemoryManager.h>
|
||||
|
@ -60,11 +61,16 @@ KResultOr<int> Process::sys$create_thread(void* (*entry)(void*), Userspace<const
|
|||
if (!is_thread_joinable)
|
||||
thread->detach();
|
||||
|
||||
#if ARCH(I386)
|
||||
auto& tss = thread->tss();
|
||||
tss.eip = (FlatPtr)entry;
|
||||
tss.eflags = 0x0202;
|
||||
tss.cr3 = space().page_directory().cr3();
|
||||
tss.esp = user_esp.value();
|
||||
#else
|
||||
(void)entry;
|
||||
PANIC("Process::sys$create_thread() not implemented");
|
||||
#endif
|
||||
|
||||
auto tsr_result = thread->make_thread_specific_region({});
|
||||
if (tsr_result.is_error())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue