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

Kernel: Allow passing a thread argument for new kernel threads

This adds the ability to pass a pointer to kernel thread/process.
Also add the ability to use a closure as thread function, which
allows passing information to a kernel thread more easily.
This commit is contained in:
Tom 2020-11-16 20:51:34 -07:00 committed by Andreas Kling
parent 6cb640eeba
commit 6a620562cc
11 changed files with 68 additions and 24 deletions

View file

@ -86,7 +86,7 @@ u32 __stack_chk_guard;
namespace Kernel {
[[noreturn]] static void init_stage2();
[[noreturn]] static void init_stage2(void*);
static void setup_serial_debug();
// boot.S expects these functions precisely this this. We declare them here
@ -168,7 +168,7 @@ extern "C" [[noreturn]] void init()
{
RefPtr<Thread> init_stage2_thread;
Process::create_kernel_process(init_stage2_thread, "init_stage2", init_stage2);
Process::create_kernel_process(init_stage2_thread, "init_stage2", init_stage2, nullptr);
// We need to make sure we drop the reference for init_stage2_thread
// before calling into Scheduler::start, otherwise we will have a
// dangling Thread that never gets cleaned up
@ -210,7 +210,7 @@ extern "C" void init_finished(u32 cpu)
}
}
void init_stage2()
void init_stage2(void*)
{
if (APIC::initialized() && APIC::the().enabled_processor_count() > 1) {
// We can't start the APs until we have a scheduler up and running.