1 #include <lunaix/types.h>
2 #include <lunaix/block.h>
3 #include <lunaix/boot_generic.h>
4 #include <lunaix/device.h>
5 #include <lunaix/foptions.h>
6 #include <lunaix/fs/twifs.h>
7 #include <lunaix/input.h>
8 #include <lunaix/mm/cake.h>
9 #include <lunaix/mm/mmio.h>
10 #include <lunaix/mm/pmm.h>
11 #include <lunaix/mm/valloc.h>
12 #include <lunaix/mm/vmm.h>
13 #include <lunaix/process.h>
14 #include <lunaix/sched.h>
15 #include <lunaix/spike.h>
16 #include <lunaix/trace.h>
17 #include <lunaix/tty/tty.h>
18 #include <lunaix/owloysius.h>
19 #include <lunaix/hart_state.h>
21 #include <hal/acpi/acpi.h>
24 #include <sys/mm/mm_defs.h>
26 #include <klibc/strfmt.h>
27 #include <klibc/string.h>
33 kmem_init(struct boot_handoff* bhctx);
36 kernel_bootstrap(struct boot_handoff* bhctx)
41 // now we can start reserving physical space
43 /* Begin kernel bootstrapping sequence */
46 /* Setup kernel memory layout and services */
49 boot_parse_cmdline(bhctx);
51 /* Prepare stack trace environment */
52 trace_modksyms_init(bhctx);
54 device_scan_drivers();
56 device_sysconf_load();
58 invoke_init_function(on_earlyboot);
64 TODO autoload these init function that do not have dependency between
68 /* Let's get fs online as soon as possible, as things rely on them */
77 /* the bare metal are now happy, let's get software over with */
79 must_success(vfs_mount_root("ramfs", NULL));
80 must_success(vfs_mount("/dev", "devfs", NULL, 0));
82 invoke_init_function(on_boot);
84 must_success(vfs_unmount("/dev"));
86 /* Finish up bootstrapping sequence, we are ready to spawn the root process
87 * and start geting into uspace
98 * @brief 创建并运行Lunaix守护进程
105 struct thread* kthread;
107 has_error = spawn_process(&kthread, (ptr_t)lunad_main, false);
108 assert_msg(!has_error, "failed to spawn lunad");
112 fail("Unexpected Return");
116 kmem_init(struct boot_handoff* bhctx)
118 pte_t* ptep = mkptep_va(VMS_SELF, KERNEL_RESIDENT);
120 ptep = mkl0tep(ptep);
122 unsigned int i = ptep_vfn(ptep);
124 if (l0tep_impile_vmnts(ptep)) {
130 assert(mkl1t(ptep++, 0, KERNEL_DATA));
132 assert(mkl2t(ptep++, 0, KERNEL_DATA));
134 assert(mkl3t(ptep++, 0, KERNEL_DATA));
136 assert(mklft(ptep++, 0, KERNEL_DATA));
138 } while (++i < MAX_PTEN);