kernel: Run the init function in a separate block to free everything before kernel_exit is called
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
826be882a9
commit
917203ef11
@ -33,38 +33,40 @@ void reap_thread()
|
||||
|
||||
[[noreturn]] void init()
|
||||
{
|
||||
kinfoln("Starting Moon %s %s", MOON_VERSION, MOON_RELEASE);
|
||||
{
|
||||
kinfoln("Starting Moon %s %s", MOON_VERSION, MOON_RELEASE);
|
||||
|
||||
// Default hostname if nobody from userspace changes it
|
||||
set_host_name("moon"_sv);
|
||||
// Default hostname if nobody from userspace changes it
|
||||
set_host_name("moon"_sv);
|
||||
|
||||
kinfoln("Current platform: %s", CPU::platform_string().chars());
|
||||
kinfoln("Current processor: %s", CPU::identify().value_or("(unknown)"_sv).chars());
|
||||
kinfoln("Current platform: %s", CPU::platform_string().chars());
|
||||
kinfoln("Current processor: %s", CPU::identify().value_or("(unknown)"_sv).chars());
|
||||
|
||||
auto root = mark_critical(TmpFS::FileSystem::create(), "Failed to create initial ramfs");
|
||||
mark_critical(VFS::mount_root(root), "Failed to mount the initial ramfs as the root filesystem");
|
||||
mark_critical(InitRD::populate_vfs(), "Failed to load files from the initial ramdisk");
|
||||
mark_critical(DeviceRegistry::init(), "Failed to register initial devices");
|
||||
auto root = mark_critical(TmpFS::FileSystem::create(), "Failed to create initial ramfs");
|
||||
mark_critical(VFS::mount_root(root), "Failed to mount the initial ramfs as the root filesystem");
|
||||
mark_critical(InitRD::populate_vfs(), "Failed to load files from the initial ramdisk");
|
||||
mark_critical(DeviceRegistry::init(), "Failed to register initial devices");
|
||||
|
||||
mark_critical(BinaryFormat::init(), "Failed to register initial binary formats");
|
||||
mark_critical(BinaryFormat::init(), "Failed to register initial binary formats");
|
||||
|
||||
auto init =
|
||||
mark_critical(VFS::resolve_path("/bin/preinit", Credentials {}), "Can't find init in the initial ramfs!");
|
||||
auto init_thread =
|
||||
mark_critical(Scheduler::new_userspace_thread(init, "/bin/preinit"), "Failed to create PID 1 process for init");
|
||||
auto init =
|
||||
mark_critical(VFS::resolve_path("/bin/preinit", Credentials {}), "Can't find init in the initial ramfs!");
|
||||
auto init_thread = mark_critical(Scheduler::new_userspace_thread(init, "/bin/preinit"),
|
||||
"Failed to create PID 1 process for init");
|
||||
|
||||
auto reap = mark_critical(Scheduler::new_kernel_thread(reap_thread, "[reap]"),
|
||||
"Failed to create the process reaper kernel thread");
|
||||
Scheduler::set_reap_thread(reap);
|
||||
auto reap = mark_critical(Scheduler::new_kernel_thread(reap_thread, "[reap]"),
|
||||
"Failed to create the process reaper kernel thread");
|
||||
Scheduler::set_reap_thread(reap);
|
||||
|
||||
#ifdef ARCH_X86_64
|
||||
ATA::Controller::scan();
|
||||
ATA::Controller::scan();
|
||||
#endif
|
||||
|
||||
// Disable console logging before transferring control to userspace.
|
||||
setup_log(log_debug_enabled(), log_serial_enabled(), false);
|
||||
// Disable console logging before transferring control to userspace.
|
||||
setup_log(log_debug_enabled(), log_serial_enabled(), false);
|
||||
|
||||
init_thread->wake_up();
|
||||
init_thread->wake_up();
|
||||
}
|
||||
|
||||
kernel_exit();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user