[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/4] Add grub_efi_get_variable
From: |
Matthew Garrett |
Subject: |
[PATCH 2/4] Add grub_efi_get_variable |
Date: |
Wed, 8 Feb 2012 11:51:56 -0500 |
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 <address@hidden>
+ * 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 <address@hidden>
+
* include/grub/efi/pci.h: New file to define EFI PCI protocols.
2012-02-07 Vladimir Serbinenko <address@hidden>
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
[PATCH 4/4] Add support for getting EDID via EFI, Matthew Garrett, 2012/02/08
[PATCH 3/4] Prefer GOP devices which implement the pci_io protocol, Matthew Garrett, 2012/02/08
[PATCH 1/4] Add PCI protocols, Matthew Garrett, 2012/02/08