From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZHC5g-0004og-AT for mharc-grub-devel@gnu.org; Mon, 20 Jul 2015 10:30:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHC5a-0004lM-En for grub-devel@gnu.org; Mon, 20 Jul 2015 10:30:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZHC5T-0000tV-QM for grub-devel@gnu.org; Mon, 20 Jul 2015 10:30:42 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:48715) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHC5T-0000tL-I0 for grub-devel@gnu.org; Mon, 20 Jul 2015 10:30:35 -0400 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t6KEUQQM008652 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 20 Jul 2015 14:30:26 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t6KEUQTq006865 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 20 Jul 2015 14:30:26 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t6KEUQ2m027735; Mon, 20 Jul 2015 14:30:26 GMT Received: from olila.local.net-space.pl (/10.175.255.176) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 Jul 2015 07:30:25 -0700 From: Daniel Kiper To: xen-devel@lists.xenproject.org, grub-devel@gnu.org Subject: [PATCH v2 13/23] efi: split out efi_get_gop() Date: Mon, 20 Jul 2015 16:29:08 +0200 Message-Id: <1437402558-7313-14-git-send-email-daniel.kiper@oracle.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1437402558-7313-1-git-send-email-daniel.kiper@oracle.com> References: <1437402558-7313-1-git-send-email-daniel.kiper@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] 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, 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 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, 20 Jul 2015 14:30:46 -0000 ..which gets pointer to GOP device. We want to re-use this code to support multiboot2 protocol on EFI platforms. Signed-off-by: Daniel Kiper --- v2 - suggestions/fixes: - improve commit message (suggested by Jan Beulich). --- xen/common/efi/boot.c | 59 ++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 4614146..6fad230 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -630,6 +630,41 @@ static void __init efi_console_set_mode(void) StdOut->SetMode(StdOut, best); } +static EFI_GRAPHICS_OUTPUT_PROTOCOL __init *efi_get_gop(void) +{ + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info; + EFI_GRAPHICS_OUTPUT_PROTOCOL *gop; + EFI_HANDLE *handles; + EFI_STATUS status; + UINTN info_size, size = 0; + static EFI_GUID __initdata gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; + unsigned int i; + + status = efi_bs->LocateHandle(ByProtocol, &gop_guid, NULL, &size, NULL); + if ( status == EFI_BUFFER_TOO_SMALL ) + status = efi_bs->AllocatePool(EfiLoaderData, size, (void **)&handles); + if ( !EFI_ERROR(status) ) + status = efi_bs->LocateHandle(ByProtocol, &gop_guid, NULL, &size, + handles); + if ( EFI_ERROR(status) ) + size = 0; + for ( i = 0; i < size / sizeof(*handles); ++i ) + { + status = efi_bs->HandleProtocol(handles[i], &gop_guid, (void **)&gop); + if ( EFI_ERROR(status) ) + continue; + status = gop->QueryMode(gop, gop->Mode->Mode, &info_size, &mode_info); + if ( !EFI_ERROR(status) ) + break; + } + if ( handles ) + efi_bs->FreePool(handles); + if ( EFI_ERROR(status) ) + gop = NULL; + + return gop; +} + static void __init setup_efi_pci(void) { EFI_STATUS status; @@ -736,14 +771,12 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) { static EFI_GUID __initdata loaded_image_guid = LOADED_IMAGE_PROTOCOL; - static EFI_GUID __initdata gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; static EFI_GUID __initdata shim_lock_guid = SHIM_LOCK_PROTOCOL_GUID; EFI_LOADED_IMAGE *loaded_image; 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; - EFI_HANDLE *handles = NULL; EFI_SHIM_LOCK_PROTOCOL *shim_lock; EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL; EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info; @@ -837,27 +870,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) &cols, &rows) == EFI_SUCCESS ) efi_arch_console_init(cols, rows); - status = efi_bs->LocateHandle(ByProtocol, &gop_guid, NULL, &size, NULL); - if ( status == EFI_BUFFER_TOO_SMALL ) - status = efi_bs->AllocatePool(EfiLoaderData, size, (void **)&handles); - if ( !EFI_ERROR(status) ) - status = efi_bs->LocateHandle(ByProtocol, &gop_guid, NULL, &size, - handles); - if ( EFI_ERROR(status) ) - size = 0; - for ( i = 0; i < size / sizeof(*handles); ++i ) - { - status = efi_bs->HandleProtocol(handles[i], &gop_guid, (void **)&gop); - if ( EFI_ERROR(status) ) - continue; - status = gop->QueryMode(gop, gop->Mode->Mode, &info_size, &mode_info); - if ( !EFI_ERROR(status) ) - break; - } - if ( handles ) - efi_bs->FreePool(handles); - if ( EFI_ERROR(status) ) - gop = NULL; + gop = efi_get_gop(); /* Get the file system interface. */ dir_handle = get_parent_handle(loaded_image, &file_name); -- 1.7.10.4