From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1YHFnE-0002i6-Oz for mharc-grub-devel@gnu.org; Fri, 30 Jan 2015 12:55:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHFn8-0002ec-FK for grub-devel@gnu.org; Fri, 30 Jan 2015 12:55:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YHFn2-0007xX-EG for grub-devel@gnu.org; Fri, 30 Jan 2015 12:55:38 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:22861) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHFn2-0007xO-4E for grub-devel@gnu.org; Fri, 30 Jan 2015 12:55:32 -0500 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t0UHtQaT014351 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 30 Jan 2015 17:55:27 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t0UHtQDF011150 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 30 Jan 2015 17:55:26 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id t0UHtOOb012183; Fri, 30 Jan 2015 17:55:24 GMT Received: from olila.local.net-space.pl (/10.175.253.219) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 30 Jan 2015 09:55:24 -0800 From: Daniel Kiper To: xen-devel@lists.xenproject.org, grub-devel@gnu.org Subject: [PATCH 11/18] efi: create efi_get_gop() Date: Fri, 30 Jan 2015 18:54:15 +0100 Message-Id: <1422640462-28103-12-git-send-email-daniel.kiper@oracle.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1422640462-28103-1-git-send-email-daniel.kiper@oracle.com> References: <1422640462-28103-1-git-send-email-daniel.kiper@oracle.com> X-Source-IP: acsinet22.oracle.com [141.146.126.238] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 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, 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: Fri, 30 Jan 2015 17:55:42 -0000 ..which gets pointer to GOP device. We need this to support multiboot2 protocol on EFI platforms. Signed-off-by: Daniel Kiper --- 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 9ce8a25..6bbcb3b 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -620,6 +620,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; @@ -726,14 +761,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; @@ -825,27 +858,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