⛏️ index : haiku.git

author PulkoMandy <pulkomandy@pulkomandy.tk> 2025-12-07 22:22:04.0 +01:00:00
committer waddlesplash <waddlesplash@gmail.com> 2025-12-09 19:35:39.0 +00:00:00
commit
97675f2fc495e85b8b595467b5b39cf4467d1322 [patch]
tree
ca5801584686066282ffba8b5e8a4a153a5e786f
parent
0f7bee148d7d86d4f7e13b44fd6a28cc56c938e8
download
97675f2fc495e85b8b595467b5b39cf4467d1322.tar.gz

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(+)

diff --git a/headers/private/kernel/arch/generic/debug_uart.h b/headers/private/kernel/arch/generic/debug_uart.h
index c6a660e..862f8c1 100644
--- a/headers/private/kernel/arch/generic/debug_uart.h
+++ b/headers/private/kernel/arch/generic/debug_uart.h
@@ -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; }
diff --git a/src/system/boot/platform/efi/arch/arm/arch_mmu.cpp b/src/system/boot/platform/efi/arch/arm/arch_mmu.cpp
index 54897ed..1acd293 100644
--- a/src/system/boot/platform/efi/arch/arm/arch_mmu.cpp
+++ b/src/system/boot/platform/efi/arch/arm/arch_mmu.cpp
@@ -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;


// Ignore memory above 512GB
@@ -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);