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);
44 const char* argv[] = { "/mnt/lunaix-os/usr/bin/init", 0 };
45 const char* envp[] = { 0 };
47 if ((errno = exec_kexecve(argv[0], argv, envp))) {
51 fail("should not reach");
54 ERROR("fail to load initd. (%d)", errno);
60 // No, these are not preemptive
63 if (!mount_bootmedium() || !exec_initd()) {
64 fail("failed to initd");
69 * @brief LunaixOS的内核进程,该进程永远为可执行。
71 * 这主要是为了保证调度器在没有进程可调度时依然有事可做。
73 * 同时,该进程也负责fork出我们的init进程。
79 spawn_kthread((ptr_t)init_platform);
82 NOTE Kernel preemption after this point.
84 More specifically, it is not a real kernel preemption (as in preemption
85 happened at any point of kernel, except those marked explicitly).
86 In Lunaix, things are designed in an non-preemptive fashion, we implement
87 kernel preemption the other way around: only selected kernel functions which,
88 of course, with great care of preemptive assumption, will goes into kernel
89 thread (which is preemptive!)
95 cleanup_detached_threads();
103 device_postboot_load();
104 invoke_init_function(on_postboot);
106 twifs_register_plugins();
108 // FIXME Re-design needed!!
111 assert(!spawn_process(NULL, (ptr_t)lunad_do_usr, true));