-/* $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 <yasuoka@yasuoka.net>
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)
{
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;
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);
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;