Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/sys/stand/efiboot Pull up following revision(s) (requeste...



details:   https://anonhg.NetBSD.org/src/rev/38c0a6b2d6fb
branches:  netbsd-9
changeset: 962744:38c0a6b2d6fb
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Aug 04 11:37:56 2019 +0000

description:
Pull up following revision(s) (requested by jmcneill in ticket #3):

        sys/stand/efiboot/efiacpi.c: revision 1.4
        sys/stand/efiboot/efifdt.c: revision 1.18
        sys/stand/efiboot/version: revision 1.12
        sys/arch/arm/acpi/acpi_machdep.c: revision 1.7
        sys/arch/arm/acpi/acpi_machdep.c: revision 1.8

Add full UEFI memory map to the /chosen node.

 -

acpi_md_OsMapMemory can be used for both normal and device memory. Use the
UEFI memory map to determine how to map a given region.

Always map ACPI table memory as normal memory. Always map device memory as device memory.

diffstat:

 sys/arch/arm/acpi/acpi_machdep.c |  61 ++++++++++++++++++++++++++++++++++++++-
 sys/stand/efiboot/efiacpi.c      |   4 +-
 sys/stand/efiboot/efifdt.c       |  12 +++---
 sys/stand/efiboot/version        |   3 +-
 4 files changed, 68 insertions(+), 12 deletions(-)

diffs (158 lines):

diff -r 9dd41bbd9932 -r 38c0a6b2d6fb sys/arch/arm/acpi/acpi_machdep.c
--- a/sys/arch/arm/acpi/acpi_machdep.c  Fri Aug 02 05:51:55 2019 +0000
+++ b/sys/arch/arm/acpi/acpi_machdep.c  Sun Aug 04 11:37:56 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.6 2018/11/16 23:03:55 jmcneill Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.6.6.1 2019/08/04 11:37:56 martin Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "pci.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.6 2018/11/16 23:03:55 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.6.6.1 2019/08/04 11:37:56 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -50,6 +50,8 @@
 #include <dev/acpi/acpi_mcfg.h>
 #endif
 
+#include <arm/arm/efi_runtime.h>
+
 #include <arm/pic/picvar.h>
 
 #include <arm/locore.h>
@@ -58,6 +60,55 @@
 
 extern struct bus_space arm_generic_bs_tag;
 
+static int
+acpi_md_pmapflags(paddr_t pa)
+{
+       int len;
+
+       const int chosen = OF_finddevice("/chosen");
+       if (chosen == -1)
+               return 0;
+
+       const uint32_t *map = fdtbus_get_prop(chosen, "netbsd,uefi-memmap", &len);
+       if (map == NULL)
+               return 0;
+
+       while (len >= 28) {
+               const uint32_t type = be32dec(&map[0]);
+               const uint64_t phys_start = be64dec(&map[1]);
+               const uint64_t num_pages = be64dec(&map[3]);
+               const uint64_t attr = be64dec(&map[5]);
+
+               if (pa >= phys_start && pa < phys_start + (num_pages * EFI_PAGE_SIZE)) {
+                       switch (type) {
+                       case EFI_MD_TYPE_RECLAIM:
+                               /* ACPI table memory */
+                               return PMAP_WRITE_BACK;
+
+                       case EFI_MD_TYPE_IOMEM:
+                       case EFI_MD_TYPE_IOPORT:
+                               return PMAP_DEV;
+
+                       default:
+                               if ((attr & EFI_MD_ATTR_WB) != 0)
+                                       return PMAP_WRITE_BACK;
+                               else if ((attr & EFI_MD_ATTR_WC) != 0)
+                                       return PMAP_WRITE_COMBINE;
+                               else if ((attr & EFI_MD_ATTR_WT) != 0)
+                                       return 0;       /* XXX */
+
+                               return PMAP_DEV;
+                       }
+               }
+
+               map += 7;
+               len -= 28;
+       }
+
+       /* Not found; assume device memory */
+       return PMAP_DEV;
+}
+
 ACPI_STATUS
 acpi_md_OsInitialize(void)
 {
@@ -105,8 +156,12 @@
        if (va == 0)
                return AE_NO_MEMORY;
 
+       const int pmapflags = acpi_md_pmapflags(spa);
+
+       aprint_debug("%s: 0x%lx 0x%x flags = %#x\n", __func__, pa, size, pmapflags);
+
        for (curpa = spa, curva = va; curpa < epa; curpa += PAGE_SIZE, curva += PAGE_SIZE)
-               pmap_kenter_pa(curva, curpa, VM_PROT_READ | VM_PROT_WRITE, 0);
+               pmap_kenter_pa(curva, curpa, VM_PROT_READ | VM_PROT_WRITE, pmapflags);
        pmap_update(pmap_kernel());
 
        *vap = (void *)(va + (pa - spa));
diff -r 9dd41bbd9932 -r 38c0a6b2d6fb sys/stand/efiboot/efiacpi.c
--- a/sys/stand/efiboot/efiacpi.c       Fri Aug 02 05:51:55 2019 +0000
+++ b/sys/stand/efiboot/efiacpi.c       Sun Aug 04 11:37:56 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efiacpi.c,v 1.3 2018/10/28 10:17:47 jmcneill Exp $ */
+/* $NetBSD: efiacpi.c,v 1.3.6.1 2019/08/04 11:37:56 martin Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <libfdt.h>
 
-#define        ACPI_FDT_SIZE   (64 * 1024)
+#define        ACPI_FDT_SIZE   (128 * 1024)
 
 static EFI_GUID Acpi20TableGuid = ACPI_20_TABLE_GUID;
 static EFI_GUID Smbios3TableGuid = SMBIOS3_TABLE_GUID;
diff -r 9dd41bbd9932 -r 38c0a6b2d6fb sys/stand/efiboot/efifdt.c
--- a/sys/stand/efiboot/efifdt.c        Fri Aug 02 05:51:55 2019 +0000
+++ b/sys/stand/efiboot/efifdt.c        Sun Aug 04 11:37:56 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.c,v 1.17 2019/07/25 11:44:14 skrll Exp $ */
+/* $NetBSD: efifdt.c,v 1.17.2.1 2019/08/04 11:37:56 martin Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -206,14 +206,14 @@
 
        memmap = LibMemoryMap(&nentries, &mapkey, &descsize, &descver);
        for (n = 0, md = memmap; n < nentries; n++, md = NextMemoryDescriptor(md, descsize)) {
+               fdt_appendprop_u32(fdt_data, fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "netbsd,uefi-memmap", md->Type);
+               fdt_appendprop_u64(fdt_data, fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "netbsd,uefi-memmap", md->PhysicalStart);
+               fdt_appendprop_u64(fdt_data, fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "netbsd,uefi-memmap", md->NumberOfPages);
+               fdt_appendprop_u64(fdt_data, fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "netbsd,uefi-memmap", md->Attribute);
+
                if ((md->Attribute & EFI_MEMORY_RUNTIME) != 0)
                        continue;
 
-               fdt_appendprop_u32(fdt_data, chosen, "netbsd,uefi-memory-map", md->Type);
-               fdt_appendprop_u64(fdt_data, chosen, "netbsd,uefi-memory-map", md->PhysicalStart);
-               fdt_appendprop_u64(fdt_data, chosen, "netbsd,uefi-memory-map", md->NumberOfPages);
-               fdt_appendprop_u64(fdt_data, chosen, "netbsd,uefi-memory-map", md->Attribute);
-
                if ((md->Attribute & EFI_MEMORY_WB) == 0)
                        continue;
                if (!FDT_MEMORY_USABLE(md))
diff -r 9dd41bbd9932 -r 38c0a6b2d6fb sys/stand/efiboot/version
--- a/sys/stand/efiboot/version Fri Aug 02 05:51:55 2019 +0000
+++ b/sys/stand/efiboot/version Sun Aug 04 11:37:56 2019 +0000
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.11 2019/07/24 11:40:36 jmcneill Exp $
+$NetBSD: version,v 1.11.2.1 2019/08/04 11:37:56 martin 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
@@ -15,3 +15,4 @@
 1.8:   Add support for "bootargs" environment variable.
 1.9:   Add support for efiboot.plist and loading device tree overlays.
 1.10:  Add support for EFI GOP framebuffers in ACPI mode.
+1.11:  Add full UEFI memory map to /chosen node.



Home | Main Index | Thread Index | Old Index