arm64: Map discovered UART into kernel space as device memory.

Change-Id: I4af09410c29c5586b85e1e1eba5803c0b30a1b01
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5272
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
milek7 2022-03-31 02:13:29 +02:00 committed by Adrien Destugues
parent 9ee255851d
commit 5be45ee70f
2 changed files with 21 additions and 7 deletions

View File

@ -489,19 +489,25 @@ arch_mmu_generate_post_efi_page_tables(size_t memory_map_size,
| currentMair.MaskOf(MAIR_NORMAL_WB));
}
/* TODO: Not an UART here... inspect dtb?
// identity mapping for the debug uart
map_range(0x09000000, 0x09000000, B_PAGE_SIZE,
ARMv8TranslationTableDescriptor::DefaultPeripheralAttribute
| currentMair.MaskOf(MAIR_DEVICE_nGnRnE));
*/
// TODO: We actually can only map physical RAM, mapping everything
// could cause unwanted MMIO or bus errors on real hardware.
map_range(KERNEL_PMAP_BASE, 0, KERNEL_PMAP_SIZE - 1,
ARMv8TranslationTableDescriptor::DefaultCodeAttribute
| currentMair.MaskOf(MAIR_NORMAL_WB));
if (gKernelArgs.arch_args.uart.kind[0] != 0) {
// Map uart because we want to use it during early boot.
uint64 regs_start = gKernelArgs.arch_args.uart.regs.start;
uint64 regs_size = ROUNDUP(gKernelArgs.arch_args.uart.regs.size, B_PAGE_SIZE);
uint64 base = get_next_virtual_address(regs_size);
map_range(base, regs_start, regs_size,
ARMv8TranslationTableDescriptor::DefaultPeripheralAttribute |
currentMair.MaskOf(MAIR_DEVICE_nGnRnE));
gKernelArgs.arch_args.uart.regs.start = base;
}
sort_address_ranges(gKernelArgs.virtual_allocated_range,
gKernelArgs.num_virtual_allocated_ranges);

View File

@ -96,6 +96,14 @@ arch_vm_translation_map_init_post_area(kernel_args* args)
area_id area = vm_create_null_area(VMAddressSpace::KernelID(), "physical map area", &address,
B_EXACT_ADDRESS, KERNEL_PMAP_SIZE, 0);
if (args->arch_args.uart.kind[0] != 0) {
// debug uart is already mapped by the efi loader
address = (void*)args->arch_args.uart.regs.start;
area_id area = vm_create_null_area(VMAddressSpace::KernelID(),
"debug uart map area", &address, B_EXACT_ADDRESS,
ROUNDUP(args->arch_args.uart.regs.size, B_PAGE_SIZE), 0);
}
return B_OK;
}