Make sure that switching the console from serial to framebuffer works
authorkettenis <kettenis@openbsd.org>
Tue, 9 Feb 2021 23:58:33 +0000 (23:58 +0000)
committerkettenis <kettenis@openbsd.org>
Tue, 9 Feb 2021 23:58:33 +0000 (23:58 +0000)
for framebuffer nodes under / and /chosen.

ok patrick@

sys/arch/arm64/stand/efiboot/conf.c
sys/arch/arm64/stand/efiboot/efiboot.c

index 2de9bcc..f54f791 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: conf.c,v 1.31 2020/12/09 18:10:18 krw Exp $   */
+/*     $OpenBSD: conf.c,v 1.32 2021/02/09 23:58:33 kettenis Exp $      */
 
 /*
  * Copyright (c) 1996 Michael Shalayeff
@@ -46,7 +46,7 @@
 #include "efipxe.h"
 #include "softraid_arm64.h"
 
-const char version[] = "1.3";
+const char version[] = "1.4";
 int    debug = 0;
 
 struct fs_ops file_system[] = {
index bf25c07..db75d09 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: efiboot.c,v 1.29 2020/05/10 11:55:42 kettenis Exp $   */
+/*     $OpenBSD: efiboot.c,v 1.30 2021/02/09 23:58:33 kettenis Exp $   */
 
 /*
  * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
@@ -112,6 +112,8 @@ static SIMPLE_INPUT_INTERFACE *conin;
 static dev_t serial = makedev(0, 0);
 static dev_t framebuffer = makedev(1, 0);
 
+static char framebuffer_path[128];
+
 void
 efi_cons_probe(struct consdev *cn)
 {
@@ -357,8 +359,13 @@ efi_framebuffer(void)
                if (!fdt_node_is_compatible(child, "simple-framebuffer"))
                        continue;
                if (fdt_node_property(child, "status", &prop) &&
-                   strcmp(prop, "okay") == 0)
+                   strcmp(prop, "okay") == 0) {
+                       strlcpy(framebuffer_path, "/chosen/",
+                           sizeof(framebuffer_path));
+                       strlcat(framebuffer_path, fdt_node_name(child),
+                           sizeof(framebuffer_path));
                        return;
+               }
        }
        node = fdt_find_node("/");
        for (child = fdt_child_node(node); child;
@@ -366,8 +373,13 @@ efi_framebuffer(void)
                if (!fdt_node_is_compatible(child, "simple-framebuffer"))
                        continue;
                if (fdt_node_property(child, "status", &prop) &&
-                   strcmp(prop, "okay") == 0)
+                   strcmp(prop, "okay") == 0) {
+                       strlcpy(framebuffer_path, "/",
+                           sizeof(framebuffer_path));
+                       strlcat(framebuffer_path, fdt_node_name(child),
+                           sizeof(framebuffer_path));
                        return;
+               }
        }
 
        status = EFI_CALL(BS->LocateProtocol, &gop_guid, NULL, (void **)&gop);
@@ -426,35 +438,26 @@ efi_framebuffer(void)
        fdt_node_add_property(child, "reg", reg, (acells + scells) * 4);
        fdt_node_add_property(child, "compatible",
            "simple-framebuffer", strlen("simple-framebuffer") + 1);
+
+       strlcpy(framebuffer_path, "/chosen/framebuffer",
+           sizeof(framebuffer_path));
 }
 
 void
 efi_console(void)
 {
-       char path[128];
-       void *node, *child;
-       char *prop;
+       void *node;
 
        if (cn_tab->cn_dev != framebuffer)
                return;
 
-       /* Find the desired framebuffer node. */
-       node = fdt_find_node("/chosen");
-       for (child = fdt_child_node(node); child;
-            child = fdt_next_node(child)) {
-               if (!fdt_node_is_compatible(child, "simple-framebuffer"))
-                       continue;
-               if (fdt_node_property(child, "status", &prop) &&
-                   strcmp(prop, "okay") == 0)
-                       break;
-       }
-       if (child == NULL)
+       if (strlen(framebuffer_path) == 0)
                return;
 
        /* Point stdout-path at the framebuffer node. */
-       strlcpy(path, "/chosen/", sizeof(path));
-       strlcat(path, fdt_node_name(child), sizeof(path));
-       fdt_node_add_property(node, "stdout-path", path, strlen(path) + 1);
+       node = fdt_find_node("/chosen");
+       fdt_node_add_property(node, "stdout-path",
+           framebuffer_path, strlen(framebuffer_path) + 1);
 }
 
 uint64_t dma_constraint[2] = { 0, -1 };