Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/stand/efiboot Support EFI runtime and GOP FB for devicet...
details: https://anonhg.NetBSD.org/src/rev/9f9a9110d28d
branches: trunk
changeset: 955760:9f9a9110d28d
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sat Oct 10 19:17:39 2020 +0000
description:
Support EFI runtime and GOP FB for devicetree (non-ACPI) setups.
diffstat:
sys/stand/efiboot/efiacpi.c | 5 +---
sys/stand/efiboot/efifdt.c | 55 ++++++++++++++++++++++++++++++++++----------
sys/stand/efiboot/efifdt.h | 3 +-
sys/stand/efiboot/exec.c | 8 ++----
sys/stand/efiboot/version | 3 +-
5 files changed, 50 insertions(+), 24 deletions(-)
diffs (185 lines):
diff -r 09f7193f4388 -r 9f9a9110d28d sys/stand/efiboot/efiacpi.c
--- a/sys/stand/efiboot/efiacpi.c Sat Oct 10 18:53:56 2020 +0000
+++ b/sys/stand/efiboot/efiacpi.c Sat Oct 10 19:17:39 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efiacpi.c,v 1.7 2020/05/14 19:19:08 riastradh Exp $ */
+/* $NetBSD: efiacpi.c,v 1.8 2020/10/10 19:17:39 jmcneill Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -155,9 +155,6 @@
fdt_setprop_u64(fdt, fdt_path_offset(fdt, "/chosen"), "netbsd,acpi-root-table", (uint64_t)(uintptr_t)acpi_root);
if (smbios3_table)
fdt_setprop_u64(fdt, fdt_path_offset(fdt, "/chosen"), "netbsd,smbios-table", (uint64_t)(uintptr_t)smbios3_table);
-#ifdef EFIBOOT_RUNTIME_ADDRESS
- fdt_setprop_u64(fdt, fdt_path_offset(fdt, "/chosen"), "netbsd,uefi-system-table", (uint64_t)(uintptr_t)ST);
-#endif
fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"), "acpi");
fdt_setprop_string(fdt, fdt_path_offset(fdt, "/acpi"), "compatible", "netbsd,acpi");
diff -r 09f7193f4388 -r 9f9a9110d28d sys/stand/efiboot/efifdt.c
--- a/sys/stand/efiboot/efifdt.c Sat Oct 10 18:53:56 2020 +0000
+++ b/sys/stand/efiboot/efifdt.c Sat Oct 10 19:17:39 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.c,v 1.24 2020/06/21 17:24:26 jmcneill Exp $ */
+/* $NetBSD: efifdt.c,v 1.25 2020/10/10 19:17:39 jmcneill Exp $ */
/*-
* Copyright (c) 2019 Jason R. Thorpe
@@ -30,6 +30,7 @@
#include "efiboot.h"
#include "efifdt.h"
#include "efiblock.h"
+#include "efiacpi.h"
#include <libfdt.h>
@@ -55,6 +56,7 @@
#define PRIxUINTN "x"
#endif
static void *fdt_data = NULL;
+static size_t fdt_data_size = 512*1024;
int
efi_fdt_probe(void)
@@ -76,10 +78,23 @@
int
efi_fdt_set_data(void *data)
{
+ int err;
+
if (fdt_check_header(data) != 0)
return EINVAL;
- fdt_data = data;
+ fdt_data = alloc(fdt_data_size);
+ if (fdt_data == NULL)
+ return ENOMEM;
+ memset(fdt_data, 0, fdt_data_size);
+
+ err = fdt_open_into(data, fdt_data, fdt_data_size);
+ if (err != 0) {
+ dealloc(fdt_data, fdt_data_size);
+ fdt_data = NULL;
+ return ENXIO;
+ }
+
return 0;
}
@@ -202,6 +217,18 @@
}
void
+efi_fdt_system_table(void)
+{
+#ifdef EFIBOOT_RUNTIME_ADDRESS
+ int chosen;
+
+ chosen = efi_fdt_chosen();
+
+ fdt_setprop_u64(fdt_data, chosen, "netbsd,uefi-system-table", (uint64_t)(uintptr_t)ST);
+#endif
+}
+
+void
efi_fdt_memory_map(void)
{
UINTN nentries = 0, mapkey, descsize;
@@ -278,7 +305,7 @@
EFI_HANDLE *gop_handle;
UINTN ngop_handle, n;
char buf[48];
- int fb;
+ int fb, chosen;
status = LibLocateHandle(ByProtocol, &GraphicsOutputProtocol, NULL, &ngop_handle, &gop_handle);
if (EFI_ERROR(status) || ngop_handle == 0)
@@ -311,15 +338,13 @@
continue;
}
- fdt_setprop_u32(fdt_data,
- fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "#address-cells", 2);
- fdt_setprop_u32(fdt_data,
- fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "#size-cells", 2);
- fdt_setprop_empty(fdt_data,
- fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "ranges");
+ chosen = efi_fdt_chosen();
+ fdt_setprop_u32(fdt_data, chosen, "#address-cells", 2);
+ fdt_setprop_u32(fdt_data, chosen, "#size-cells", 2);
+ fdt_setprop_empty(fdt_data, chosen, "ranges");
snprintf(buf, sizeof(buf), "framebuffer@%" PRIx64, mode->FrameBufferBase);
- fb = fdt_add_subnode(fdt_data, fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), buf);
+ fb = fdt_add_subnode(fdt_data, chosen, buf);
if (fb < 0)
panic("FDT: Failed to create framebuffer node");
@@ -332,9 +357,13 @@
fdt_appendprop_u32(fdt_data, fb, "stride", mode->Info->PixelsPerScanLine * 4); /* XXX */
fdt_appendprop_string(fdt_data, fb, "format", "a8b8g8r8");
- snprintf(buf, sizeof(buf), "/chosen/framebuffer@%" PRIx64, mode->FrameBufferBase);
- fdt_setprop_string(fdt_data, fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH),
- "stdout-path", buf);
+ /*
+ * In ACPI mode, use GOP as console.
+ */
+ if (efi_acpi_available()) {
+ snprintf(buf, sizeof(buf), "/chosen/framebuffer@%" PRIx64, mode->FrameBufferBase);
+ fdt_setprop_string(fdt_data, chosen, "stdout-path", buf);
+ }
return;
}
diff -r 09f7193f4388 -r 9f9a9110d28d sys/stand/efiboot/efifdt.h
--- a/sys/stand/efiboot/efifdt.h Sat Oct 10 18:53:56 2020 +0000
+++ b/sys/stand/efiboot/efifdt.h Sat Oct 10 19:17:39 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.h,v 1.9 2020/06/21 17:24:26 jmcneill Exp $ */
+/* $NetBSD: efifdt.h,v 1.10 2020/10/10 19:17:39 jmcneill Exp $ */
/*-
* Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -42,3 +42,4 @@
void efi_fdt_module(const char *, u_long, u_long);
void efi_fdt_init(u_long, u_long);
void efi_fdt_fini(void);
+void efi_fdt_system_table(void);
diff -r 09f7193f4388 -r 9f9a9110d28d sys/stand/efiboot/exec.c
--- a/sys/stand/efiboot/exec.c Sat Oct 10 18:53:56 2020 +0000
+++ b/sys/stand/efiboot/exec.c Sat Oct 10 19:17:39 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: exec.c,v 1.18 2020/06/28 11:39:50 jmcneill Exp $ */
+/* $NetBSD: exec.c,v 1.19 2020/10/10 19:17:39 jmcneill Exp $ */
/*-
* Copyright (c) 2019 Jason R. Thorpe
@@ -315,10 +315,8 @@
efi_fdt_rndseed(rndseed_addr, rndseed_size);
efi_fdt_efirng(efirng_addr, efirng_size);
efi_fdt_bootargs(args);
-#ifdef EFIBOOT_ACPI
- if (efi_acpi_available())
- efi_fdt_gop();
-#endif
+ efi_fdt_system_table();
+ efi_fdt_gop();
efi_fdt_memory_map();
}
diff -r 09f7193f4388 -r 9f9a9110d28d sys/stand/efiboot/version
--- a/sys/stand/efiboot/version Sat Oct 10 18:53:56 2020 +0000
+++ b/sys/stand/efiboot/version Sat Oct 10 19:17:39 2020 +0000
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.19 2020/06/28 11:39:50 jmcneill Exp $
+$NetBSD: version,v 1.20 2020/10/10 19:17:39 jmcneill Exp $
NOTE ANY CHANGES YOU MAKE TO THE EFI BOOTLOADER HERE. The format of this
file is important - make sure the entries are appended on end, last item
@@ -23,3 +23,4 @@
2.0: Add boot.cfg support.
2.1: Remove efiboot.plist support; support dtoverlay in boot.cfg.
2.2: Remove support for storing settings in EFI env vars.
+2.3: EFI RT and GOP support for devicetree mode.
Home |
Main Index |
Thread Index |
Old Index