diff --git a/headers/private/kernel/vm/vm.h b/headers/private/kernel/vm/vm.h index adb42afb5b..ed5c51932c 100644 --- a/headers/private/kernel/vm/vm.h +++ b/headers/private/kernel/vm/vm.h @@ -69,7 +69,8 @@ area_id vm_create_anonymous_area(team_id team, const char *name, void **address, uint32 addressSpec, addr_t size, uint32 wiring, uint32 protection, addr_t physicalAddress, uint32 flags, bool kernel); area_id vm_map_physical_memory(team_id team, const char *name, void **address, - uint32 addressSpec, addr_t size, uint32 protection, addr_t phys_addr); + uint32 addressSpec, addr_t size, uint32 protection, + addr_t physicalAddress, bool alreadyWired); area_id vm_map_physical_memory_vecs(team_id team, const char* name, void** _address, uint32 addressSpec, addr_t* _size, uint32 protection, struct iovec* vecs, uint32 vecCount); diff --git a/src/system/kernel/arch/x86/arch_int.cpp b/src/system/kernel/arch/x86/arch_int.cpp index 4e1d7c44b5..bd25d444b6 100644 --- a/src/system/kernel/arch/x86/arch_int.cpp +++ b/src/system/kernel/arch/x86/arch_int.cpp @@ -568,9 +568,10 @@ ioapic_init(kernel_args *args) // always map the local apic as it can be used for timers even if we // don't end up using the io apic sLocalAPIC = args->arch_args.apic; - if (map_physical_memory("local apic", (void *)args->arch_args.apic_phys, - B_PAGE_SIZE, B_EXACT_ADDRESS, B_KERNEL_READ_AREA - | B_KERNEL_WRITE_AREA, &sLocalAPIC) < B_OK) { + if (vm_map_physical_memory(B_SYSTEM_TEAM, "local apic", &sLocalAPIC, + B_EXACT_ADDRESS, B_PAGE_SIZE, + B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, + args->arch_args.apic_phys, true) < 0) { panic("mapping the local apic failed"); return; } @@ -597,9 +598,10 @@ ioapic_init(kernel_args *args) // map in the ioapic sIOAPIC = (ioapic *)args->arch_args.ioapic; - if (map_physical_memory("ioapic", (void *)args->arch_args.ioapic_phys, - B_PAGE_SIZE, B_EXACT_ADDRESS, - B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, (void **)&sIOAPIC) < 0) { + if (vm_map_physical_memory(B_SYSTEM_TEAM, "ioapic", (void**)&sIOAPIC, + B_EXACT_ADDRESS, B_PAGE_SIZE, + B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, + args->arch_args.ioapic_phys, true) < 0) { panic("mapping the ioapic failed"); return; } diff --git a/src/system/kernel/arch/x86/vm86.cpp b/src/system/kernel/arch/x86/vm86.cpp index 988981e6e3..3589ad2b34 100644 --- a/src/system/kernel/arch/x86/vm86.cpp +++ b/src/system/kernel/arch/x86/vm86.cpp @@ -573,8 +573,9 @@ vm86_prepare(struct vm86_state *state, unsigned int ramSize) // map vga/bios area address = (void *)0xa0000; state->bios_area = vm_map_physical_memory(team->id, "bios", - &address, B_EXACT_ADDRESS, 0x60000, B_KERNEL_READ_AREA - | B_KERNEL_WRITE_AREA | B_READ_AREA | B_WRITE_AREA, (addr_t)0xa0000); + &address, B_EXACT_ADDRESS, 0x60000, + B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_READ_AREA | B_WRITE_AREA, + (addr_t)0xa0000, false); if (state->bios_area < B_OK) { ret = state->bios_area; TRACE("Could not map VGA BIOS.\n"); diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index 89055e57e8..1348f77fe5 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -1079,7 +1079,8 @@ err0: area_id vm_map_physical_memory(team_id team, const char* name, void** _address, - uint32 addressSpec, addr_t size, uint32 protection, addr_t physicalAddress) + uint32 addressSpec, addr_t size, uint32 protection, addr_t physicalAddress, + bool alreadyWired) { VMArea* area; VMCache* cache; @@ -1132,7 +1133,7 @@ vm_map_physical_memory(team_id team, const char* name, void** _address, delete_area(locker.AddressSpace(), area); } - if (status >= B_OK) { + if (status >= B_OK && !alreadyWired) { // make sure our area is mapped in completely vm_translation_map* map = &locker.AddressSpace()->TranslationMap(); @@ -4839,7 +4840,7 @@ map_physical_memory(const char* name, void* physicalAddress, size_t numBytes, return vm_map_physical_memory(VMAddressSpace::KernelID(), name, _virtualAddress, addressSpec, numBytes, protection, - (addr_t)physicalAddress); + (addr_t)physicalAddress, false); }