arm: relocate UART when remapping virtual memory
The uart virtual address changes as soon as we apply the kernel memory
map. gUART is used only after that, from serial_init() onwards. So it
should use the virtual address, and not the physical address it was
previously created with while parsing the FDT.
Change-Id: I8c8a024fe564b49d6555f8e48f5ab31652d30708
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10068
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Diff
headers/private/kernel/arch/generic/debug_uart.h | 1 +
src/system/boot/platform/efi/arch/arm/arch_mmu.cpp | 5 +++++
2 files changed, 6 insertions(+)
@@ -35,6 +35,7 @@
virtual void FlushTx() = 0;
virtual void FlushRx() = 0;
void SetBase(addr_t base) { fBase = base; }
addr_t Base() const { return fBase; }
int64 Clock() const { return fClock; }
bool Enabled() const { return fEnabled; }
@@ -8,12 +8,14 @@
#include <arm_mmu.h>
#include <kernel.h>
#include <arch/generic/debug_uart.h>
#include <arch_kernel.h>
#include <boot/platform.h>
#include <boot/stage2.h>
#include <efi/types.h>
#include <efi/boot-services.h>
#include "efi_platform.h"
#include "generic_mmu.h"
#include "mmu.h"
@@ -29,6 +31,8 @@
static constexpr bool kTraceMemoryMap = false;
static constexpr bool kTracePageDirectory = false;
extern DebugUART* gUART;
@@ -281,6 +285,7 @@
map_range_to_new_area(gKernelArgs.arch_args.uart.regs,
ARM_MMU_L2_FLAG_B | ARM_MMU_L2_FLAG_HAIKU_KERNEL_RW | ARM_MMU_L2_FLAG_XN);
gUART->SetBase(gKernelArgs.arch_args.uart.regs.start);
sort_address_ranges(gKernelArgs.virtual_allocated_range,
gKernelArgs.num_virtual_allocated_ranges);