Setup mappings for EFI runtime mmio ranges.
This commit is contained in:
parent
1cd5b4302b
commit
77a6cf4b9b
@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.1 2018/10/28 10:21:42 jmcneill Exp
|
||||
#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);
|
||||
|
@ -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_gettime(struct efi_tm *);
|
||||
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 */
|
||||
|
@ -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>
|
||||
@ -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 @@ fdt_setup_initrd(void)
|
||||
|
||||
#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 @@ fdt_map_efi_runtime(const char *prop, bool exec)
|
||||
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 @@ initarm(void *arg)
|
||||
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user