1 #include <lunaix/boot_generic.h>
2 #include <lunaix/exec.h>
3 #include <lunaix/foptions.h>
5 #include <lunaix/fs/probe_boot.h>
6 #include <lunaix/fs/twifs.h>
7 #include <lunaix/spike.h>
8 #include <lunaix/syslog.h>
9 #include <lunaix/types.h>
10 #include <lunaix/owloysius.h>
11 #include <lunaix/sched.h>
12 #include <lunaix/kpreempt.h>
14 #include <klibc/string.h>
24 struct v_dnode* dnode;
26 struct device* dev = probe_boot_medium();
28 ERROR("fail to acquire device. (%d)", errno);
32 if ((errno = vfs_mount("/mnt/lunaix-os", "iso9660", dev, 0))) {
33 ERROR("fail to mount boot medium. (%d)", errno);
45 if ((errno = exec_kexecve("/mnt/lunaix-os/usr/bin/init", NULL, NULL))) {
49 fail("should not reach");
52 ERROR("fail to load initd. (%d)", errno);
58 // No, these are not preemptive
59 cpu_disable_interrupt();
61 if (!mount_bootmedium() || !exec_initd()) {
62 fail("failed to initd");
67 * @brief LunaixOS的内核进程,该进程永远为可执行。
69 * 这主要是为了保证调度器在没有进程可调度时依然有事可做。
71 * 同时,该进程也负责fork出我们的init进程。
77 spawn_kthread((ptr_t)init_platform);
80 NOTE Kernel preemption after this point.
82 More specifically, it is not a real kernel preemption (as in preemption
83 happened at any point of kernel, except those marked explicitly).
84 In Lunaix, things are designed in an non-preemptive fashion, we implement
85 kernel preemption the other way around: only selected kernel functions which,
86 of course, with great care of preemptive assumption, will goes into kernel
87 thread (which is preemptive!)
90 cpu_enable_interrupt();
93 cleanup_detached_threads();
101 device_postboot_load();
102 invoke_init_function(on_postboot);
104 twifs_register_plugins();
106 // FIXME Re-design needed!!
109 assert(!spawn_process(NULL, (ptr_t)lunad_do_usr, true));