/**
* show_efi_boot_opt_data() - dump UEFI load option
*
- * @id: load option number
+ * @varname16: variable name
* @data: value of UEFI load option variable
* @size: size of the boot option
*
* Decode the value of UEFI load option variable and print information.
*/
-static void show_efi_boot_opt_data(int id, void *data, size_t size)
+static void show_efi_boot_opt_data(u16 *varname16, void *data, size_t size)
{
struct efi_load_option lo;
char *label, *p;
p = label;
utf16_utf8_strncpy(&p, lo.label, label_len16);
- printf("Boot%04X:\n", id);
- printf(" attributes: %c%c%c (0x%08x)\n",
+ printf("%ls:\nattributes: %c%c%c (0x%08x)\n",
+ varname16,
/* ACTIVE */
lo.attributes & LOAD_OPTION_ACTIVE ? 'A' : '-',
/* FORCE RECONNECT */
/**
* show_efi_boot_opt() - dump UEFI load option
*
- * @id: Load option number
+ * @varname16: variable name
*
* Dump information defined by UEFI load option.
*/
-static void show_efi_boot_opt(int id)
+static void show_efi_boot_opt(u16 *varname16)
{
- char var_name[9];
- u16 var_name16[9], *p;
- efi_guid_t guid;
- void *data = NULL;
+ void *data;
efi_uintn_t size;
efi_status_t ret;
- sprintf(var_name, "Boot%04X", id);
- p = var_name16;
- utf8_utf16_strncpy(&p, var_name, 9);
- guid = efi_global_variable_guid;
-
size = 0;
- ret = EFI_CALL(RT->get_variable(var_name16, &guid, NULL, &size, NULL));
+ ret = EFI_CALL(efi_get_variable(varname16, &efi_global_variable_guid,
+ NULL, &size, NULL));
if (ret == EFI_BUFFER_TOO_SMALL) {
data = malloc(size);
- ret = EFI_CALL(RT->get_variable(var_name16, &guid, NULL, &size,
- data));
+ if (!data) {
+ printf("ERROR: Out of memory\n");
+ return;
+ }
+ ret = EFI_CALL(efi_get_variable(varname16,
+ &efi_global_variable_guid,
+ NULL, &size, data));
+ if (ret == EFI_SUCCESS)
+ show_efi_boot_opt_data(varname16, data, size);
+ free(data);
}
- if (ret == EFI_SUCCESS)
- show_efi_boot_opt_data(id, data, size);
- else if (ret == EFI_NOT_FOUND)
- printf("Boot%04X: not found\n", id);
-
- free(data);
}
static int u16_tohex(u16 c)
id = (id << 4) + digit;
}
if (i == 4 && !var_name16[8])
- show_efi_boot_opt(id);
+ show_efi_boot_opt(var_name16);
}
free(var_name16);