From: Daniel Kiper <daniel.kiper@oracle.com>
To: xen-devel@lists.xenproject.org, grub-devel@gnu.org
Cc: jgross@suse.com, keir@xen.org, ian.campbell@citrix.com,
andrew.cooper3@citrix.com, stefano.stabellini@eu.citrix.com,
roy.franz@linaro.org, ning.sun@intel.com,
david.vrabel@citrix.com, jbeulich@suse.com, phcoder@gmail.com,
wei.liu2@citrix.com, qiaowei.ren@intel.com,
richard.l.maliszewski@intel.com, gang.wei@intel.com,
fu.wei@linaro.org
Subject: [PATCH v2 18/23] efi: split out efi_exit_boot()
Date: Mon, 20 Jul 2015 16:29:13 +0200 [thread overview]
Message-ID: <1437402558-7313-19-git-send-email-daniel.kiper@oracle.com> (raw)
In-Reply-To: <1437402558-7313-1-git-send-email-daniel.kiper@oracle.com>
..which gets memory map and calls ExitBootServices(). We want to re-use this
code to support multiboot2 protocol on EFI platforms.
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
v2 - suggestions/fixes:
- improve commit message
(suggested by Jan Beulich).
---
xen/common/efi/boot.c | 92 +++++++++++++++++++++++++++----------------------
1 file changed, 50 insertions(+), 42 deletions(-)
diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index 04b9c7e..bf2f198 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -879,6 +879,53 @@ static void __init efi_set_gop_mode(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, UINTN gop
efi_arch_video_init(gop, info_size, mode_info);
}
+static void __init efi_exit_boot(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
+{
+ EFI_STATUS status;
+ UINTN info_size = 0, map_key;
+ bool_t retry;
+
+ efi_bs->GetMemoryMap(&info_size, NULL, &map_key,
+ &efi_mdesc_size, &mdesc_ver);
+ info_size += 8 * efi_mdesc_size;
+ efi_memmap = efi_arch_allocate_mmap_buffer(info_size);
+ if ( !efi_memmap )
+ blexit(L"Unable to allocate memory for EFI memory map");
+
+ for ( retry = 0; ; retry = 1 )
+ {
+ efi_memmap_size = info_size;
+ status = SystemTable->BootServices->GetMemoryMap(&efi_memmap_size,
+ efi_memmap, &map_key,
+ &efi_mdesc_size,
+ &mdesc_ver);
+ if ( EFI_ERROR(status) )
+ PrintErrMesg(L"Cannot obtain memory map", status);
+
+ efi_arch_process_memory_map(SystemTable, efi_memmap, efi_memmap_size,
+ efi_mdesc_size, mdesc_ver);
+
+ efi_arch_pre_exit_boot();
+
+ status = SystemTable->BootServices->ExitBootServices(ImageHandle,
+ map_key);
+ efi_bs = NULL;
+ if ( status != EFI_INVALID_PARAMETER || retry )
+ break;
+ }
+
+ if ( EFI_ERROR(status) )
+ PrintErrMesg(L"Cannot exit boot services", status);
+
+ /* Adjust pointers into EFI. */
+ efi_ct = (void *)efi_ct + DIRECTMAP_VIRT_START;
+#ifdef USE_SET_VIRTUAL_ADDRESS_MAP
+ efi_rs = (void *)efi_rs + DIRECTMAP_VIRT_START;
+#endif
+ efi_memmap = (void *)efi_memmap + DIRECTMAP_VIRT_START;
+ efi_fw_vendor = (void *)efi_fw_vendor + DIRECTMAP_VIRT_START;
+}
+
static int __init __maybe_unused set_color(u32 mask, int bpp, u8 *pos, u8 *sz)
{
if ( bpp < 0 )
@@ -903,11 +950,11 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS status;
unsigned int i, argc;
CHAR16 **argv, *file_name, *cfg_file_name = NULL, *options = NULL;
- UINTN map_key, info_size, gop_mode = ~0;
+ UINTN gop_mode = ~0;
EFI_SHIM_LOCK_PROTOCOL *shim_lock;
EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL;
union string section = { NULL }, name;
- bool_t base_video = 0, retry;
+ bool_t base_video = 0;
char *option_str;
bool_t use_cfg_file;
@@ -1125,46 +1172,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
efi_set_gop_mode(gop, gop_mode);
- info_size = 0;
- efi_bs->GetMemoryMap(&info_size, NULL, &map_key,
- &efi_mdesc_size, &mdesc_ver);
- info_size += 8 * efi_mdesc_size;
- efi_memmap = efi_arch_allocate_mmap_buffer(info_size);
- if ( !efi_memmap )
- blexit(L"Unable to allocate memory for EFI memory map");
-
- for ( retry = 0; ; retry = 1 )
- {
- efi_memmap_size = info_size;
- status = SystemTable->BootServices->GetMemoryMap(&efi_memmap_size,
- efi_memmap, &map_key,
- &efi_mdesc_size,
- &mdesc_ver);
- if ( EFI_ERROR(status) )
- PrintErrMesg(L"Cannot obtain memory map", status);
-
- efi_arch_process_memory_map(SystemTable, efi_memmap, efi_memmap_size,
- efi_mdesc_size, mdesc_ver);
-
- efi_arch_pre_exit_boot();
-
- status = SystemTable->BootServices->ExitBootServices(ImageHandle,
- map_key);
- efi_bs = NULL;
- if ( status != EFI_INVALID_PARAMETER || retry )
- break;
- }
-
- if ( EFI_ERROR(status) )
- PrintErrMesg(L"Cannot exit boot services", status);
-
- /* Adjust pointers into EFI. */
- efi_ct = (void *)efi_ct + DIRECTMAP_VIRT_START;
-#ifdef USE_SET_VIRTUAL_ADDRESS_MAP
- efi_rs = (void *)efi_rs + DIRECTMAP_VIRT_START;
-#endif
- efi_memmap = (void *)efi_memmap + DIRECTMAP_VIRT_START;
- efi_fw_vendor = (void *)efi_fw_vendor + DIRECTMAP_VIRT_START;
+ efi_exit_boot(ImageHandle, SystemTable);
efi_arch_post_exit_boot();
for( ; ; ); /* not reached */
--
1.7.10.4
next prev parent reply other threads:[~2015-07-20 14:31 UTC|newest]
Thread overview: 104+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-20 14:28 [PATCH v2 00/23] x86: multiboot2 protocol support Daniel Kiper
2015-07-20 14:28 ` [PATCH v2 01/23] x86/boot: remove unneeded instruction Daniel Kiper
2015-07-24 16:22 ` Konrad Rzeszutek Wilk
2015-07-27 19:46 ` Daniel Kiper
2015-08-10 16:07 ` Konrad Rzeszutek Wilk
2015-07-20 14:28 ` [PATCH v2 02/23] x86/boot: copy only text section from *.lnk file to *.bin file Daniel Kiper
2015-07-20 14:28 ` [PATCH v2 03/23] x86: zero BSS using stosl instead of stosb Daniel Kiper
2015-07-20 14:28 ` [PATCH v2 04/23] x86/boot: call reloc() using cdecl calling convention Daniel Kiper
2015-08-10 16:33 ` [Xen-devel] " Konrad Rzeszutek Wilk
2015-08-17 15:44 ` Jan Beulich
2015-07-20 14:29 ` [PATCH v2 05/23] x86/boot/reloc: create generic alloc and copy functions Daniel Kiper
2015-08-17 15:51 ` Jan Beulich
2015-08-17 22:03 ` Daniel Kiper
2015-07-20 14:29 ` [PATCH v2 06/23] x86/boot: use %ecx instead of %eax Daniel Kiper
2015-08-10 16:36 ` [Xen-devel] " Konrad Rzeszutek Wilk
2015-07-20 14:29 ` [PATCH v2 07/23] x86/boot/reloc: Rename some variables and rearrange code a bit Daniel Kiper
2015-08-10 16:40 ` [Xen-devel] " Konrad Rzeszutek Wilk
2015-08-17 15:55 ` Jan Beulich
2015-07-20 14:29 ` [PATCH v2 08/23] x86: add multiboot2 protocol support Daniel Kiper
2015-08-10 19:17 ` [Xen-devel] " Konrad Rzeszutek Wilk
2015-08-13 19:22 ` Daniel Kiper
2015-08-14 10:03 ` Jan Beulich
2015-08-15 6:00 ` Andrew Cooper
2015-08-18 8:12 ` Jan Beulich
2015-08-18 12:00 ` Daniel Kiper
2015-08-18 14:20 ` Jan Beulich
2015-07-20 14:29 ` [PATCH v2 09/23] efi: create efi_enabled() Daniel Kiper
2015-08-10 19:20 ` [Xen-devel] " Konrad Rzeszutek Wilk
2015-08-20 15:18 ` Jan Beulich
2015-08-22 12:33 ` Daniel Kiper
2015-08-24 11:29 ` Jan Beulich
2015-07-20 14:29 ` [PATCH v2 10/23] efi: build xen.gz with EFI code Daniel Kiper
2015-08-10 19:24 ` [Xen-devel] " Konrad Rzeszutek Wilk
2015-08-20 15:39 ` Jan Beulich
2015-08-22 13:59 ` Daniel Kiper
2015-08-24 11:35 ` Jan Beulich
2015-08-24 20:54 ` Daniel Kiper
2015-08-25 10:50 ` Andrew Cooper
2015-08-25 15:39 ` Daniel Kiper
2015-08-25 12:09 ` Jan Beulich
2015-08-25 16:31 ` Daniel Kiper
2015-08-26 6:46 ` Jan Beulich
2015-08-26 12:33 ` Daniel Kiper
2015-08-26 12:40 ` Jan Beulich
2015-08-26 12:58 ` Daniel Kiper
2015-07-20 14:29 ` [PATCH v2 11/23] efi: split out efi_init() Daniel Kiper
2015-08-10 19:25 ` [Xen-devel] " Konrad Rzeszutek Wilk
2015-07-20 14:29 ` [PATCH v2 12/23] efi: split out efi_console_set_mode() Daniel Kiper
2015-08-10 19:25 ` [Xen-devel] " Konrad Rzeszutek Wilk
2015-07-20 14:29 ` [PATCH v2 13/23] efi: split out efi_get_gop() Daniel Kiper
2015-08-10 19:27 ` [Xen-devel] " Konrad Rzeszutek Wilk
2015-07-20 14:29 ` [PATCH v2 14/23] efi: split out efi_find_gop_mode() Daniel Kiper
2015-08-10 19:31 ` [Xen-devel] " Konrad Rzeszutek Wilk
2015-08-20 15:48 ` Jan Beulich
2015-07-20 14:29 ` [PATCH v2 15/23] efi: split out efi_tables() Daniel Kiper
2015-08-10 19:32 ` [Xen-devel] " Konrad Rzeszutek Wilk
2015-07-20 14:29 ` [PATCH v2 16/23] efi: split out efi_variables() Daniel Kiper
2015-08-10 19:34 ` [Xen-devel] " Konrad Rzeszutek Wilk
2015-07-20 14:29 ` [PATCH v2 17/23] efi: split out efi_set_gop_mode() Daniel Kiper
2015-08-10 19:34 ` [Xen-devel] " Konrad Rzeszutek Wilk
2015-07-20 14:29 ` Daniel Kiper [this message]
2015-08-10 19:36 ` [Xen-devel] [PATCH v2 18/23] efi: split out efi_exit_boot() Konrad Rzeszutek Wilk
2015-07-20 14:29 ` [PATCH v2 19/23] x86/efi: create new early memory allocator Daniel Kiper
2015-08-10 19:49 ` [Xen-devel] " Konrad Rzeszutek Wilk
2015-08-27 11:23 ` Jan Beulich
2015-07-20 14:29 ` [PATCH v2 20/23] x86: add multiboot2 protocol support for EFI platforms Daniel Kiper
2015-08-10 20:07 ` [Xen-devel] " Konrad Rzeszutek Wilk
2015-08-11 15:23 ` Konrad Rzeszutek Wilk
2015-08-27 12:01 ` Jan Beulich
2015-09-22 15:21 ` Daniel Kiper
2015-09-22 15:58 ` Jan Beulich
2015-07-20 14:29 ` [PATCH v2 21/23] x86/boot: implement early command line parser in C Daniel Kiper
2015-08-10 20:31 ` [Xen-devel] " Konrad Rzeszutek Wilk
2015-08-11 14:43 ` Konrad Rzeszutek Wilk
2015-08-27 12:43 ` Jan Beulich
2015-09-22 17:03 ` Daniel Kiper
2015-09-23 7:25 ` Jan Beulich
2015-07-20 14:29 ` [PATCH v2 22/23] x86: make Xen early boot code relocatable Daniel Kiper
2015-08-11 16:48 ` [Xen-devel] " Konrad Rzeszutek Wilk
2015-08-14 11:52 ` Daniel Kiper
2015-08-14 12:49 ` Jan Beulich
2015-08-14 13:59 ` Daniel Kiper
2015-08-14 14:32 ` Jan Beulich
2015-08-14 14:37 ` Daniel Kiper
2015-08-14 15:12 ` Jan Beulich
2015-08-14 15:20 ` Konrad Rzeszutek Wilk
2015-08-27 13:12 ` Jan Beulich
2015-08-27 15:10 ` Daniel Kiper
2015-08-27 15:29 ` Jan Beulich
2015-08-27 17:56 ` Ben Hildred
2015-08-28 8:22 ` [Xen-devel] " Jan Beulich
2015-08-28 13:42 ` Konrad Rzeszutek Wilk
2015-08-28 14:16 ` Jan Beulich
2015-08-31 19:49 ` Daniel Kiper
2015-09-01 6:59 ` Jan Beulich
2015-08-27 18:04 ` Andrew Cooper
2015-08-28 6:54 ` Jan Beulich
2015-08-28 11:59 ` Andrew Cooper
2015-08-28 14:24 ` [Xen-devel] " Jan Beulich
2015-07-20 14:29 ` [PATCH v2 23/23] x86: add multiboot2 protocol support for relocatable images Daniel Kiper
2015-08-11 16:56 ` Konrad Rzeszutek Wilk
2015-08-14 11:57 ` Daniel Kiper
2015-08-14 13:43 ` Konrad Rzeszutek Wilk
2015-07-21 9:39 ` [PATCH v2 00/23] x86: multiboot2 protocol support Jan Beulich
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=1437402558-7313-19-git-send-email-daniel.kiper@oracle.com \
--to=daniel.kiper@oracle.com \
--cc=andrew.cooper3@citrix.com \
--cc=david.vrabel@citrix.com \
--cc=fu.wei@linaro.org \
--cc=gang.wei@intel.com \
--cc=grub-devel@gnu.org \
--cc=ian.campbell@citrix.com \
--cc=jbeulich@suse.com \
--cc=jgross@suse.com \
--cc=keir@xen.org \
--cc=ning.sun@intel.com \
--cc=phcoder@gmail.com \
--cc=qiaowei.ren@intel.com \
--cc=richard.l.maliszewski@intel.com \
--cc=roy.franz@linaro.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.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).