Module Name:    src
Committed By:   skrll
Date:           Sat Feb 25 08:19:35 UTC 2023

Modified Files:
        src/sys/arch/arm/fdt: arm_platform.c
        src/sys/arch/evbarm/conf: GENERIC GENERIC64

Log Message:
Restore the ability to have EARLYCONS work for the QEMU virt after
SOC_VIRT got removed.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/arm_platform.c
cvs rdiff -u -r1.117 -r1.118 src/sys/arch/evbarm/conf/GENERIC
cvs rdiff -u -r1.209 -r1.210 src/sys/arch/evbarm/conf/GENERIC64

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/fdt/arm_platform.c
diff -u src/sys/arch/arm/fdt/arm_platform.c:1.5 src/sys/arch/arm/fdt/arm_platform.c:1.6
--- src/sys/arch/arm/fdt/arm_platform.c:1.5	Sat Apr 24 23:36:26 2021
+++ src/sys/arch/arm/fdt/arm_platform.c	Sat Feb 25 08:19:35 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: arm_platform.c,v 1.5 2021/04/24 23:36:26 thorpej Exp $ */
+/* $NetBSD: arm_platform.c,v 1.6 2023/02/25 08:19:35 skrll Exp $ */
 
 /*-
  * Copyright (c) 2020 Jared McNeill <jmcne...@invisible.ca>
@@ -35,8 +35,10 @@
  *  - Console UART is pre-configured by firmware
  */
 
+#include "opt_console.h"
+
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arm_platform.c,v 1.5 2021/04/24 23:36:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm_platform.c,v 1.6 2023/02/25 08:19:35 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -58,6 +60,9 @@ __KERNEL_RCSID(0, "$NetBSD: arm_platform
 #include <arm/arm/psci.h>
 #include <arm/fdt/psci_fdtvar.h>
 
+#include <evbarm/dev/plcomreg.h>
+#include <evbarm/dev/plcomvar.h>
+
 #include <libfdt.h>
 
 #include <arch/evbarm/fdt/platform.h>
@@ -65,6 +70,31 @@ __KERNEL_RCSID(0, "$NetBSD: arm_platform
 extern struct arm32_bus_dma_tag arm_generic_dma_tag;
 extern struct bus_space arm_generic_bs_tag;
 
+void plcom_platform_early_putchar(char);
+
+#define	ARM_PTOV(p)       (((p) - DEVMAP_ALIGN(uart_base)) + KERNEL_IO_VBASE)
+
+void __noasan
+plcom_platform_early_putchar(char c)
+{
+#ifdef CONSADDR
+	bus_addr_t uart_base = CONSADDR;
+
+	volatile uint32_t *uartaddr = cpu_earlydevice_va_p() ?
+		(volatile uint32_t *)ARM_PTOV(uart_base):
+		(volatile uint32_t *)uart_base;
+
+	while ((le32toh(uartaddr[PL01XCOM_FR / 4]) & PL01X_FR_TXFF) != 0)
+		continue;
+
+	uartaddr[PL01XCOM_DR / 4] = htole32(c);
+	dsb(sy);
+
+	while ((le32toh(uartaddr[PL01XCOM_FR / 4]) & PL01X_FR_TXFE) == 0)
+		continue;
+#endif
+}
+
 static void
 arm_platform_init_attach_args(struct fdt_attach_args *faa)
 {
@@ -87,12 +117,12 @@ arm_platform_devmap(void)
 		DEVMAP_ENTRY(KERNEL_IO_VBASE, 0, PAGE_SIZE),
 		DEVMAP_ENTRY_END
 	};
-	bus_addr_t uart_base;
 
 	const int phandle = fdtbus_get_stdout_phandle();
 	if (phandle <= 0)
 		return devmap_empty;
 
+	bus_addr_t uart_base;
 	if (fdtbus_get_reg(phandle, 0, &uart_base, NULL) != 0)
 		return devmap_empty;
 

Index: src/sys/arch/evbarm/conf/GENERIC
diff -u src/sys/arch/evbarm/conf/GENERIC:1.117 src/sys/arch/evbarm/conf/GENERIC:1.118
--- src/sys/arch/evbarm/conf/GENERIC:1.117	Thu Feb  9 14:09:48 2023
+++ src/sys/arch/evbarm/conf/GENERIC	Sat Feb 25 08:19:35 2023
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC,v 1.117 2023/02/09 14:09:48 abs Exp $
+#	$NetBSD: GENERIC,v 1.118 2023/02/25 08:19:35 skrll Exp $
 #
 #	GENERIC ARM (aarch32) kernel
 #
@@ -78,10 +78,12 @@ options 	MSGBUFSIZE=32768
 #options 	EARLYCONS=tegra, CONSADDR=0x70006300
 
 #options 	EARLYCONS=vexpress, CONSADDR=0x1c090000
-#options 	EARLYCONS=virt, CONSADDR=0x09000000
 #options 	EARLYCONS=zynq, CONSADDR=0xe0001000
 #options 	EARLYCONS=rk3288, CONSADDR=0xff690000
 
+# The QEMU virt machine
+#options 	EARLYCONS=plcom, CONSADDR=0x09000000
+
 # Kernel Undefined Behavior Sanitizer (kUBSan). Use UBSAN_ALWAYS_FATAL
 # if you want panics instead of warnings.
 #options 	KUBSAN			# mandatory

Index: src/sys/arch/evbarm/conf/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.209 src/sys/arch/evbarm/conf/GENERIC64:1.210
--- src/sys/arch/evbarm/conf/GENERIC64:1.209	Sat Feb 11 07:01:32 2023
+++ src/sys/arch/evbarm/conf/GENERIC64	Sat Feb 25 08:19:35 2023
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.209 2023/02/11 07:01:32 mrg Exp $
+#	$NetBSD: GENERIC64,v 1.210 2023/02/25 08:19:35 skrll Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -47,7 +47,9 @@ options 	INCLUDE_CONFIG_FILE
 #options 	EARLYCONS=sunxi, CONSADDR=0x01c28000
 #options 	EARLYCONS=tegra, CONSADDR=0x70006000
 #options 	EARLYCONS=thunderx, CONSADDR=0x87e024000000
-#options 	EARLYCONS=virt, CONSADDR=0x09000000
+
+# The QEMU virt machine
+#options 	EARLYCONS=plcom, CONSADDR=0x09000000
 
 # Hardware management of the Access flag and dirty state (HAFDBS).
 options 	ARMV81_HAFDBS

Reply via email to