diff --git a/headers/private/kernel/arch/vm_translation_map.h b/headers/private/kernel/arch/vm_translation_map.h index 6971529e69..3d4383d5d0 100644 --- a/headers/private/kernel/arch/vm_translation_map.h +++ b/headers/private/kernel/arch/vm_translation_map.h @@ -25,10 +25,9 @@ status_t arch_vm_translation_map_init_post_area(struct kernel_args *args); status_t arch_vm_translation_map_init_post_sem(struct kernel_args *args); // Quick function to map a page in regardless of map context. Used in VM -// initialization before most vm data structures exist. +// initialization before most VM data structures exist. status_t arch_vm_translation_map_early_map(struct kernel_args *args, addr_t va, - phys_addr_t pa, uint8 attributes, - phys_addr_t (*get_free_page)(struct kernel_args *)); + phys_addr_t pa, uint8 attributes); bool arch_vm_translation_map_is_kernel_page_accessible(addr_t virtualAddress, uint32 protection); diff --git a/headers/private/kernel/vm/vm.h b/headers/private/kernel/vm/vm.h index 009eb6a343..73c255131b 100644 --- a/headers/private/kernel/vm/vm.h +++ b/headers/private/kernel/vm/vm.h @@ -58,8 +58,7 @@ status_t vm_init_post_thread(struct kernel_args *args); status_t vm_init_post_modules(struct kernel_args *args); void vm_free_kernel_args(struct kernel_args *args); void vm_free_unused_boot_loader_range(addr_t start, addr_t end); -page_num_t vm_allocate_early_physical_page(kernel_args *args); -page_num_t vm_allocate_early_physical_page_etc(kernel_args *args, phys_addr_t maxAddress = 0); +page_num_t vm_allocate_early_physical_page(kernel_args *args, phys_addr_t maxAddress = 0); addr_t vm_allocate_early(struct kernel_args *args, size_t virtualSize, size_t physicalSize, uint32 attributes, addr_t alignment); diff --git a/src/system/kernel/arch/arm/arch_vm_translation_map.cpp b/src/system/kernel/arch/arm/arch_vm_translation_map.cpp index 2aa644d111..3e684fa885 100644 --- a/src/system/kernel/arch/arm/arch_vm_translation_map.cpp +++ b/src/system/kernel/arch/arm/arch_vm_translation_map.cpp @@ -101,11 +101,11 @@ arch_vm_translation_map_init_post_area(kernel_args *args) status_t arch_vm_translation_map_early_map(kernel_args *args, addr_t va, phys_addr_t pa, - uint8 attributes, phys_addr_t (*get_free_page)(kernel_args *)) + uint8 attributes) { TRACE("early_tmap: entry pa 0x%lx va 0x%lx\n", pa, va); - return gARMPagingMethod->MapEarly(args, va, pa, attributes, get_free_page); + return gARMPagingMethod->MapEarly(args, va, pa, attributes); } diff --git a/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.cpp b/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.cpp index cf3cba3a4e..fbbc0a7417 100644 --- a/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.cpp +++ b/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.cpp @@ -369,8 +369,7 @@ get_free_pgtable(kernel_args* args, phys_addr_t* phys_addr, addr_t* virt_addr) status_t ARMPagingMethod32Bit::MapEarly(kernel_args* args, addr_t virtualAddress, - phys_addr_t physicalAddress, uint8 attributes, - page_num_t (*get_free_page)(kernel_args*)) + phys_addr_t physicalAddress, uint8 attributes) { // check to see if a page table exists for this range int index = VADDR_TO_PDENT(virtualAddress); diff --git a/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.h b/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.h index 5557feee3b..6ffb2ecbc8 100644 --- a/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.h +++ b/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.h @@ -33,8 +33,7 @@ public: virtual status_t MapEarly(kernel_args* args, addr_t virtualAddress, phys_addr_t physicalAddress, - uint8 attributes, - page_num_t (*get_free_page)(kernel_args*)); + uint8 attributes); virtual bool IsKernelPageAccessible(addr_t virtualAddress, uint32 protection); diff --git a/src/system/kernel/arch/arm/paging/ARMPagingMethod.h b/src/system/kernel/arch/arm/paging/ARMPagingMethod.h index 71c51c4a0b..fa75723424 100644 --- a/src/system/kernel/arch/arm/paging/ARMPagingMethod.h +++ b/src/system/kernel/arch/arm/paging/ARMPagingMethod.h @@ -31,9 +31,7 @@ public: virtual status_t MapEarly(kernel_args* args, addr_t virtualAddress, phys_addr_t physicalAddress, - uint8 attributes, - page_num_t (*get_free_page)(kernel_args*)) - = 0; + uint8 attributes) = 0; virtual bool IsKernelPageAccessible(addr_t virtualAddress, uint32 protection) = 0; diff --git a/src/system/kernel/arch/arm64/arch_vm_translation_map.cpp b/src/system/kernel/arch/arm64/arch_vm_translation_map.cpp index d0d891b798..a50e7b93c3 100644 --- a/src/system/kernel/arch/arm64/arch_vm_translation_map.cpp +++ b/src/system/kernel/arch/arm64/arch_vm_translation_map.cpp @@ -155,7 +155,7 @@ TableFromPa(phys_addr_t pa) static void map_page_early(phys_addr_t ptPa, int level, addr_t va, phys_addr_t pa, - phys_addr_t (*get_free_page)(kernel_args*), kernel_args* args) + kernel_args* args) { int tableBits = page_bits - 3; uint64_t tableMask = (1UL << tableBits) - 1; @@ -176,7 +176,7 @@ map_page_early(phys_addr_t ptPa, int level, addr_t va, phys_addr_t pa, if (type == 0x3) { table = pteVal & kPteAddrMask; } else { - table = get_free_page(args) << page_bits; + table = vm_allocate_early_physical_page(args) << page_bits; dprintf("early: pulling page %lx\n", table); uint64_t* newTableVa = TableFromPa(table); @@ -195,14 +195,13 @@ map_page_early(phys_addr_t ptPa, int level, addr_t va, phys_addr_t pa, atomic_set64((int64*) pte, table | 0x3); } - map_page_early(table, level + 1, va, pa, get_free_page, args); + map_page_early(table, level + 1, va, pa, args); } } status_t -arch_vm_translation_map_early_map(kernel_args* args, addr_t va, phys_addr_t pa, uint8 attributes, - phys_addr_t (*get_free_page)(kernel_args*)) +arch_vm_translation_map_early_map(kernel_args* args, addr_t va, phys_addr_t pa, uint8 attributes) { int va_bits = 64 - tsz; uint64_t va_mask = (1UL << va_bits) - 1; @@ -213,7 +212,7 @@ arch_vm_translation_map_early_map(kernel_args* args, addr_t va, phys_addr_t pa, va &= va_mask; pa |= VMSAv8TranslationMap::GetMemoryAttr(attributes, 0, true); - map_page_early(ptPa, level, va, pa, get_free_page, args); + map_page_early(ptPa, level, va, pa, args); return B_OK; } diff --git a/src/system/kernel/arch/m68k/arch_vm_translation_map.cpp b/src/system/kernel/arch/m68k/arch_vm_translation_map.cpp index 176f0f11a3..17d2e6183b 100644 --- a/src/system/kernel/arch/m68k/arch_vm_translation_map.cpp +++ b/src/system/kernel/arch/m68k/arch_vm_translation_map.cpp @@ -144,11 +144,11 @@ arch_vm_translation_map_init_post_area(kernel_args *args) */ status_t arch_vm_translation_map_early_map(kernel_args *args, addr_t va, phys_addr_t pa, - uint8 attributes, phys_addr_t (*get_free_page)(kernel_args *)) + uint8 attributes) { TRACE("early_tmap: entry pa 0x%lx va 0x%lx\n", pa, va); - return gM68KPagingMethod->MapEarly(args, va, pa, attributes, get_free_page); + return gM68KPagingMethod->MapEarly(args, va, pa, attributes); } diff --git a/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp b/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp index 4a39b6beda..2df56e2a02 100644 --- a/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp +++ b/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp @@ -1446,7 +1446,7 @@ m68k_vm_translation_map_init_post_area(kernel_args *args) static status_t m68k_vm_translation_map_early_map(kernel_args *args, addr_t va, addr_t pa, - uint8 attributes, addr_t (*get_free_page)(kernel_args *)) + uint8 attributes) { page_root_entry *pr = (page_root_entry *)sKernelPhysicalPageRoot; page_directory_entry *pd; @@ -1463,7 +1463,7 @@ m68k_vm_translation_map_early_map(kernel_args *args, addr_t va, addr_t pa, if (pr[index].type != DT_ROOT) { unsigned aindex = index & ~(NUM_DIRTBL_PER_PAGE-1); /* aligned */ TRACE(("missing page root entry %d ai %d\n", index, aindex)); - tbl = get_free_page(args) * B_PAGE_SIZE; + tbl = vm_allocate_early_physical_page(args) * B_PAGE_SIZE; if (!tbl) return ENOMEM; TRACE(("early_map: asked for free page for pgdir. 0x%lx\n", tbl)); @@ -1487,7 +1487,7 @@ m68k_vm_translation_map_early_map(kernel_args *args, addr_t va, addr_t pa, if (pd[index].type != DT_DIR) { unsigned aindex = index & ~(NUM_PAGETBL_PER_PAGE-1); /* aligned */ TRACE(("missing page dir entry %d ai %d\n", index, aindex)); - tbl = get_free_page(args) * B_PAGE_SIZE; + tbl = vm_allocate_early_physical_page(args) * B_PAGE_SIZE; if (!tbl) return ENOMEM; TRACE(("early_map: asked for free page for pgtable. 0x%lx\n", tbl)); diff --git a/src/system/kernel/arch/m68k/paging/040/M68KPagingMethod040.cpp b/src/system/kernel/arch/m68k/paging/040/M68KPagingMethod040.cpp index f3c735ae57..f593d73648 100644 --- a/src/system/kernel/arch/m68k/paging/040/M68KPagingMethod040.cpp +++ b/src/system/kernel/arch/m68k/paging/040/M68KPagingMethod040.cpp @@ -467,8 +467,7 @@ M68KPagingMethod040::CreateTranslationMap(bool kernel, VMTranslationMap** _map) status_t M68KPagingMethod040::MapEarly(kernel_args* args, addr_t virtualAddress, - phys_addr_t physicalAddress, uint8 attributes, - phys_addr_t (*get_free_page)(kernel_args*)) + phys_addr_t physicalAddress, uint8 attributes) { // XXX horrible back door to map a page quickly regardless of translation // map object, etc. used only during VM setup. @@ -494,7 +493,7 @@ M68KPagingMethod040::MapEarly(kernel_args* args, addr_t virtualAddress, if (PRE_TYPE(pr[index]) != DT_ROOT) { unsigned aindex = index & ~(NUM_DIRTBL_PER_PAGE-1); /* aligned */ TRACE("missing page root entry %d ai %d\n", index, aindex); - tbl = get_free_page(args) * B_PAGE_SIZE; + tbl = vm_allocate_early_physical_page(args) * B_PAGE_SIZE; if (!tbl) return ENOMEM; TRACE("040::MapEarly: asked for free page for pgdir. 0x%lx\n", tbl); @@ -518,7 +517,7 @@ M68KPagingMethod040::MapEarly(kernel_args* args, addr_t virtualAddress, if (PDE_TYPE(pd[index]) != DT_DIR) { unsigned aindex = index & ~(NUM_PAGETBL_PER_PAGE-1); /* aligned */ TRACE("missing page dir entry %d ai %d\n", index, aindex); - tbl = get_free_page(args) * B_PAGE_SIZE; + tbl = vm_allocate_early_physical_page(args) * B_PAGE_SIZE; if (!tbl) return ENOMEM; TRACE("early_map: asked for free page for pgtable. 0x%lx\n", tbl); @@ -555,7 +554,7 @@ M68KPagingMethod040::MapEarly(kernel_args* args, addr_t virtualAddress, phys_addr_t pgtable; page_directory_entry *e; // we need to allocate a pgtable - pgtable = get_free_page(args); + pgtable = vm_allocate_early_physical_page(args); // pgtable is in pages, convert to physical address pgtable *= B_PAGE_SIZE; diff --git a/src/system/kernel/arch/m68k/paging/040/M68KPagingMethod040.h b/src/system/kernel/arch/m68k/paging/040/M68KPagingMethod040.h index f194ca201d..a08c60ae1d 100644 --- a/src/system/kernel/arch/m68k/paging/040/M68KPagingMethod040.h +++ b/src/system/kernel/arch/m68k/paging/040/M68KPagingMethod040.h @@ -30,8 +30,7 @@ public: virtual status_t MapEarly(kernel_args* args, addr_t virtualAddress, phys_addr_t physicalAddress, - uint8 attributes, - phys_addr_t (*get_free_page)(kernel_args*)); + uint8 attributes); virtual bool IsKernelPageAccessible(addr_t virtualAddress, uint32 protection); diff --git a/src/system/kernel/arch/m68k/paging/M68KPagingMethod.h b/src/system/kernel/arch/m68k/paging/M68KPagingMethod.h index ec0b415f8b..ee4d0a0449 100644 --- a/src/system/kernel/arch/m68k/paging/M68KPagingMethod.h +++ b/src/system/kernel/arch/m68k/paging/M68KPagingMethod.h @@ -29,9 +29,7 @@ public: virtual status_t MapEarly(kernel_args* args, addr_t virtualAddress, phys_addr_t physicalAddress, - uint8 attributes, - phys_addr_t (*get_free_page)(kernel_args*)) - = 0; + uint8 attributes) = 0; virtual bool IsKernelPageAccessible(addr_t virtualAddress, uint32 protection) = 0; diff --git a/src/system/kernel/arch/ppc/arch_vm_translation_map.cpp b/src/system/kernel/arch/ppc/arch_vm_translation_map.cpp index edb091c08d..89ca4f9320 100644 --- a/src/system/kernel/arch/ppc/arch_vm_translation_map.cpp +++ b/src/system/kernel/arch/ppc/arch_vm_translation_map.cpp @@ -283,12 +283,12 @@ arch_vm_translation_map_init_post_sem(kernel_args *args) status_t arch_vm_translation_map_early_map(kernel_args *args, addr_t va, phys_addr_t pa, - uint8 attributes, phys_addr_t (*get_free_page)(kernel_args *)) + uint8 attributes) { TRACE("early_tmap: entry pa %#" B_PRIxPHYSADDR " va %#" B_PRIxADDR "\n", pa, va); - return gPPCPagingMethod->MapEarly(args, va, pa, attributes, get_free_page); + return gPPCPagingMethod->MapEarly(args, va, pa, attributes); } diff --git a/src/system/kernel/arch/ppc/paging/460/PPCPagingMethod460.cpp b/src/system/kernel/arch/ppc/paging/460/PPCPagingMethod460.cpp index ddf1df4fa3..af21faaa68 100644 --- a/src/system/kernel/arch/ppc/paging/460/PPCPagingMethod460.cpp +++ b/src/system/kernel/arch/ppc/paging/460/PPCPagingMethod460.cpp @@ -236,8 +236,7 @@ PPCPagingMethod460::CreateTranslationMap(bool kernel, VMTranslationMap** _map) status_t PPCPagingMethod460::MapEarly(kernel_args* args, addr_t virtualAddress, - phys_addr_t physicalAddress, uint8 attributes, - page_num_t (*get_free_page)(kernel_args*)) + phys_addr_t physicalAddress, uint8 attributes) { uint32 virtualSegmentID = get_sr((void *)virtualAddress) & 0xffffff; diff --git a/src/system/kernel/arch/ppc/paging/460/PPCPagingMethod460.h b/src/system/kernel/arch/ppc/paging/460/PPCPagingMethod460.h index 96b8add8af..79651c5225 100644 --- a/src/system/kernel/arch/ppc/paging/460/PPCPagingMethod460.h +++ b/src/system/kernel/arch/ppc/paging/460/PPCPagingMethod460.h @@ -31,8 +31,7 @@ public: virtual status_t MapEarly(kernel_args* args, addr_t virtualAddress, phys_addr_t physicalAddress, - uint8 attributes, - page_num_t (*get_free_page)(kernel_args*)); + uint8 attributes); virtual bool IsKernelPageAccessible(addr_t virtualAddress, uint32 protection); diff --git a/src/system/kernel/arch/ppc/paging/PPCPagingMethod.h b/src/system/kernel/arch/ppc/paging/PPCPagingMethod.h index 9ef4846102..62c5dc922f 100644 --- a/src/system/kernel/arch/ppc/paging/PPCPagingMethod.h +++ b/src/system/kernel/arch/ppc/paging/PPCPagingMethod.h @@ -31,9 +31,7 @@ public: virtual status_t MapEarly(kernel_args* args, addr_t virtualAddress, phys_addr_t physicalAddress, - uint8 attributes, - page_num_t (*get_free_page)(kernel_args*)) - = 0; + uint8 attributes) = 0; virtual bool IsKernelPageAccessible(addr_t virtualAddress, uint32 protection) = 0; diff --git a/src/system/kernel/arch/ppc/paging/classic/PPCPagingMethodClassic.cpp b/src/system/kernel/arch/ppc/paging/classic/PPCPagingMethodClassic.cpp index 0403b2a719..2b81a50d84 100644 --- a/src/system/kernel/arch/ppc/paging/classic/PPCPagingMethodClassic.cpp +++ b/src/system/kernel/arch/ppc/paging/classic/PPCPagingMethodClassic.cpp @@ -236,8 +236,7 @@ PPCPagingMethodClassic::CreateTranslationMap(bool kernel, VMTranslationMap** _ma status_t PPCPagingMethodClassic::MapEarly(kernel_args* args, addr_t virtualAddress, - phys_addr_t physicalAddress, uint8 attributes, - page_num_t (*get_free_page)(kernel_args*)) + phys_addr_t physicalAddress, uint8 attributes) { uint32 virtualSegmentID = get_sr((void *)virtualAddress) & 0xffffff; diff --git a/src/system/kernel/arch/ppc/paging/classic/PPCPagingMethodClassic.h b/src/system/kernel/arch/ppc/paging/classic/PPCPagingMethodClassic.h index 3025870082..c39a31f6a1 100644 --- a/src/system/kernel/arch/ppc/paging/classic/PPCPagingMethodClassic.h +++ b/src/system/kernel/arch/ppc/paging/classic/PPCPagingMethodClassic.h @@ -31,8 +31,7 @@ public: virtual status_t MapEarly(kernel_args* args, addr_t virtualAddress, phys_addr_t physicalAddress, - uint8 attributes, - page_num_t (*get_free_page)(kernel_args*)); + uint8 attributes); virtual bool IsKernelPageAccessible(addr_t virtualAddress, uint32 protection); diff --git a/src/system/kernel/arch/riscv64/arch_vm_translation_map.cpp b/src/system/kernel/arch/riscv64/arch_vm_translation_map.cpp index 23d2f51451..f532bd94e3 100644 --- a/src/system/kernel/arch/riscv64/arch_vm_translation_map.cpp +++ b/src/system/kernel/arch/riscv64/arch_vm_translation_map.cpp @@ -42,8 +42,7 @@ char sPhysicalPageMapperData[sizeof(RISCV64VMPhysicalPageMapper)]; // TODO: Consolidate function with RISCV64VMTranslationMap static Pte* -LookupPte(addr_t virtAdr, bool alloc, kernel_args* args, - phys_addr_t (*get_free_page)(kernel_args *)) +LookupPte(addr_t virtAdr, bool alloc, kernel_args* args) { Pte *pte = (Pte*)VirtFromPhys(sPageTable); for (int level = 2; level > 0; level --) { @@ -51,7 +50,7 @@ LookupPte(addr_t virtAdr, bool alloc, kernel_args* args, if (!pte->isValid) { if (!alloc) return NULL; - page_num_t ppn = get_free_page(args); + page_num_t ppn = vm_allocate_early_physical_page(args); if (ppn == 0) return NULL; memset((Pte*)VirtFromPhys(B_PAGE_SIZE * ppn), 0, B_PAGE_SIZE); @@ -70,11 +69,10 @@ LookupPte(addr_t virtAdr, bool alloc, kernel_args* args, static void -Map(addr_t virtAdr, phys_addr_t physAdr, uint64 flags, kernel_args* args, - phys_addr_t (*get_free_page)(kernel_args *)) +Map(addr_t virtAdr, phys_addr_t physAdr, uint64 flags, kernel_args* args) { // dprintf("Map(0x%" B_PRIxADDR ", 0x%" B_PRIxADDR ")\n", virtAdr, physAdr); - Pte* pte = LookupPte(virtAdr, true, args, get_free_page); + Pte* pte = LookupPte(virtAdr, true, args); if (pte == NULL) panic("can't allocate page table"); Pte newPte { @@ -162,8 +160,7 @@ arch_vm_translation_map_init_post_area(kernel_args *args) status_t arch_vm_translation_map_early_map(kernel_args *args, - addr_t virtAdr, phys_addr_t physAdr, uint8 attributes, - phys_addr_t (*get_free_page)(kernel_args *)) + addr_t virtAdr, phys_addr_t physAdr, uint8 attributes) { //dprintf("early_map(%#" B_PRIxADDR ", %#" B_PRIxADDR ")\n", virtAdr, physAdr); Pte flags { @@ -171,7 +168,7 @@ arch_vm_translation_map_early_map(kernel_args *args, .isWrite = (attributes & B_KERNEL_WRITE_AREA) != 0, .isExec = (attributes & B_KERNEL_EXECUTE_AREA) != 0, }; - Map(virtAdr, physAdr, flags.val, args, get_free_page); + Map(virtAdr, physAdr, flags.val, args); return B_OK; } diff --git a/src/system/kernel/arch/sparc/arch_vm_translation_map.cpp b/src/system/kernel/arch/sparc/arch_vm_translation_map.cpp index afb42677a2..b162e81a6b 100644 --- a/src/system/kernel/arch/sparc/arch_vm_translation_map.cpp +++ b/src/system/kernel/arch/sparc/arch_vm_translation_map.cpp @@ -77,7 +77,7 @@ arch_vm_translation_map_init_post_area(kernel_args *args) status_t arch_vm_translation_map_early_map(kernel_args *args, addr_t va, phys_addr_t pa, - uint8 attributes, phys_addr_t (*get_free_page)(kernel_args *)) + uint8 attributes) { TRACE("early_tmap: entry pa 0x%lx va 0x%lx\n", pa, va); return B_OK; diff --git a/src/system/kernel/arch/x86/arch_vm_translation_map.cpp b/src/system/kernel/arch/x86/arch_vm_translation_map.cpp index 3fbf66a397..34a4bc2f23 100644 --- a/src/system/kernel/arch/x86/arch_vm_translation_map.cpp +++ b/src/system/kernel/arch/x86/arch_vm_translation_map.cpp @@ -143,12 +143,12 @@ arch_vm_translation_map_init_post_area(kernel_args *args) status_t arch_vm_translation_map_early_map(kernel_args *args, addr_t va, phys_addr_t pa, - uint8 attributes, phys_addr_t (*get_free_page)(kernel_args *)) + uint8 attributes) { TRACE("early_tmap: entry pa %#" B_PRIxPHYSADDR " va %#" B_PRIxADDR "\n", pa, va); - return gX86PagingMethod->MapEarly(args, va, pa, attributes, get_free_page); + return gX86PagingMethod->MapEarly(args, va, pa, attributes); } diff --git a/src/system/kernel/arch/x86/paging/32bit/X86PagingMethod32Bit.cpp b/src/system/kernel/arch/x86/paging/32bit/X86PagingMethod32Bit.cpp index 2bbfeeb55f..590aa711bd 100644 --- a/src/system/kernel/arch/x86/paging/32bit/X86PagingMethod32Bit.cpp +++ b/src/system/kernel/arch/x86/paging/32bit/X86PagingMethod32Bit.cpp @@ -392,8 +392,7 @@ X86PagingMethod32Bit::CreateTranslationMap(bool kernel, VMTranslationMap** _map) status_t X86PagingMethod32Bit::MapEarly(kernel_args* args, addr_t virtualAddress, - phys_addr_t physicalAddress, uint8 attributes, - page_num_t (*get_free_page)(kernel_args*)) + phys_addr_t physicalAddress, uint8 attributes) { // XXX horrible back door to map a page quickly regardless of translation // map object, etc. used only during VM setup. @@ -408,7 +407,7 @@ X86PagingMethod32Bit::MapEarly(kernel_args* args, addr_t virtualAddress, phys_addr_t pgtable; page_directory_entry *e; // we need to allocate a pgtable - pgtable = get_free_page(args); + pgtable = vm_allocate_early_physical_page(args); // pgtable is in pages, convert to physical address pgtable *= B_PAGE_SIZE; diff --git a/src/system/kernel/arch/x86/paging/32bit/X86PagingMethod32Bit.h b/src/system/kernel/arch/x86/paging/32bit/X86PagingMethod32Bit.h index da154f5a1d..4bb0bd2ec8 100644 --- a/src/system/kernel/arch/x86/paging/32bit/X86PagingMethod32Bit.h +++ b/src/system/kernel/arch/x86/paging/32bit/X86PagingMethod32Bit.h @@ -30,8 +30,7 @@ public: virtual status_t MapEarly(kernel_args* args, addr_t virtualAddress, phys_addr_t physicalAddress, - uint8 attributes, - page_num_t (*get_free_page)(kernel_args*)); + uint8 attributes); virtual bool IsKernelPageAccessible(addr_t virtualAddress, uint32 protection); diff --git a/src/system/kernel/arch/x86/paging/64bit/X86PagingMethod64Bit.cpp b/src/system/kernel/arch/x86/paging/64bit/X86PagingMethod64Bit.cpp index 66fc4f84be..81127174a3 100644 --- a/src/system/kernel/arch/x86/paging/64bit/X86PagingMethod64Bit.cpp +++ b/src/system/kernel/arch/x86/paging/64bit/X86PagingMethod64Bit.cpp @@ -123,8 +123,7 @@ X86PagingMethod64Bit::CreateTranslationMap(bool kernel, VMTranslationMap** _map) status_t X86PagingMethod64Bit::MapEarly(kernel_args* args, addr_t virtualAddress, - phys_addr_t physicalAddress, uint8 attributes, - page_num_t (*get_free_page)(kernel_args*)) + phys_addr_t physicalAddress, uint8 attributes) { TRACE("X86PagingMethod64Bit::MapEarly(%#" B_PRIxADDR ", %#" B_PRIxPHYSADDR ", %#" B_PRIx8 ")\n", virtualAddress, physicalAddress, attributes); @@ -148,7 +147,7 @@ X86PagingMethod64Bit::MapEarly(kernel_args* args, addr_t virtualAddress, uint64* pdpte = &virtualPDPT[VADDR_TO_PDPTE(virtualAddress)]; uint64* virtualPageDir; if ((*pdpte & X86_64_PDPTE_PRESENT) == 0) { - phys_addr_t physicalPageDir = get_free_page(args) * B_PAGE_SIZE; + phys_addr_t physicalPageDir = vm_allocate_early_physical_page(args) * B_PAGE_SIZE; TRACE("X86PagingMethod64Bit::MapEarly(): creating page directory for va" " %#" B_PRIxADDR " at %#" B_PRIxPHYSADDR "\n", virtualAddress, @@ -172,7 +171,7 @@ X86PagingMethod64Bit::MapEarly(kernel_args* args, addr_t virtualAddress, uint64* pde = &virtualPageDir[VADDR_TO_PDE(virtualAddress)]; uint64* virtualPageTable; if ((*pde & X86_64_PDE_PRESENT) == 0) { - phys_addr_t physicalPageTable = get_free_page(args) * B_PAGE_SIZE; + phys_addr_t physicalPageTable = vm_allocate_early_physical_page(args) * B_PAGE_SIZE; TRACE("X86PagingMethod64Bit::MapEarly(): creating page table for va" " %#" B_PRIxADDR " at %#" B_PRIxPHYSADDR "\n", virtualAddress, diff --git a/src/system/kernel/arch/x86/paging/64bit/X86PagingMethod64Bit.h b/src/system/kernel/arch/x86/paging/64bit/X86PagingMethod64Bit.h index fb59c78b58..8b13940768 100644 --- a/src/system/kernel/arch/x86/paging/64bit/X86PagingMethod64Bit.h +++ b/src/system/kernel/arch/x86/paging/64bit/X86PagingMethod64Bit.h @@ -40,8 +40,7 @@ public: virtual status_t MapEarly(kernel_args* args, addr_t virtualAddress, phys_addr_t physicalAddress, - uint8 attributes, - page_num_t (*get_free_page)(kernel_args*)); + uint8 attributes); virtual bool IsKernelPageAccessible(addr_t virtualAddress, uint32 protection); diff --git a/src/system/kernel/arch/x86/paging/X86PagingMethod.h b/src/system/kernel/arch/x86/paging/X86PagingMethod.h index e80c4c7a14..d7da8cd194 100644 --- a/src/system/kernel/arch/x86/paging/X86PagingMethod.h +++ b/src/system/kernel/arch/x86/paging/X86PagingMethod.h @@ -31,9 +31,7 @@ public: virtual status_t MapEarly(kernel_args* args, addr_t virtualAddress, phys_addr_t physicalAddress, - uint8 attributes, - page_num_t (*get_free_page)(kernel_args*)) - = 0; + uint8 attributes) = 0; virtual bool IsKernelPageAccessible(addr_t virtualAddress, uint32 protection) = 0; diff --git a/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.cpp b/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.cpp index 56b51a17c0..4cb533f036 100644 --- a/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.cpp +++ b/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.cpp @@ -284,7 +284,7 @@ private: phys_addr_t _Allocate32BitPage() { phys_addr_t physicalAddress - = (phys_addr_t)vm_allocate_early_physical_page_etc(fKernelArgs, 0xffffffff) + = (phys_addr_t)vm_allocate_early_physical_page(fKernelArgs, 0xffffffff) * B_PAGE_SIZE; if (physicalAddress == 0 || physicalAddress > 0xffffffff) { panic("Failed to allocate 32-bit-addressable page for the switch " @@ -674,8 +674,7 @@ X86PagingMethodPAE::CreateTranslationMap(bool kernel, VMTranslationMap** _map) status_t X86PagingMethodPAE::MapEarly(kernel_args* args, addr_t virtualAddress, - phys_addr_t physicalAddress, uint8 attributes, - page_num_t (*get_free_page)(kernel_args*)) + phys_addr_t physicalAddress, uint8 attributes) { // check to see if a page table exists for this range pae_page_directory_entry* pageDirEntry = PageDirEntryForAddress( @@ -683,7 +682,7 @@ X86PagingMethodPAE::MapEarly(kernel_args* args, addr_t virtualAddress, pae_page_table_entry* pageTable; if ((*pageDirEntry & X86_PAE_PDE_PRESENT) == 0) { // we need to allocate a page table - phys_addr_t physicalPageTable = get_free_page(args) * B_PAGE_SIZE; + phys_addr_t physicalPageTable = vm_allocate_early_physical_page(args) * B_PAGE_SIZE; TRACE("X86PagingMethodPAE::MapEarly(): asked for free page for " "page table: %#" B_PRIxPHYSADDR "\n", physicalPageTable); diff --git a/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.h b/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.h index 84f071a002..7a67c70e61 100644 --- a/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.h +++ b/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.h @@ -38,8 +38,7 @@ public: virtual status_t MapEarly(kernel_args* args, addr_t virtualAddress, phys_addr_t physicalAddress, - uint8 attributes, - page_num_t (*get_free_page)(kernel_args*)); + uint8 attributes); virtual bool IsKernelPageAccessible(addr_t virtualAddress, uint32 protection); diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index aeb5dd9417..07dcc96489 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -3724,14 +3724,7 @@ is_page_in_physical_memory_range(kernel_args* args, phys_addr_t address) page_num_t -vm_allocate_early_physical_page(kernel_args* args) -{ - return vm_allocate_early_physical_page_etc(args); -} - - -page_num_t -vm_allocate_early_physical_page_etc(kernel_args* args, phys_addr_t maxAddress) +vm_allocate_early_physical_page(kernel_args* args, phys_addr_t maxAddress) { if (args->num_physical_allocated_ranges == 0) { panic("early physical page allocations no longer possible!"); @@ -3899,8 +3892,7 @@ vm_allocate_early(kernel_args* args, size_t virtualSize, size_t physicalSize, status_t status = arch_vm_translation_map_early_map(args, virtualBase + i * B_PAGE_SIZE, - physicalAddress * B_PAGE_SIZE, attributes, - &vm_allocate_early_physical_page); + physicalAddress * B_PAGE_SIZE, attributes); if (status != B_OK) panic("error mapping early page!"); }