From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZOss3-0006Ld-1R for mharc-grub-devel@gnu.org; Mon, 10 Aug 2015 15:36:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOsrz-0006GH-MZ for grub-devel@gnu.org; Mon, 10 Aug 2015 15:36:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZOsrw-0003Cw-Ds for grub-devel@gnu.org; Mon, 10 Aug 2015 15:36:27 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:37589) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOsrw-0003Cp-60 for grub-devel@gnu.org; Mon, 10 Aug 2015 15:36:24 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t7AJaEBu028067 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 10 Aug 2015 19:36:14 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t7AJaDmq010366 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 10 Aug 2015 19:36:13 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id t7AJaCpn002686; Mon, 10 Aug 2015 19:36:12 GMT Received: from l.oracle.com (/10.137.176.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 10 Aug 2015 12:36:10 -0700 Received: by l.oracle.com (Postfix, from userid 1000) id 105FA6A3C73; Mon, 10 Aug 2015 15:36:09 -0400 (EDT) Date: Mon, 10 Aug 2015 15:36:08 -0400 From: Konrad Rzeszutek Wilk To: Daniel Kiper Subject: Re: [Xen-devel] [PATCH v2 18/23] efi: split out efi_exit_boot() Message-ID: <20150810193608.GO13576@l.oracle.com> References: <1437402558-7313-1-git-send-email-daniel.kiper@oracle.com> <1437402558-7313-19-git-send-email-daniel.kiper@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437402558-7313-19-git-send-email-daniel.kiper@oracle.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 156.151.31.81 Cc: jgross@suse.com, grub-devel@gnu.org, keir@xen.org, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com, gang.wei@intel.com, roy.franz@linaro.org, ning.sun@intel.com, david.vrabel@citrix.com, jbeulich@suse.com, phcoder@gmail.com, xen-devel@lists.xenproject.org, wei.liu2@citrix.com, richard.l.maliszewski@intel.com, qiaowei.ren@intel.com, fu.wei@linaro.org X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Aug 2015 19:36:29 -0000 On Mon, Jul 20, 2015 at 04:29:13PM +0200, Daniel Kiper wrote: > ..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 Reviewed-by: Konrad Rzeszutek Wilk > --- > 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 > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel