X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/b60166b327a9108b07e3069fa6568a451529ffd9..bdc143a7aa3f51a46eceec62b0b364599533fa21:/lunaix-os/kernel/kinit.c?ds=sidebyside diff --git a/lunaix-os/kernel/kinit.c b/lunaix-os/kernel/kinit.c index 2d911bd..24550cf 100644 --- a/lunaix-os/kernel/kinit.c +++ b/lunaix-os/kernel/kinit.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -17,13 +16,12 @@ #include #include #include -#include +#include #include -#include #include -#include +#include #include #include @@ -37,9 +35,11 @@ kmem_init(struct boot_handoff* bhctx); void kernel_bootstrap(struct boot_handoff* bhctx) { - pmm_init(bhctx->mem.size); vmm_init(); + pmm_init(bhctx); + // now we can start reserving physical space + /* Begin kernel bootstrapping sequence */ boot_begin(bhctx); @@ -53,16 +53,9 @@ kernel_bootstrap(struct boot_handoff* bhctx) device_scan_drivers(); - invoke_init_function(on_earlyboot); - - // FIXME this goes to hal/gfxa - tty_init(ioremap(0xB8000, PG_SIZE)); - tty_set_theme(VGA_COLOR_WHITE, VGA_COLOR_BLACK); - device_sysconf_load(); - /* Get intc online, this is the cornerstone when initing devices */ - intc_init(); + invoke_init_function(on_earlyboot); clock_init(); timer_init(); @@ -122,15 +115,27 @@ spawn_lunad() void kmem_init(struct boot_handoff* bhctx) { - extern u8_t __kexec_end; - // 将内核占据的页,包括前1MB,hhk_init 设为已占用 - size_t pg_count = ((ptr_t)&__kexec_end - KERNEL_EXEC) >> PG_SIZE_BITS; - pmm_mark_chunk_occupied(0, pg_count, PP_FGLOCKED); - - // reserve higher half - for (size_t i = L1_INDEX(KERNEL_EXEC); i < 1023; i++) { - assert(vmm_set_mapping(VMS_SELF, i << 22, 0, 0, VMAP_NOMAP)); - } + pte_t* ptep = mkptep_va(VMS_SELF, KERNEL_RESIDENT); + + ptep = mkl0tep(ptep); + + unsigned int i = ptep_vfn(ptep); + do { + if (l0tep_impile_vmnts(ptep)) { + ptep++; + continue; + } + +#if LnT_ENABLED(1) + assert(mkl1t(ptep++, 0, KERNEL_DATA)); +#elif LnT_ENABLED(2) + assert(mkl2t(ptep++, 0, KERNEL_DATA)); +#elif LnT_ENABLED(3) + assert(mkl3t(ptep++, 0, KERNEL_DATA)); +#else + assert(mklft(ptep++, 0, KERNEL_DATA)); +#endif + } while (++i < MAX_PTEN); // allocators cake_init();