Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RvAlB-0000y6-Oa for mharc-grub-devel@gnu.org; Wed, 08 Feb 2012 11:52:45 -0500 Received: from eggs.gnu.org ([140.186.70.92]:52449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvAl4-0000iu-5j for grub-devel@gnu.org; Wed, 08 Feb 2012 11:52:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RvAkv-0000eG-K4 for grub-devel@gnu.org; Wed, 08 Feb 2012 11:52:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50452) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvAkv-0000dw-8k for grub-devel@gnu.org; Wed, 08 Feb 2012 11:52:29 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q18GqSIu020510 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 8 Feb 2012 11:52:28 -0500 Received: from cavan.codon.org.uk (ovpn-113-122.phx2.redhat.com [10.3.113.122]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q18GqQfG015800 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Wed, 8 Feb 2012 11:52:28 -0500 Received: from nat-pool-rdu.redhat.com ([66.187.233.202] helo=2530p.boston.devel.redhat.com) by cavan.codon.org.uk with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1RvAkr-00011F-Vs; Wed, 08 Feb 2012 16:52:26 +0000 From: Matthew Garrett To: grub-devel@gnu.org Subject: [PATCH 3/4] Prefer GOP devices which implement the pci_io protocol Date: Wed, 8 Feb 2012 11:51:57 -0500 Message-Id: <1328719918-4789-4-git-send-email-mjg@redhat.com> In-Reply-To: <1328719918-4789-1-git-send-email-mjg@redhat.com> References: <1328719918-4789-1-git-send-email-mjg@redhat.com> X-SA-Do-Not-Run: Yes X-SA-Exim-Connect-IP: 66.187.233.202 X-SA-Exim-Mail-From: mjg@redhat.com X-SA-Exim-Scanned: No (on cavan.codon.org.uk); SAEximRunCond expanded to false X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Matthew Garrett 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: Wed, 08 Feb 2012 16:52:44 -0000 Some systems (especially Apple) implement multiple GOP devices representing the same hardware. The preferred device is the one that also implements the PCI io protocol. --- ChangeLog | 5 +++++ grub-core/video/efi_gop.c | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletions(-) diff --git a/ChangeLog b/ChangeLog index e662f3d..26d779b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2012-02-08 Matthew Garrett + * grub-core/video/efi_gop.c (check_protocol): Prefer GOP devices which + implement the pci_io protocol. + +2012-02-08 Matthew Garrett + * grub-core/kern/efi/efi.c (grub_efi_get_variable): Add new function. * include/grub/efi/efi.h: Likewise. * include/grub/efi/api.h: Add guid for EFI-specified variables. diff --git a/grub-core/video/efi_gop.c b/grub-core/video/efi_gop.c index d14ae98..47e3ee9 100644 --- a/grub-core/video/efi_gop.c +++ b/grub-core/video/efi_gop.c @@ -28,11 +28,14 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); static grub_efi_guid_t graphics_output_guid = GRUB_EFI_GOP_GUID; +static grub_efi_guid_t pci_io_guid = GRUB_EFI_PCI_IO_GUID; static struct grub_efi_gop *gop; +static grub_efi_handle_t gop_handle; static unsigned old_mode; static int restore_needed; @@ -47,7 +50,40 @@ static struct static int check_protocol (void) { - gop = grub_efi_locate_protocol (&graphics_output_guid, 0); + grub_efi_handle_t *handle, *handles; + grub_efi_uintn_t num_handles; + + handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL, + &pci_io_guid, NULL, &num_handles); + if (!num_handles || !handles) + return 0; + + for (handle = handles; num_handles--; handle++) + { + gop = grub_efi_open_protocol (*handle, &graphics_output_guid, + GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); + if (gop) + { + gop_handle = *handle; + break; + } + } + + grub_free(handles); + + if (!gop) + { + handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL, + &graphics_output_guid, NULL, &num_handles); + gop = grub_efi_open_protocol (*handles, &graphics_output_guid, + GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); + if (gop) + { + gop_handle = *handles; + } + grub_free(handles); + } + if (gop) return 1; -- 1.7.7.6