Add support for using non-standard UARTs (such as the Synopsys DesignWare
authorkettenis <kettenis@openbsd.org>
Wed, 29 Jun 2022 07:51:54 +0000 (07:51 +0000)
committerkettenis <kettenis@openbsd.org>
Wed, 29 Jun 2022 07:51:54 +0000 (07:51 +0000)
UART found on AMD's Ryzen Embedded V1000 family) as an early console.
This requires additional parameters to be passed by the bootloader to the
kernel so it changes the struct for the BOOTARG_CONSDEV boot argument.
The old struct will still be supported until OpenBSD 7.3 has been released
such that new kernels boot with the old bootloader.

ok anton@, deraadt@

sys/arch/amd64/amd64/machdep.c
sys/arch/amd64/include/biosvar.h

index d7d36c5..53e2e0a 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: machdep.c,v 1.277 2022/02/01 20:29:53 deraadt Exp $   */
+/*     $OpenBSD: machdep.c,v 1.278 2022/06/29 07:51:54 kettenis Exp $  */
 /*     $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
 
 /*-
@@ -1945,7 +1945,7 @@ getbootinfo(char *bootinfo, int bootinfo_size)
                        /* generated by i386 boot loader */
                        break;
                case BOOTARG_CONSDEV:
-                       if (q->ba_size >= sizeof(bios_consdev_t) +
+                       if (q->ba_size > sizeof(bios_oconsdev_t) +
                            offsetof(struct _boot_args32, ba_arg)) {
 #if NCOM > 0
                                bios_consdev_t *cdp =
@@ -1953,6 +1953,35 @@ getbootinfo(char *bootinfo, int bootinfo_size)
                                static const int ports[] =
                                    { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
                                int unit = minor(cdp->consdev);
+                               uint64_t consaddr = cdp->consaddr;
+                               if (consaddr == -1 && unit >= 0 &&
+                                   unit < nitems(ports))
+                                       consaddr = ports[unit];
+                               if (major(cdp->consdev) == 8 &&
+                                   consaddr != -1) {
+                                       comconsunit = unit;
+                                       comconsaddr = consaddr;
+                                       comconsrate = cdp->conspeed;
+                                       comconsfreq = cdp->consfreq;
+                                       comcons_reg_width = cdp->reg_width;
+                                       comcons_reg_shift = cdp->reg_shift;
+                                       if (cdp->flags & BCD_MMIO)
+                                               comconsiot = X86_BUS_SPACE_MEM;
+                                       else
+                                               comconsiot = X86_BUS_SPACE_IO;
+                               }
+#endif
+#ifdef BOOTINFO_DEBUG
+                               printf(" console 0x%x:%d",
+                                   cdp->consdev, cdp->conspeed);
+#endif
+                       } else {
+#if NCOM > 0
+                               bios_oconsdev_t *cdp =
+                                   (bios_oconsdev_t*)q->ba_arg;
+                               static const int ports[] =
+                                   { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
+                               int unit = minor(cdp->consdev);
                                int consaddr = cdp->consaddr;
                                if (consaddr == -1 && unit >= 0 &&
                                    unit < nitems(ports))
index 893fbc2..8fe6e29 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: biosvar.h,v 1.27 2019/11/29 16:16:19 kettenis Exp $   */
+/*     $OpenBSD: biosvar.h,v 1.28 2022/06/29 07:51:54 kettenis Exp $   */
 
 /*
  * Copyright (c) 1997-1999 Michael Shalayeff
@@ -162,11 +162,23 @@ typedef struct _bios_pciinfo {
 
 #define        BOOTARG_CONSDEV 5
 typedef struct _bios_consdev {
+       dev_t           consdev;
+       int             conspeed;
+       uint64_t        consaddr;
+       int             consfreq;
+       uint32_t        flags;
+#define BCD_MMIO       0x00000001      /* Memory Mapped IO */
+       int             reg_width;
+       int             reg_shift;
+} __packed bios_consdev_t;
+
+/* Old interface; remove after OpenBSD 7.3 is released */
+typedef struct _bios_oconsdev {
        dev_t   consdev;
        int     conspeed;
        int     consaddr;
        int     consfreq;
-} __packed bios_consdev_t;
+} __packed bios_oconsdev_t;
 
 #define BOOTARG_BOOTMAC        7
 typedef struct _bios_bootmac {