From f93416d677432f3a713c71b79fb68e89162baca9 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Thu, 11 May 2023 14:03:30 -0600 Subject: [PATCH] stand: add comconsole backwards compatibility shim for aarch64 Add a compat shim for the "comconsole" name so that people with a "console=comconsole" in their loader.conf on aarch64 will continue to work (though with a warning). This is only aarch64: it will never be there for amd64 (where comconsole always means talk to the hardware directly). To do that is too hard. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D39983 --- stand/efi/loader/conf.c | 7 +++++++ stand/efi/loader/efiserialio.c | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/stand/efi/loader/conf.c b/stand/efi/loader/conf.c index e9ae01d19270..e84d8b6c366d 100644 --- a/stand/efi/loader/conf.c +++ b/stand/efi/loader/conf.c @@ -81,6 +81,10 @@ struct netif_driver *netif_drivers[] = { extern struct console efi_console; extern struct console eficom; +#if defined(__aarch64__) && __FreeBSD_version < 1500000 +/* Hack for backward compatibility -- but only for a while */ +extern struct console comconsole; +#endif #if defined(__amd64__) || defined(__i386__) extern struct console comconsole; extern struct console nullconsole; @@ -90,6 +94,9 @@ extern struct console spinconsole; struct console *consoles[] = { &efi_console, &eficom, +#if defined(__aarch64__) && __FreeBSD_version < 1500000 + &comconsole, +#endif #if defined(__amd64__) || defined(__i386__) &comconsole, &nullconsole, diff --git a/stand/efi/loader/efiserialio.c b/stand/efi/loader/efiserialio.c index de4d6b3e34c1..16f28080f80e 100644 --- a/stand/efi/loader/efiserialio.c +++ b/stand/efi/loader/efiserialio.c @@ -81,6 +81,20 @@ struct console eficom = { .c_ready = comc_ischar, }; +#if defined(__aarch64__) && __FreeBSD_version < 1500000 +static void comc_probe_compat(struct console *); +struct console comconsole = { + .c_name = "comconsole", + .c_desc = "serial port", + .c_flags = 0, + .c_probe = comc_probe_compat, + .c_init = comc_init, + .c_out = comc_putchar, + .c_in = comc_getchar, + .c_ready = comc_ischar, +}; +#endif + static EFI_STATUS efi_serial_init(EFI_HANDLE **handlep, int *nhandles) { @@ -328,6 +342,17 @@ comc_probe(struct console *sc) } } +#if defined(__aarch64__) && __FreeBSD_version < 1500000 +static void +comc_probe_compat(struct console *sc) +{ + comc_probe(sc); + if (sc->c_flags & (C_PRESENTIN | C_PRESENTOUT)) { + printf("comconsole: comconsole device name is deprecated, switch to eficom\n"); + } +} +#endif + static int comc_init(int arg __unused) {