#include <lunaix/mm/page.h>
#include <lunaix/mm/pagetable.h>
-
-extern unsigned int __kexec_end[];
+#include <lunaix/sections.h>
void
pmm_arch_init_pool(struct pmem* memory)
ptr_t
pmm_arch_init_remap(struct pmem* memory, struct boot_handoff* bctx)
{
- size_t ppfn_total = pfn(bctx->mem.size) + 1;
+ size_t ppfn_total = pfn(bctx->mem.size);
size_t pool_size = ppfn_total * sizeof(struct ppage);
size_t i = 0;
struct boot_mmapent* ent;
- for (; i < bctx->mem.mmap_len; i++) {
- ent = &bctx->mem.mmap[i];
+
+restart:;
+ while (i < bctx->mem.mmap_len) {
+ ent = &bctx->mem.mmap[i++];
if (free_memregion(ent) && ent->size > pool_size) {
goto found;
}
return 0;
found:;
- ptr_t kexec_end = to_kphysical(__kexec_end);
+ ptr_t kexec_end = to_kphysical(kernel_start);
ptr_t aligned_pplist = MAX(ent->start, kexec_end);
#ifdef CONFIG_ARCH_X86_64
#endif
if (aligned_pplist + pool_size > ent->start + ent->size) {
- return 0;
+ goto restart;
}
// for x86_32, the upper bound of memory requirement for pplist