-/**
- * @brief 创建并运行init进程
- *
- */
-void spawn_lxinit() {
- struct proc_info kinit;
- uint32_t* kstack = (uint32_t*)KSTACK_TOP - 4 * 5;
-
- memset(&kinit, 0, sizeof(kinit));
- kinit.page_table = (void*) cpu_rcr3();
- kinit.parent = -1;
- kinit.pid = 1;
- kinit.intr_ctx = (isr_param) {
- .registers.esp = kstack,
- .cs = KCODE_SEG,
- .eip = (void*)_kernel_post_init,
- .ss = KDATA_SEG,
- .eflags = cpu_reflags()
- };
-
- /*
- 因为schedule从设计上是需要在中断环境中执行的
- 可是我们需要在这里手动调用 schedule,从而使我们的init能够被执行。
- 所以需要模拟中断产生时的栈里内容。
- */
- kstack[2] = kinit.intr_ctx.eip;
- kstack[3] = kinit.intr_ctx.cs;
- kstack[4] = kinit.intr_ctx.eflags;
-
- push_process(&kinit);
-
- schedule();
-}
-
-void
-_kernel_post_init() {
- assert_msg(kalloc_init(), "Fail to initialize heap");
-
- size_t hhk_init_pg_count = ((uintptr_t)(&__init_hhk_end)) >> PG_SIZE_BITS;
- kprintf(KINFO "[MM] Releaseing %d pages from 0x0.\n", hhk_init_pg_count);
-
- // Fuck it, I will no longer bother this little 1MiB
- // I just release 4 pages for my APIC & IOAPIC remappings
- for (size_t i = 0; i < 3; i++) {
- vmm_unmap_page(KERNEL_PID, (void*)(i << PG_SIZE_BITS));
- }
-
- // 锁定所有系统预留页(内存映射IO,ACPI之类的),并且进行1:1映射
- lock_reserved_memory();