Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Setup mappings for EFI runtime mmio ranges.
details: https://anonhg.NetBSD.org/src/rev/fe66b422c725
branches: trunk
changeset: 445516:fe66b422c725
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Wed Oct 31 13:01:48 2018 +0000
description:
Setup mappings for EFI runtime mmio ranges.
diffstat:
sys/arch/aarch64/aarch64/efi_machdep.c | 34 ++++++++++++++++++++++++----------
sys/arch/arm/arm/efi_runtime.h | 10 ++++++++--
sys/arch/evbarm/fdt/fdt_machdep.c | 14 ++++++++------
3 files changed, 40 insertions(+), 18 deletions(-)
diffs (129 lines):
diff -r bc01241a7895 -r fe66b422c725 sys/arch/aarch64/aarch64/efi_machdep.c
--- a/sys/arch/aarch64/aarch64/efi_machdep.c Wed Oct 31 13:00:35 2018 +0000
+++ b/sys/arch/aarch64/aarch64/efi_machdep.c Wed Oct 31 13:01:48 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efi_machdep.c,v 1.1 2018/10/28 10:21:42 jmcneill Exp $ */
+/* $NetBSD: efi_machdep.c,v 1.2 2018/10/31 13:01:48 jmcneill Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.1 2018/10/28 10:21:42 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.2 2018/10/31 13:01:48 jmcneill Exp $");
#include <sys/param.h>
#include <uvm/uvm_extern.h>
@@ -39,16 +39,30 @@
#include <arm/arm/efi_runtime.h>
void
-arm_efirt_md_map_range(vaddr_t va, paddr_t pa, size_t sz, bool exec)
+arm_efirt_md_map_range(vaddr_t va, paddr_t pa, size_t sz, enum arm_efirt_mem_type type)
{
pt_entry_t attr;
-
- attr = LX_BLKPAG_OS_READ | LX_BLKPAG_AF | LX_BLKPAG_UXN | LX_BLKPAG_ATTR_NORMAL_WB;
- if (exec)
- attr |= LX_BLKPAG_AP_RO;
- else
- attr |= LX_BLKPAG_AP_RW | LX_BLKPAG_OS_WRITE | LX_BLKPAG_PXN;
-
+
+ switch (type) {
+ case ARM_EFIRT_MEM_CODE:
+ attr = LX_BLKPAG_OS_READ |
+ LX_BLKPAG_AF | LX_BLKPAG_AP_RO | LX_BLKPAG_UXN |
+ LX_BLKPAG_ATTR_NORMAL_WB;
+ break;
+ case ARM_EFIRT_MEM_DATA:
+ attr = LX_BLKPAG_OS_READ | LX_BLKPAG_OS_WRITE |
+ LX_BLKPAG_AF | LX_BLKPAG_AP_RW | LX_BLKPAG_UXN | LX_BLKPAG_PXN |
+ LX_BLKPAG_ATTR_NORMAL_WB;
+ break;
+ case ARM_EFIRT_MEM_MMIO:
+ attr = LX_BLKPAG_OS_READ | LX_BLKPAG_OS_WRITE |
+ LX_BLKPAG_AF | LX_BLKPAG_AP_RW | LX_BLKPAG_UXN | LX_BLKPAG_PXN |
+ LX_BLKPAG_ATTR_DEVICE_MEM;
+ break;
+ default:
+ panic("arm_efirt_md_map_range: unsupported type %d", type);
+ }
+
pmapboot_enter(va, pa, sz, L3_SIZE, attr, 0, bootpage_alloc, NULL);
while (sz >= PAGE_SIZE) {
aarch64_tlbi_by_va(va);
diff -r bc01241a7895 -r fe66b422c725 sys/arch/arm/arm/efi_runtime.h
--- a/sys/arch/arm/arm/efi_runtime.h Wed Oct 31 13:00:35 2018 +0000
+++ b/sys/arch/arm/arm/efi_runtime.h Wed Oct 31 13:01:48 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efi_runtime.h,v 1.1 2018/10/28 10:21:42 jmcneill Exp $ */
+/* $NetBSD: efi_runtime.h,v 1.2 2018/10/31 13:01:48 jmcneill Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -39,6 +39,12 @@
int arm_efirt_settime(struct efi_tm *);
int arm_efirt_reset(enum efi_reset);
-void arm_efirt_md_map_range(vaddr_t, paddr_t, size_t, bool);
+enum arm_efirt_mem_type {
+ ARM_EFIRT_MEM_CODE,
+ ARM_EFIRT_MEM_DATA,
+ ARM_EFIRT_MEM_MMIO,
+};
+
+void arm_efirt_md_map_range(vaddr_t, paddr_t, size_t, enum arm_efirt_mem_type);
#endif /* !_ARM_EFI_RUNTIME_H */
diff -r bc01241a7895 -r fe66b422c725 sys/arch/evbarm/fdt/fdt_machdep.c
--- a/sys/arch/evbarm/fdt/fdt_machdep.c Wed Oct 31 13:00:35 2018 +0000
+++ b/sys/arch/evbarm/fdt/fdt_machdep.c Wed Oct 31 13:01:48 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.50 2018/10/31 09:15:25 skrll Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.51 2018/10/31 13:01:48 jmcneill Exp $ */
/*-
* Copyright (c) 2015-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.50 2018/10/31 09:15:25 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.51 2018/10/31 13:01:48 jmcneill Exp $");
#include "opt_machdep.h"
#include "opt_bootconfig.h"
@@ -388,7 +388,7 @@
#ifdef EFI_RUNTIME
static void
-fdt_map_efi_runtime(const char *prop, bool exec)
+fdt_map_efi_runtime(const char *prop, enum arm_efirt_mem_type type)
{
int len;
@@ -404,7 +404,8 @@
const paddr_t pa = be64toh(map[0]);
const vaddr_t va = be64toh(map[1]);
const uint64_t sz = be64toh(map[2]);
- arm_efirt_md_map_range(va, pa, sz, exec);
+ VPRINTF("%s: %s %lx-%lx (%lx-%lx)\n", __func__, prop, pa, pa+sz-1, va, va+sz-1);
+ arm_efirt_md_map_range(va, pa, sz, type);
map += 3;
len -= 24;
}
@@ -523,8 +524,9 @@
fdt_build_bootconfig(memory_start, memory_end);
#ifdef EFI_RUNTIME
- fdt_map_efi_runtime("netbsd,uefi-runtime-code", true);
- fdt_map_efi_runtime("netbsd,uefi-runtime-data", false);
+ fdt_map_efi_runtime("netbsd,uefi-runtime-code", ARM_EFIRT_MEM_CODE);
+ fdt_map_efi_runtime("netbsd,uefi-runtime-data", ARM_EFIRT_MEM_DATA);
+ fdt_map_efi_runtime("netbsd,uefi-runtime-mmio", ARM_EFIRT_MEM_MMIO);
#endif
/* Perform PT build and VM init */
Home |
Main Index |
Thread Index |
Old Index