From: Daniel Kiper <daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-ia64-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
xen-devel-GuqFBffKawtpuQazS67q72D2FQJk+8+b@public.gmane.org
Cc: boris.ostrovsky-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org,
david.vrabel-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org,
eshelton-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org,
fenghua.yu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org,
ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org,
jbeulich-IBi9RG/b67k@public.gmane.org,
jeremy-TSDbQ3PG+2Y@public.gmane.org,
konrad.wilk-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org,
matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org,
tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org,
tony.luck-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
Daniel Kiper
<daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
Tang Liang <liang.tang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH v3 1/5] efi: Add efi_init_ops variable
Date: Tue, 25 Mar 2014 21:57:52 +0100 [thread overview]
Message-ID: <1395781076-12000-2-git-send-email-daniel.kiper@oracle.com> (raw)
In-Reply-To: <1395781076-12000-1-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Add efi_init_ops variable which allows us to replace
EFI init functions on Xen with its specific stuff.
This patch is based on Jan Beulich and Tang Liang work.
Signed-off-by: Daniel Kiper <daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Tang Liang <liang.tang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
arch/ia64/kernel/efi.c | 30 +++++++++++++++++++++---------
arch/x86/platform/efi/efi.c | 18 +++++++++++++-----
drivers/firmware/efi/efi.c | 26 ++++++++++++++++++++++++++
include/linux/efi.h | 8 ++++++++
4 files changed, 68 insertions(+), 14 deletions(-)
diff --git a/arch/ia64/kernel/efi.c b/arch/ia64/kernel/efi.c
index da5b462..f646374 100644
--- a/arch/ia64/kernel/efi.c
+++ b/arch/ia64/kernel/efi.c
@@ -468,8 +468,8 @@ efi_map_pal_code (void)
ia64_set_psr(psr); /* restore psr */
}
-void __init
-efi_init (void)
+static void __init
+efi_init_generic (void)
{
void *efi_map_start, *efi_map_end;
efi_char16_t *c16;
@@ -593,8 +593,13 @@ efi_init (void)
efi_enter_virtual_mode();
}
-void
-efi_enter_virtual_mode (void)
+static void
+efi_reserve_boot_services_generic (void)
+{
+}
+
+static void
+efi_enter_virtual_mode_generic (void)
{
void *efi_map_start, *efi_map_end, *p;
efi_memory_desc_t *md;
@@ -751,8 +756,8 @@ efi_memmap_intersects (unsigned long phys_addr, unsigned long size)
return 0;
}
-u32
-efi_mem_type (unsigned long phys_addr)
+static u32
+efi_mem_type_generic (unsigned long phys_addr)
{
efi_memory_desc_t *md = efi_memory_descriptor(phys_addr);
@@ -761,8 +766,8 @@ efi_mem_type (unsigned long phys_addr)
return 0;
}
-u64
-efi_mem_attributes (unsigned long phys_addr)
+static u64
+efi_mem_attributes_generic (unsigned long phys_addr)
{
efi_memory_desc_t *md = efi_memory_descriptor(phys_addr);
@@ -770,7 +775,14 @@ efi_mem_attributes (unsigned long phys_addr)
return md->attribute;
return 0;
}
-EXPORT_SYMBOL(efi_mem_attributes);
+
+struct efi_init_ops efi_init_ops = {
+ .efi_init = efi_init_generic,
+ .efi_reserve_boot_services = efi_reserve_boot_services_generic,
+ .efi_enter_virtual_mode = efi_enter_virtual_mode_generic,
+ .efi_mem_type = efi_mem_type_generic,
+ .efi_mem_attributes = efi_mem_attributes_generic
+};
u64
efi_mem_attribute (unsigned long phys_addr, unsigned long size)
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index b97acec..e4af217 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -422,7 +422,7 @@ static void __init print_efi_memmap(void)
#endif /* EFI_DEBUG */
}
-void __init efi_reserve_boot_services(void)
+static void __init efi_reserve_boot_services_generic(void)
{
void *p;
@@ -700,7 +700,7 @@ out:
return ret;
}
-void __init efi_init(void)
+static void __init efi_init_generic(void)
{
efi_char16_t *c16;
char vendor[100] = "unknown";
@@ -998,7 +998,7 @@ out:
* be passed in via setup_data. In that case runtime ranges will be mapped
* to the same virtual addresses as the first kernel.
*/
-void __init efi_enter_virtual_mode(void)
+static void __init efi_enter_virtual_mode_generic(void)
{
efi_status_t status;
void *new_memmap = NULL;
@@ -1085,7 +1085,7 @@ void __init efi_enter_virtual_mode(void)
/*
* Convenience functions to obtain memory types and attributes
*/
-u32 efi_mem_type(unsigned long phys_addr)
+static u32 efi_mem_type_generic(unsigned long phys_addr)
{
efi_memory_desc_t *md;
void *p;
@@ -1103,7 +1103,7 @@ u32 efi_mem_type(unsigned long phys_addr)
return 0;
}
-u64 efi_mem_attributes(unsigned long phys_addr)
+static u64 efi_mem_attributes_generic(unsigned long phys_addr)
{
efi_memory_desc_t *md;
void *p;
@@ -1118,6 +1118,14 @@ u64 efi_mem_attributes(unsigned long phys_addr)
return 0;
}
+struct efi_init_ops efi_init_ops = {
+ .efi_init = efi_init_generic,
+ .efi_reserve_boot_services = efi_reserve_boot_services_generic,
+ .efi_enter_virtual_mode = efi_enter_virtual_mode_generic,
+ .efi_mem_type = efi_mem_type_generic,
+ .efi_mem_attributes = efi_mem_attributes_generic
+};
+
/*
* Some firmware has serious problems when using more than 50% of the EFI
* variable store, i.e. it triggers bugs that can brick machines. Ensure that
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 4753bac..5ce75cf 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -137,6 +137,32 @@ static void generic_ops_unregister(void)
efivars_unregister(&generic_efivars);
}
+void __init efi_init(void)
+{
+ efi_init_ops.efi_init();
+}
+
+void __init efi_reserve_boot_services(void)
+{
+ efi_init_ops.efi_reserve_boot_services();
+}
+
+void __init efi_enter_virtual_mode(void)
+{
+ efi_init_ops.efi_enter_virtual_mode();
+}
+
+u32 efi_mem_type(unsigned long phys_addr)
+{
+ return efi_init_ops.efi_mem_type(phys_addr);
+}
+
+u64 efi_mem_attributes(unsigned long phys_addr)
+{
+ return efi_init_ops.efi_mem_attributes(phys_addr);
+}
+EXPORT_SYMBOL(efi_mem_attributes);
+
/*
* We register the efi subsystem with the firmware subsystem and the
* efivars subsystem with the efi subsystem, if the system was booted with
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 0a819e7..67ba1a0 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -541,6 +541,14 @@ typedef struct _efi_file_io_interface {
#define EFI_INVALID_TABLE_ADDR (~0UL)
+extern struct efi_init_ops {
+ void (*efi_init)(void);
+ void (*efi_reserve_boot_services)(void);
+ void (*efi_enter_virtual_mode)(void);
+ u32 (*efi_mem_type)(unsigned long phys_addr);
+ u64 (*efi_mem_attributes)(unsigned long phys_addr);
+} efi_init_ops;
+
/*
* All runtime access to EFI goes through this structure:
*/
--
1.7.10.4
next prev parent reply other threads:[~2014-03-25 20:57 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-25 20:57 [PATCH v3 0/5] xen: Add EFI support Daniel Kiper
[not found] ` <1395781076-12000-1-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2014-03-25 20:57 ` Daniel Kiper [this message]
[not found] ` <1395781076-12000-2-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2014-03-26 12:56 ` [PATCH v3 1/5] efi: Add efi_init_ops variable Matt Fleming
2014-03-26 14:02 ` Daniel Kiper
2014-03-26 14:29 ` Matt Fleming
2014-03-25 20:57 ` [PATCH v3 2/5] efi: Export arch_tables variable Daniel Kiper
2014-03-26 13:21 ` Jan Beulich
[not found] ` <5332E25F020000780000255A-ce6RLXgGx+vWGUEhTRrCg1aTQe2KTcn/@public.gmane.org>
2014-03-26 14:08 ` Daniel Kiper
[not found] ` <20140326140800.GP3454-fJNZiO034lp9pOct4yEdx/3oZC3j2Omk@public.gmane.org>
2014-03-26 14:17 ` Jan Beulich
2014-03-26 14:18 ` Matt Fleming
2014-03-25 20:57 ` [PATCH v3 3/5] x86: Call efi_memblock_x86_reserve_range() on native EFI platform only Daniel Kiper
[not found] ` <1395781076-12000-4-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2014-03-26 13:00 ` Matt Fleming
[not found] ` <20140326130009.GB24856-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2014-03-26 13:22 ` Jan Beulich
[not found] ` <5332E2B9020000780000255D-ce6RLXgGx+vWGUEhTRrCg1aTQe2KTcn/@public.gmane.org>
2014-03-26 13:31 ` Matt Fleming
[not found] ` <20140326133119.GD24856-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2014-03-26 13:39 ` Jan Beulich
2014-03-26 13:48 ` Daniel Kiper
[not found] ` <20140326134845.GN3454-fJNZiO034lp9pOct4yEdx/3oZC3j2Omk@public.gmane.org>
2014-03-26 13:57 ` Matt Fleming
2014-03-26 22:01 ` Daniel Kiper
2014-03-26 22:35 ` Andrew Cooper
2014-03-25 20:57 ` [PATCH v3 4/5] xen: Define EFI related stuff Daniel Kiper
2014-03-26 13:25 ` Jan Beulich
2014-03-26 14:58 ` Stefano Stabellini
2014-03-26 15:25 ` Jan Beulich
[not found] ` <5332FF6C02000078000027A5-ce6RLXgGx+vWGUEhTRrCg1aTQe2KTcn/@public.gmane.org>
2014-03-26 15:34 ` Stefano Stabellini
2014-03-25 20:57 ` [PATCH v3 5/5] xen: Put EFI machinery in place Daniel Kiper
[not found] ` <1395781076-12000-6-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2014-03-26 13:12 ` Matt Fleming
[not found] ` <20140326131214.GC24856-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2014-03-26 13:31 ` Jan Beulich
2014-03-26 13:46 ` Matt Fleming
[not found] ` <20140326134617.GE24856-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2014-03-26 13:53 ` Matt Fleming
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=1395781076-12000-2-git-send-email-daniel.kiper@oracle.com \
--to=daniel.kiper-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
--cc=boris.ostrovsky-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=david.vrabel-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org \
--cc=eshelton-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org \
--cc=fenghua.yu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org \
--cc=ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org \
--cc=jbeulich-IBi9RG/b67k@public.gmane.org \
--cc=jeremy-TSDbQ3PG+2Y@public.gmane.org \
--cc=konrad.wilk-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=liang.tang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-ia64-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org \
--cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
--cc=tony.luck-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=xen-devel-GuqFBffKawtpuQazS67q72D2FQJk+8+b@public.gmane.org \
/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).