git: e49773296c6c - main - kboot: aarch64 bi_loadsmap

From: Warner Losh <imp_at_FreeBSD.org>
Date: Fri, 03 Feb 2023 15:50:47 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=e49773296c6ce3a493260456128e090809249fd4

commit e49773296c6ce3a493260456128e090809249fd4
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-02-03 15:39:46 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-02-03 15:41:40 +0000

    kboot: aarch64 bi_loadsmap
    
    Since aarch64 is different, it needs a different smap. We first see if
    we have the PA of the table from the FDT info. If so, we copy that and
    quit. Otherwise, we do the best we can in translating the /proc/iomap
    into EFI Memory Table format.
    
    We also send the system table to the kernel.
    
    Sponsored by:           Netflix
    Reviewed by:            kevans
    Differential Revision:  https://reviews.freebsd.org/D38255
---
 stand/kboot/arch/aarch64/load_addr.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/stand/kboot/arch/aarch64/load_addr.c b/stand/kboot/arch/aarch64/load_addr.c
index ad71a4f9fbb1..ae8a599645c9 100644
--- a/stand/kboot/arch/aarch64/load_addr.c
+++ b/stand/kboot/arch/aarch64/load_addr.c
@@ -152,3 +152,22 @@ kboot_get_phys_load_segment(void)
 	printf("Falling back to crazy address %#lx\n", s);
 	return (s);
 }
+
+void
+bi_loadsmap(struct preloaded_file *kfp)
+{
+
+	if (efi_systbl_phys)
+		file_addmetadata(kfp, MODINFOMD_FW_HANDLE, sizeof(efi_systbl_phys), &efi_systbl_phys);
+
+	/*
+	 * If we have efi_map_hdr, then it's a pointer to the PA where this
+	 * memory map lives. The trampoline code will copy it over. If we don't
+	 * have it, we use whatever we found in /proc/iomap.
+	 */
+	if (efi_map_hdr != NULL) {
+		file_addmetadata(kfp, MODINFOMD_EFI_MAP, efi_map_size, efi_map_hdr);
+		return;
+	}
+	panic("Can't get UEFI memory map, nor a pointer to it, can't proceed.\n");
+}