[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 18/23] efi: split out efi_exit_boot()
From: |
Daniel Kiper |
Subject: |
[PATCH v2 18/23] efi: split out efi_exit_boot() |
Date: |
Mon, 20 Jul 2015 16:29:13 +0200 |
..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 <address@hidden>
---
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
- [PATCH v2 07/23] x86/boot/reloc: Rename some variables and rearrange code a bit, (continued)
- [PATCH v2 07/23] x86/boot/reloc: Rename some variables and rearrange code a bit, Daniel Kiper, 2015/07/20
- [PATCH v2 06/23] x86/boot: use %ecx instead of %eax, Daniel Kiper, 2015/07/20
- [PATCH v2 05/23] x86/boot/reloc: create generic alloc and copy functions, Daniel Kiper, 2015/07/20
- [PATCH v2 08/23] x86: add multiboot2 protocol support, Daniel Kiper, 2015/07/20
- [PATCH v2 11/23] efi: split out efi_init(), Daniel Kiper, 2015/07/20
- [PATCH v2 12/23] efi: split out efi_console_set_mode(), Daniel Kiper, 2015/07/20
- [PATCH v2 02/23] x86/boot: copy only text section from *.lnk file to *.bin file, Daniel Kiper, 2015/07/20
- [PATCH v2 13/23] efi: split out efi_get_gop(), Daniel Kiper, 2015/07/20
- [PATCH v2 16/23] efi: split out efi_variables(), Daniel Kiper, 2015/07/20
- [PATCH v2 19/23] x86/efi: create new early memory allocator, Daniel Kiper, 2015/07/20
- [PATCH v2 18/23] efi: split out efi_exit_boot(),
Daniel Kiper <=
- [PATCH v2 21/23] x86/boot: implement early command line parser in C, Daniel Kiper, 2015/07/20
- [PATCH v2 20/23] x86: add multiboot2 protocol support for EFI platforms, Daniel Kiper, 2015/07/20
- [PATCH v2 09/23] efi: create efi_enabled(), Daniel Kiper, 2015/07/20
- [PATCH v2 14/23] efi: split out efi_find_gop_mode(), Daniel Kiper, 2015/07/20
- [PATCH v2 10/23] efi: build xen.gz with EFI code, Daniel Kiper, 2015/07/20
- [PATCH v2 22/23] x86: make Xen early boot code relocatable, Daniel Kiper, 2015/07/20
- [PATCH v2 17/23] efi: split out efi_set_gop_mode(), Daniel Kiper, 2015/07/20
- [PATCH v2 15/23] efi: split out efi_tables(), Daniel Kiper, 2015/07/20
- [PATCH v2 23/23] x86: add multiboot2 protocol support for relocatable images, Daniel Kiper, 2015/07/20
- Re: [PATCH v2 00/23] x86: multiboot2 protocol support, Jan Beulich, 2015/07/21