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 <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
PulkoMandy
2025-12-09 19:35:39 +00:00
committed by waddlesplash
parent 0f7bee148d
commit 97675f2fc4
2 changed files with 6 additions and 0 deletions
@@ -35,6 +35,7 @@ public:
virtual void FlushTx() = 0; virtual void FlushTx() = 0;
virtual void FlushRx() = 0; virtual void FlushRx() = 0;
void SetBase(addr_t base) { fBase = base; }
addr_t Base() const { return fBase; } addr_t Base() const { return fBase; }
int64 Clock() const { return fClock; } int64 Clock() const { return fClock; }
bool Enabled() const { return fEnabled; } bool Enabled() const { return fEnabled; }
@@ -8,12 +8,14 @@
#include <arm_mmu.h> #include <arm_mmu.h>
#include <kernel.h> #include <kernel.h>
#include <arch/generic/debug_uart.h>
#include <arch_kernel.h> #include <arch_kernel.h>
#include <boot/platform.h> #include <boot/platform.h>
#include <boot/stage2.h> #include <boot/stage2.h>
#include <efi/types.h> #include <efi/types.h>
#include <efi/boot-services.h> #include <efi/boot-services.h>
#include "efi_platform.h" #include "efi_platform.h"
#include "generic_mmu.h" #include "generic_mmu.h"
#include "mmu.h" #include "mmu.h"
@@ -30,6 +32,8 @@
static constexpr bool kTraceMemoryMap = false; static constexpr bool kTraceMemoryMap = false;
static constexpr bool kTracePageDirectory = false; static constexpr bool kTracePageDirectory = false;
extern DebugUART* gUART;
// Ignore memory above 512GB // Ignore memory above 512GB
#define PHYSICAL_MEMORY_LOW 0x00000000 #define PHYSICAL_MEMORY_LOW 0x00000000
@@ -281,6 +285,7 @@ arch_mmu_generate_post_efi_page_tables(size_t memoryMapSize,
map_range_to_new_area(gKernelArgs.arch_args.uart.regs, 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); 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, sort_address_ranges(gKernelArgs.virtual_allocated_range,
gKernelArgs.num_virtual_allocated_ranges); gKernelArgs.num_virtual_allocated_ranges);