Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RvAl7-0000j9-9l for mharc-grub-devel@gnu.org; Wed, 08 Feb 2012 11:52:41 -0500 Received: from eggs.gnu.org ([140.186.70.92]:52433) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvAl0-0000ig-8b for grub-devel@gnu.org; Wed, 08 Feb 2012 11:52:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RvAku-0000dr-Lq for grub-devel@gnu.org; Wed, 08 Feb 2012 11:52:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57175) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvAku-0000dQ-EL for grub-devel@gnu.org; Wed, 08 Feb 2012 11:52:28 -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 q18GqRPc016542 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 8 Feb 2012 11:52:27 -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 q18GqPN0015795 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Wed, 8 Feb 2012 11:52:27 -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 1RvAkq-00011F-JV; Wed, 08 Feb 2012 16:52:25 +0000 From: Matthew Garrett To: grub-devel@gnu.org Subject: [PATCH 2/4] Add grub_efi_get_variable Date: Wed, 8 Feb 2012 11:51:56 -0500 Message-Id: <1328719918-4789-3-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:39 -0000 Code may wish to obtain system information from EFI variables. Add support for making the platform call. --- ChangeLog | 6 ++++++ grub-core/kern/efi/efi.c | 32 ++++++++++++++++++++++++++++++++ include/grub/efi/api.h | 4 ++++ include/grub/efi/efi.h | 3 ++- 4 files changed, 44 insertions(+), 1 deletions(-) diff --git a/ChangeLog b/ChangeLog index ca07786..e662f3d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 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. + +2012-02-08 Matthew Garrett + * include/grub/efi/pci.h: New file to define EFI PCI protocols. 2012-02-07 Vladimir Serbinenko diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index 9a2c5e6..d366f8a 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -182,6 +182,38 @@ grub_efi_set_virtual_address_map (grub_efi_uintn_t memory_map_size, return grub_error (GRUB_ERR_IO, "set_virtual_address_map failed"); } +void * +grub_efi_get_variable(grub_uint8_t *var, grub_efi_guid_t *guid) +{ + grub_efi_status_t status; + grub_efi_uintn_t datasize = 0; + grub_efi_runtime_services_t *r; + grub_efi_char16_t *var16; + int i; + void *data; + + var16 = grub_malloc((grub_strlen((char *)var) +1) * 2); + + for (i=0; i<(int)grub_strlen((char *)var); i++) + var16[i] = var[i]; + var16[i] = '\0'; + + r = grub_efi_system_table->runtime_services; + + status = efi_call_5 (r->get_variable, var16, guid, NULL, &datasize, NULL); + + data = grub_malloc(datasize); + + status = efi_call_5 (r->get_variable, var16, guid, NULL, &datasize, data); + + grub_free(var16); + + if (status == GRUB_EFI_SUCCESS) + return data; + + return NULL; +} + grub_uint64_t grub_rtc_get_time_ms (void) { diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index b3ec663..c954d03 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -1025,6 +1025,10 @@ struct grub_efi_runtime_services grub_efi_status_t (*convert_pointer) (grub_efi_uintn_t debug_disposition, void **address); +#define GRUB_EFI_GLOBAL_VARIABLE_GUID \ + { 0x8BE4DF61, 0x93CA, 0x11d2, { 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B,0x8C }} + + grub_efi_status_t (*get_variable) (grub_efi_char16_t *variable_name, grub_efi_guid_t *vendor_guid, diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 7ecda58..3182972 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -61,7 +61,8 @@ grub_err_t EXPORT_FUNC (grub_efi_set_virtual_address_map) (grub_efi_uintn_t memo grub_efi_uintn_t descriptor_size, grub_efi_uint32_t descriptor_version, grub_efi_memory_descriptor_t *virtual_map); - +void* EXPORT_FUNC (grub_efi_get_variable) (grub_uint8_t *variable, + grub_efi_guid_t *guid); int EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1, const grub_efi_device_path_t *dp2); -- 1.7.7.6