Restore the ability to have EARLYCONS work for the QEMU virt after

SOC_VIRT got removed.
This commit is contained in:
skrll 2023-02-25 08:19:35 +00:00
parent adedf7ab7d
commit 49721fc44e
3 changed files with 41 additions and 7 deletions

View File

@ -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;

View File

@ -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

View File

@ -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