From 046f0172c9ead34bbdc03cea45c59ab6a073ba3f Mon Sep 17 00:00:00 2001 From: kettenis Date: Tue, 16 Mar 2021 22:02:27 +0000 Subject: [PATCH] Make sure that switching the console from serial to framebuffer works for framebuffer nodes under / and /chosen. Same change made to arm64 last month. --- sys/arch/armv7/stand/efiboot/conf.c | 4 +-- sys/arch/armv7/stand/efiboot/efiboot.c | 43 ++++++++++++++------------ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/sys/arch/armv7/stand/efiboot/conf.c b/sys/arch/armv7/stand/efiboot/conf.c index 696c1de4c11..4b473fc0c83 100644 --- a/sys/arch/armv7/stand/efiboot/conf.c +++ b/sys/arch/armv7/stand/efiboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.29 2020/12/09 18:10:18 krw Exp $ */ +/* $OpenBSD: conf.c,v 1.30 2021/03/16 22:02:27 kettenis Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -42,7 +42,7 @@ #include "efidev.h" #include "efipxe.h" -const char version[] = "1.16"; +const char version[] = "1.17"; int debug = 0; struct fs_ops file_system[] = { diff --git a/sys/arch/armv7/stand/efiboot/efiboot.c b/sys/arch/armv7/stand/efiboot/efiboot.c index 3784f1653df..71d3db1e945 100644 --- a/sys/arch/armv7/stand/efiboot/efiboot.c +++ b/sys/arch/armv7/stand/efiboot/efiboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efiboot.c,v 1.31 2020/05/17 14:32:12 kettenis Exp $ */ +/* $OpenBSD: efiboot.c,v 1.32 2021/03/16 22:02:27 kettenis Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko @@ -107,6 +107,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) { @@ -351,8 +353,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; @@ -360,8 +367,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); @@ -420,35 +432,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); } void *fdt = NULL; -- 2.20.1