* 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. * include/grub/charset.h (GRUB_MAX_UTF16_PER_UTF8): New definition. * grub-core/normal/charset.c (grub_utf8_process): Move from here ... * include/grub/charset.h (grub_utf8_process): ... to here. Inline. * grub-core/normal/charset.c (grub_utf8_to_utf16): Move from here ... * include/grub/charset.h (grub_utf8_to_utf16): ... to here. Inline.
This commit is contained in:
parent
e33f8d692f
commit
c598862958
6 changed files with 163 additions and 110 deletions
|
@ -182,6 +182,45 @@ 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 (const char *var, const 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;
|
||||
void *data;
|
||||
grub_size_t len, len16;
|
||||
|
||||
len = grub_strlen (var);
|
||||
len16 = len * GRUB_MAX_UTF16_PER_UTF8;
|
||||
var16 = grub_malloc ((len16 + 1) * sizeof (var16[0]));
|
||||
if (!var16)
|
||||
return NULL;
|
||||
len16 = grub_utf8_to_utf16 (var16, len16, (grub_uint8_t *) var, len, NULL);
|
||||
var16[len16] = 0;
|
||||
|
||||
r = grub_efi_system_table->runtime_services;
|
||||
|
||||
status = efi_call_5 (r->get_variable, var16, guid, NULL, &datasize, NULL);
|
||||
|
||||
data = grub_malloc (datasize);
|
||||
if (!data)
|
||||
{
|
||||
grub_free (var16);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
status = efi_call_5 (r->get_variable, var16, guid, NULL, &datasize, data);
|
||||
grub_free (var16);
|
||||
|
||||
if (status == GRUB_EFI_SUCCESS)
|
||||
return data;
|
||||
|
||||
grub_free (data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
grub_uint64_t
|
||||
grub_rtc_get_time_ms (void)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue