mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-19 19:34:35 +00:00
efi_loader: use efi_create_indexed_name()
Simplify the creation of indexed variable names like 'Boot0000' by using function efi_create_indexed_name(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
This commit is contained in:
parent
60177e0ac2
commit
2ecee31017
1 changed files with 14 additions and 23 deletions
|
@ -227,8 +227,7 @@ static int do_efi_capsule_res(struct cmd_tbl *cmdtp, int flag,
|
||||||
{
|
{
|
||||||
int capsule_id;
|
int capsule_id;
|
||||||
char *endp;
|
char *endp;
|
||||||
char var_name[12];
|
u16 var_name16[12];
|
||||||
u16 var_name16[12], *p;
|
|
||||||
efi_guid_t guid;
|
efi_guid_t guid;
|
||||||
struct efi_capsule_result_variable_header *result = NULL;
|
struct efi_capsule_result_variable_header *result = NULL;
|
||||||
efi_uintn_t size;
|
efi_uintn_t size;
|
||||||
|
@ -259,9 +258,8 @@ static int do_efi_capsule_res(struct cmd_tbl *cmdtp, int flag,
|
||||||
if (capsule_id < 0 || capsule_id > 0xffff)
|
if (capsule_id < 0 || capsule_id > 0xffff)
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
sprintf(var_name, "Capsule%04X", capsule_id);
|
efi_create_indexed_name(var_name16, sizeof(var_name16),
|
||||||
p = var_name16;
|
"Capsule", capsule_id);
|
||||||
utf8_utf16_strncpy(&p, var_name, 9);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size = 0;
|
size = 0;
|
||||||
|
@ -954,8 +952,7 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
char *endp;
|
char *endp;
|
||||||
char var_name[9];
|
u16 var_name16[9];
|
||||||
u16 var_name16[9], *p;
|
|
||||||
efi_guid_t guid;
|
efi_guid_t guid;
|
||||||
size_t label_len, label_len16;
|
size_t label_len, label_len16;
|
||||||
u16 *label;
|
u16 *label;
|
||||||
|
@ -988,9 +985,8 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
|
||||||
if (*endp != '\0' || id > 0xffff)
|
if (*endp != '\0' || id > 0xffff)
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
sprintf(var_name, "Boot%04X", id);
|
efi_create_indexed_name(var_name16, sizeof(var_name16),
|
||||||
p = var_name16;
|
"Boot", id);
|
||||||
utf8_utf16_strncpy(&p, var_name, 9);
|
|
||||||
|
|
||||||
/* label */
|
/* label */
|
||||||
label_len = strlen(argv[2]);
|
label_len = strlen(argv[2]);
|
||||||
|
@ -1107,8 +1103,7 @@ static int do_efi_boot_rm(struct cmd_tbl *cmdtp, int flag,
|
||||||
efi_guid_t guid;
|
efi_guid_t guid;
|
||||||
int id, i;
|
int id, i;
|
||||||
char *endp;
|
char *endp;
|
||||||
char var_name[9];
|
u16 var_name16[9];
|
||||||
u16 var_name16[9], *p;
|
|
||||||
efi_status_t ret;
|
efi_status_t ret;
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
|
@ -1120,10 +1115,8 @@ static int do_efi_boot_rm(struct cmd_tbl *cmdtp, int flag,
|
||||||
if (*endp != '\0' || id > 0xffff)
|
if (*endp != '\0' || id > 0xffff)
|
||||||
return CMD_RET_FAILURE;
|
return CMD_RET_FAILURE;
|
||||||
|
|
||||||
sprintf(var_name, "Boot%04X", id);
|
efi_create_indexed_name(var_name16, sizeof(var_name16),
|
||||||
p = var_name16;
|
"Boot", id);
|
||||||
utf8_utf16_strncpy(&p, var_name, 9);
|
|
||||||
|
|
||||||
ret = EFI_CALL(efi_set_variable(var_name16, &guid, 0, 0, NULL));
|
ret = EFI_CALL(efi_set_variable(var_name16, &guid, 0, 0, NULL));
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("Cannot remove %ls\n", var_name16);
|
printf("Cannot remove %ls\n", var_name16);
|
||||||
|
@ -1313,8 +1306,7 @@ static int show_efi_boot_order(void)
|
||||||
u16 *bootorder;
|
u16 *bootorder;
|
||||||
efi_uintn_t size;
|
efi_uintn_t size;
|
||||||
int num, i;
|
int num, i;
|
||||||
char var_name[9];
|
u16 var_name16[9];
|
||||||
u16 var_name16[9], *p16;
|
|
||||||
void *data;
|
void *data;
|
||||||
struct efi_load_option lo;
|
struct efi_load_option lo;
|
||||||
efi_status_t ret;
|
efi_status_t ret;
|
||||||
|
@ -1344,16 +1336,15 @@ static int show_efi_boot_order(void)
|
||||||
|
|
||||||
num = size / sizeof(u16);
|
num = size / sizeof(u16);
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
sprintf(var_name, "Boot%04X", bootorder[i]);
|
efi_create_indexed_name(var_name16, sizeof(var_name16),
|
||||||
p16 = var_name16;
|
"Boot", i);
|
||||||
utf8_utf16_strncpy(&p16, var_name, 9);
|
|
||||||
|
|
||||||
size = 0;
|
size = 0;
|
||||||
ret = EFI_CALL(efi_get_variable(var_name16,
|
ret = EFI_CALL(efi_get_variable(var_name16,
|
||||||
&efi_global_variable_guid, NULL,
|
&efi_global_variable_guid, NULL,
|
||||||
&size, NULL));
|
&size, NULL));
|
||||||
if (ret != EFI_BUFFER_TOO_SMALL) {
|
if (ret != EFI_BUFFER_TOO_SMALL) {
|
||||||
printf("%2d: %s: (not defined)\n", i + 1, var_name);
|
printf("%2d: %ls: (not defined)\n", i + 1, var_name16);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1378,7 +1369,7 @@ static int show_efi_boot_order(void)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%2d: %s: %ls\n", i + 1, var_name, lo.label);
|
printf("%2d: %ls: %ls\n", i + 1, var_name16, lo.label);
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue