2 * Copyright (C) 2015 Linaro Ltd <ard.biesheuvel@linaro.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
11 #include <asm/mach/map.h>
12 #include <asm/mmu_context.h>
14 int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md)
16 struct map_desc desc = {
17 .virtual = md->virt_addr,
18 .pfn = __phys_to_pfn(md->phys_addr),
19 .length = md->num_pages * EFI_PAGE_SIZE,
23 * Order is important here: memory regions may have all of the
24 * bits below set (and usually do), so we check them in order of
27 if (md->attribute & EFI_MEMORY_WB)
28 desc.type = MT_MEMORY_RWX;
29 else if (md->attribute & EFI_MEMORY_WT)
30 desc.type = MT_MEMORY_RWX_NONCACHED;
31 else if (md->attribute & EFI_MEMORY_WC)
32 desc.type = MT_DEVICE_WC;
34 desc.type = MT_DEVICE;
36 create_mapping_late(mm, &desc, true);