diff options
| author | skrll <skrll@NetBSD.org> | 2023-02-25 08:19:35 +0000 |
|---|---|---|
| committer | skrll <skrll@NetBSD.org> | 2023-02-25 08:19:35 +0000 |
| commit | 466d62fd1ed5c89da57fb98860f18df1663c6a2e (patch) | |
| tree | a7eccbb7bbaeb57ac3ac161eb519c1fba1c615e1 /sys | |
| parent | 36e3f47c4be3168fe441e3ebf41dab5a4342c35b (diff) | |
Restore the ability to have EARLYCONS work for the QEMU virt after
SOC_VIRT got removed.
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/arch/arm/fdt/arm_platform.c | 36 | ||||
| -rw-r--r-- | sys/arch/evbarm/conf/GENERIC | 6 | ||||
| -rw-r--r-- | sys/arch/evbarm/conf/GENERIC64 | 6 |
3 files changed, 41 insertions, 7 deletions
diff --git a/sys/arch/arm/fdt/arm_platform.c b/sys/arch/arm/fdt/arm_platform.c index 012a701172a..b1965bb90df 100644 --- a/sys/arch/arm/fdt/arm_platform.c +++ b/sys/arch/arm/fdt/arm_platform.c @@ -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 <jmcneill@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.c,v 1.5 2021/04/24 23:36:26 thorpej Exp #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.c,v 1.5 2021/04/24 23:36:26 thorpej Exp 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; diff --git a/sys/arch/evbarm/conf/GENERIC b/sys/arch/evbarm/conf/GENERIC index 017bbb8b5ec..61f312973e5 100644 --- a/sys/arch/evbarm/conf/GENERIC +++ b/sys/arch/evbarm/conf/GENERIC @@ -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 diff --git a/sys/arch/evbarm/conf/GENERIC64 b/sys/arch/evbarm/conf/GENERIC64 index e86ea055723..5d5f1db6e2a 100644 --- a/sys/arch/evbarm/conf/GENERIC64 +++ b/sys/arch/evbarm/conf/GENERIC64 @@ -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 |
