git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Architectural Support: x86_64 (#37)
[lunaix-os.git]
/
lunaix-os
/
kernel
/
boot_helper.c
diff --git
a/lunaix-os/kernel/boot_helper.c
b/lunaix-os/kernel/boot_helper.c
index f7ad1584d6c2cfe2b1b84f5ab15174adbb426dbf..365295933282e151a5d79a4e5aab10b5154bfb10 100644
(file)
--- a/
lunaix-os/kernel/boot_helper.c
+++ b/
lunaix-os/kernel/boot_helper.c
@@
-6,6
+6,8
@@
#include <lunaix/kcmd.h>
#include <sys/mm/mm_defs.h>
#include <lunaix/kcmd.h>
#include <sys/mm/mm_defs.h>
+extern unsigned char __kexec_end[], __kexec_start[];
+
/**
* @brief Reserve memory for kernel bootstrapping initialization
*
/**
* @brief Reserve memory for kernel bootstrapping initialization
*
@@
-15,32
+17,30
@@
void
boot_begin(struct boot_handoff* bhctx)
{
bhctx->prepare(bhctx);
boot_begin(struct boot_handoff* bhctx)
{
bhctx->prepare(bhctx);
-
- // Identity-map the first 3GiB address spaces
- pte_t* ptep = mkl0tep(mkptep_va(VMS_SELF, 0));
- pte_t pte = mkpte_prot(KERNEL_DATA);
- size_t count = page_count(KERNEL_RESIDENT, L0T_SIZE);
- vmm_set_ptes_contig(ptep, pte_mkhuge(pte), L0T_SIZE, count);
+ boot_begin_arch_reserve(bhctx);
+
+ // 将内核占据的页,包括前1MB,hhk_init 设为已占用
+ size_t pg_count = leaf_count(to_kphysical(__kexec_end));
+ pmm_onhold_range(0, pg_count);
- struct boot_mmapent *mmap = bhctx->mem.mmap, *mmapent;
- for (size_t i = 0; i < bhctx->mem.mmap_len; i++) {
- mmapent = &mmap[i];
- size_t size_pg = leaf_count(mmapent->size);
- pfn_t start_pfn = pfn(mmapent->start);
+ size_t i;
+ struct boot_mmapent* ent;
+ for (i = 0; i < bhctx->mem.mmap_len; i++) {
+ ent = &bhctx->mem.mmap[i];
- if (
mmapent->type == BOOT_MMAP_FREE
) {
-
pmm_mark_chunk_free(start_pfn, size_pg
);
-
continue
;
+ if (
reserved_memregion(ent) || reclaimable_memregion(ent)
) {
+
unsigned int counts = leaf_count(ent->size
);
+
pmm_onhold_range(pfn(ent->start), counts)
;
}
}
/* Reserve region for all loaded modules */
}
}
/* Reserve region for all loaded modules */
- for (
size_t
i = 0; i < bhctx->mods.mods_num; i++) {
+ for (i = 0; i < bhctx->mods.mods_num; i++) {
struct boot_modent* mod = &bhctx->mods.entries[i];
unsigned int counts = leaf_count(mod->end - mod->start);
struct boot_modent* mod = &bhctx->mods.entries[i];
unsigned int counts = leaf_count(mod->end - mod->start);
- pmm_
mark_chunk_occupied(pfn(mod->start), counts, PP_FGLOCKED
);
+ pmm_
onhold_range(pfn(mod->start), counts
);
}
}
}
}
@@
-54,33
+54,19
@@
extern u8_t __kboot_end; /* link/linker.ld */
void
boot_end(struct boot_handoff* bhctx)
{
void
boot_end(struct boot_handoff* bhctx)
{
- struct boot_mmapent
*mmap = bhctx->mem.mmap, *mmap
ent;
+ struct boot_mmapent
*
ent;
for (size_t i = 0; i < bhctx->mem.mmap_len; i++) {
for (size_t i = 0; i < bhctx->mem.mmap_len; i++) {
- mmapent = &mmap[i];
- size_t size_pg = leaf_count(mmapent->size);
-
- if (mmapent->type == BOOT_MMAP_RCLM) {
- pmm_mark_chunk_free(pfn(mmapent->start), size_pg);
- }
+ ent = &bhctx->mem.mmap[i];
- if (mmapent->type == BOOT_MMAP_FREE) {
- continue;
+ if (reclaimable_memregion(ent)) {
+ unsigned int counts = leaf_count(ent->size);
+ pmm_unhold_range(pfn(ent->start), counts);
}
}
bhctx->release(bhctx);
}
}
bhctx->release(bhctx);
-}
-/**
- * @brief Clean up the boot stage code and data
- *
- */
-void
-boot_cleanup()
-{
- pte_t* ptep = mkl0tep(mkptep_va(VMS_SELF, 0));
- size_t count = page_count(KERNEL_RESIDENT, L0T_SIZE);
- vmm_unset_ptes(ptep, count);
+ boot_clean_arch_reserve(bhctx);
}
void
}
void