From: Leif Lindholm <leif.lindholm@linaro.org>
To: linux-arm-kernel@lists.infradead.org
Cc: linux-efi@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, patches@linaro.org,
hpa@linux.intel.com, tglx@linutronix.de, matt.fleming@intel.com,
Leif Lindholm <leif.lindholm@linaro.org>
Subject: [PATCH 2/4] x86: efi: break efi_lookup_mapped_addr out to generic code
Date: Tue, 25 Jun 2013 19:11:01 +0100 [thread overview]
Message-ID: <1372183863-11333-3-git-send-email-leif.lindholm@linaro.org> (raw)
In-Reply-To: <1372183863-11333-1-git-send-email-leif.lindholm@linaro.org>
efi_lookup_mapped_addr is a handy helper function for translating
a physical address to the corresponding virtual one by scanning
through memmap.map.
This patch breaks it out into a new file for use elsewhere.
Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
---
arch/x86/platform/efi/efi.c | 28 ----------------------------
drivers/firmware/efi/Makefile | 2 +-
drivers/firmware/efi/efi-helper.c | 33 +++++++++++++++++++++++++++++++++
3 files changed, 34 insertions(+), 29 deletions(-)
create mode 100644 drivers/firmware/efi/efi-helper.c
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 5ae2eb0..d1a1b6b 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -814,34 +814,6 @@ static void __init runtime_code_page_mkexec(void)
}
}
-/*
- * We can't ioremap data in EFI boot services RAM, because we've already mapped
- * it as RAM. So, look it up in the existing EFI memory map instead. Only
- * callable after efi_enter_virtual_mode and before efi_free_boot_services.
- */
-void __iomem *efi_lookup_mapped_addr(u64 phys_addr)
-{
- void *p;
- if (WARN_ON(!memmap.map))
- return NULL;
- for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
- efi_memory_desc_t *md = p;
- u64 size = md->num_pages << EFI_PAGE_SHIFT;
- u64 end = md->phys_addr + size;
- if (!(md->attribute & EFI_MEMORY_RUNTIME) &&
- md->type != EFI_BOOT_SERVICES_CODE &&
- md->type != EFI_BOOT_SERVICES_DATA)
- continue;
- if (!md->virt_addr)
- continue;
- if (phys_addr >= md->phys_addr && phys_addr < end) {
- phys_addr += md->virt_addr - md->phys_addr;
- return (__force void __iomem *)(unsigned long)phys_addr;
- }
- }
- return NULL;
-}
-
void efi_memory_uc(u64 addr, unsigned long size)
{
unsigned long page_shift = 1UL << EFI_PAGE_SHIFT;
diff --git a/drivers/firmware/efi/Makefile b/drivers/firmware/efi/Makefile
index 99245ab..629a513 100644
--- a/drivers/firmware/efi/Makefile
+++ b/drivers/firmware/efi/Makefile
@@ -1,6 +1,6 @@
#
# Makefile for linux kernel
#
-obj-y += efi.o vars.o
+obj-y += efi.o vars.o efi-helper.o
obj-$(CONFIG_EFI_VARS) += efivars.o
obj-$(CONFIG_EFI_VARS_PSTORE) += efi-pstore.o
diff --git a/drivers/firmware/efi/efi-helper.c b/drivers/firmware/efi/efi-helper.c
new file mode 100644
index 0000000..c5c2c72
--- /dev/null
+++ b/drivers/firmware/efi/efi-helper.c
@@ -0,0 +1,33 @@
+/*
+ * Common [U]EFI support helper functions across architectures.
+ */
+
+#include <linux/efi.h>
+
+/*
+ * We can't ioremap data in EFI boot services RAM, because we've already mapped
+ * it as RAM. So, look it up in the existing EFI memory map instead. Only
+ * callable after efi_enter_virtual_mode and before efi_free_boot_services.
+ */
+void __iomem *efi_lookup_mapped_addr(u64 phys_addr)
+{
+ void *p;
+ if (WARN_ON(!memmap.map))
+ return NULL;
+ for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
+ efi_memory_desc_t *md = p;
+ u64 size = md->num_pages << EFI_PAGE_SHIFT;
+ u64 end = md->phys_addr + size;
+ if (!(md->attribute & EFI_MEMORY_RUNTIME) &&
+ md->type != EFI_BOOT_SERVICES_CODE &&
+ md->type != EFI_BOOT_SERVICES_DATA)
+ continue;
+ if (!md->virt_addr)
+ continue;
+ if (phys_addr >= md->phys_addr && phys_addr < end) {
+ phys_addr += md->virt_addr - md->phys_addr;
+ return (__force void __iomem *)(unsigned long)phys_addr;
+ }
+ }
+ return NULL;
+}
--
1.7.10.4
next prev parent reply other threads:[~2013-06-25 18:06 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-25 18:10 [PATCH 0/4] arm: [U]EFI runtime services support Leif Lindholm
2013-06-25 18:11 ` [PATCH 1/4] Documentation: arm: [U]EFI runtime services Leif Lindholm
2013-06-25 18:46 ` Christopher Covington
2013-06-25 23:42 ` Stephen Warren
2013-06-26 13:20 ` Grant Likely
2013-06-26 13:53 ` Leif Lindholm
2013-06-26 13:59 ` Matt Fleming
2013-06-26 14:38 ` James Bottomley
2013-06-27 1:32 ` Matthew Garrett
2013-06-27 6:23 ` Grant Likely
2013-06-27 6:33 ` James Bottomley
2013-06-27 14:37 ` Matthew Garrett
2013-06-27 15:09 ` James Bottomley
2013-06-27 15:37 ` Grant Likely
2013-06-27 17:28 ` Matthew Garrett
2013-06-27 14:54 ` Grant Likely
2013-06-27 15:04 ` James Bottomley
2013-06-27 18:32 ` Russell King - ARM Linux
2013-06-27 9:00 ` Leif Lindholm
2013-06-27 14:38 ` Matthew Garrett
2013-06-27 18:32 ` H. Peter Anvin
2013-06-26 18:32 ` Stephen Warren
2013-06-26 19:31 ` Leif Lindholm
2013-06-27 18:04 ` Stephen Warren
2013-06-27 20:11 ` Grant Likely
2013-06-26 13:13 ` Grant Likely
2013-06-26 14:04 ` Leif Lindholm
2013-06-26 14:35 ` Grant Likely
2013-06-27 14:22 ` Arnd Bergmann
2013-06-30 3:21 ` Rob Landley
2013-06-25 18:11 ` Leif Lindholm [this message]
2013-06-26 13:30 ` [PATCH 2/4] x86: efi: break efi_lookup_mapped_addr out to generic code Grant Likely
2013-06-26 13:32 ` Matt Fleming
2013-06-26 14:11 ` Leif Lindholm
2013-06-26 14:40 ` Matt Fleming
2013-06-25 18:11 ` [PATCH 3/4] arm: Add [U]EFI runtime services support Leif Lindholm
2013-06-25 18:20 ` Matthew Garrett
2013-06-26 13:46 ` Grant Likely
2013-06-26 13:46 ` Grant Likely
2013-06-26 13:54 ` Matt Fleming
2013-06-26 14:15 ` Borislav Petkov
2013-06-26 14:35 ` Grant Likely
2013-06-26 14:22 ` Leif Lindholm
2013-06-25 18:11 ` [PATCH 4/4] init: efi: arm: enable (U)EFI runtime services on arm Leif Lindholm
2013-06-26 13:24 ` Grant Likely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1372183863-11333-3-git-send-email-leif.lindholm@linaro.org \
--to=leif.lindholm@linaro.org \
--cc=hpa@linux.intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.fleming@intel.com \
--cc=patches@linaro.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).