efi: Use 16-bit unicode strings

At present we use wide characters for unicode but this is not necessary.
Change the code to use the 'u' literal instead. This helps to fix build
warnings for sandbox on rpi.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
Simon Glass 2022-01-23 12:55:12 -07:00 committed by Tom Rini
parent 587254ebcf
commit 156ccbc3c4
34 changed files with 267 additions and 267 deletions

View file

@ -240,7 +240,7 @@ static int do_efi_capsule_res(struct cmd_tbl *cmdtp, int flag,
guid = efi_guid_capsule_report; guid = efi_guid_capsule_report;
if (argc == 1) { if (argc == 1) {
size = sizeof(var_name16); size = sizeof(var_name16);
ret = efi_get_variable_int(L"CapsuleLast", &guid, NULL, ret = efi_get_variable_int(u"CapsuleLast", &guid, NULL,
&size, var_name16, NULL); &size, var_name16, NULL);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
@ -1120,7 +1120,7 @@ static int do_efi_boot_dump(struct cmd_tbl *cmdtp, int flag,
return CMD_RET_FAILURE; return CMD_RET_FAILURE;
} }
if (memcmp(var_name16, L"Boot", 8)) if (memcmp(var_name16, u"Boot", 8))
continue; continue;
for (id = 0, i = 0; i < 4; i++) { for (id = 0, i = 0; i < 4; i++) {
@ -1156,7 +1156,7 @@ static int show_efi_boot_order(void)
efi_status_t ret; efi_status_t ret;
size = 0; size = 0;
ret = EFI_CALL(efi_get_variable(L"BootOrder", &efi_global_variable_guid, ret = EFI_CALL(efi_get_variable(u"BootOrder", &efi_global_variable_guid,
NULL, &size, NULL)); NULL, &size, NULL));
if (ret != EFI_BUFFER_TOO_SMALL) { if (ret != EFI_BUFFER_TOO_SMALL) {
if (ret == EFI_NOT_FOUND) { if (ret == EFI_NOT_FOUND) {
@ -1171,7 +1171,7 @@ static int show_efi_boot_order(void)
printf("ERROR: Out of memory\n"); printf("ERROR: Out of memory\n");
return CMD_RET_FAILURE; return CMD_RET_FAILURE;
} }
ret = EFI_CALL(efi_get_variable(L"BootOrder", &efi_global_variable_guid, ret = EFI_CALL(efi_get_variable(u"BootOrder", &efi_global_variable_guid,
NULL, &size, bootorder)); NULL, &size, bootorder));
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
ret = CMD_RET_FAILURE; ret = CMD_RET_FAILURE;
@ -1260,11 +1260,11 @@ static int do_efi_boot_next(struct cmd_tbl *cmdtp, int flag,
guid = efi_global_variable_guid; guid = efi_global_variable_guid;
size = sizeof(u16); size = sizeof(u16);
ret = efi_set_variable_int(L"BootNext", &guid, ret = efi_set_variable_int(u"BootNext", &guid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS, EFI_VARIABLE_RUNTIME_ACCESS,
size, &bootnext, false); size, &bootnext, false);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
printf("Cannot set BootNext\n"); printf("Cannot set BootNext\n");
r = CMD_RET_FAILURE; r = CMD_RET_FAILURE;
@ -1321,11 +1321,11 @@ static int do_efi_boot_order(struct cmd_tbl *cmdtp, int flag,
} }
guid = efi_global_variable_guid; guid = efi_global_variable_guid;
ret = efi_set_variable_int(L"BootOrder", &guid, ret = efi_set_variable_int(u"BootOrder", &guid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS, EFI_VARIABLE_RUNTIME_ACCESS,
size, bootorder, true); size, bootorder, true);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
printf("Cannot set BootOrder\n"); printf("Cannot set BootOrder\n");
r = CMD_RET_FAILURE; r = CMD_RET_FAILURE;

View file

@ -974,7 +974,7 @@ efi_status_t efi_capsule_authenticate(const void *capsule,
efi_uintn_t capsule_size, efi_uintn_t capsule_size,
void **image, efi_uintn_t *image_size); void **image, efi_uintn_t *image_size);
#define EFI_CAPSULE_DIR L"\\EFI\\UpdateCapsule\\" #define EFI_CAPSULE_DIR u"\\EFI\\UpdateCapsule\\"
/** /**
* Install the ESRT system table. * Install the ESRT system table.

View file

@ -16,7 +16,7 @@
#define EFI_ST_SUCCESS 0 #define EFI_ST_SUCCESS 0
#define EFI_ST_FAILURE 1 #define EFI_ST_FAILURE 1
#define EFI_ST_SUCCESS_STR L"SUCCESS" #define EFI_ST_SUCCESS_STR u"SUCCESS"
/** /**
* efi_st_printf() - print a message * efi_st_printf() - print a message
@ -111,7 +111,7 @@ u16 *efi_st_translate_char(u16 code);
* efi_st_translate_code() - translate a scan code to a human readable string * efi_st_translate_code() - translate a scan code to a human readable string
* *
* This function translates the scan code returned by the simple text input * This function translates the scan code returned by the simple text input
* protocol to a human readable string, e.g. 0x04 is translated to L"Left". * protocol to a human readable string, e.g. 0x04 is translated to u"Left".
* *
* @code: scan code * @code: scan code
* Return: Unicode string * Return: Unicode string

View file

@ -46,8 +46,8 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle,
void **load_options) void **load_options)
{ {
struct efi_load_option lo; struct efi_load_option lo;
u16 varname[] = L"Boot0000"; u16 varname[] = u"Boot0000";
u16 hexmap[] = L"0123456789ABCDEF"; u16 hexmap[] = u"0123456789ABCDEF";
void *load_option; void *load_option;
efi_uintn_t size; efi_uintn_t size;
efi_status_t ret; efi_status_t ret;
@ -83,7 +83,7 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle,
attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS; EFI_VARIABLE_RUNTIME_ACCESS;
ret = efi_set_variable_int(L"BootCurrent", ret = efi_set_variable_int(u"BootCurrent",
&efi_global_variable_guid, &efi_global_variable_guid,
attributes, sizeof(n), &n, false); attributes, sizeof(n), &n, false);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
@ -149,7 +149,7 @@ efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options)
/* BootNext */ /* BootNext */
size = sizeof(bootnext); size = sizeof(bootnext);
ret = efi_get_variable_int(L"BootNext", ret = efi_get_variable_int(u"BootNext",
&efi_global_variable_guid, &efi_global_variable_guid,
NULL, &size, &bootnext, NULL); NULL, &size, &bootnext, NULL);
if (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL) { if (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL) {
@ -158,7 +158,7 @@ efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options)
log_err("BootNext must be 16-bit integer\n"); log_err("BootNext must be 16-bit integer\n");
/* delete BootNext */ /* delete BootNext */
ret = efi_set_variable_int(L"BootNext", ret = efi_set_variable_int(u"BootNext",
&efi_global_variable_guid, &efi_global_variable_guid,
0, 0, NULL, false); 0, 0, NULL, false);
@ -178,7 +178,7 @@ efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options)
} }
/* BootOrder */ /* BootOrder */
bootorder = efi_get_var(L"BootOrder", &efi_global_variable_guid, &size); bootorder = efi_get_var(u"BootOrder", &efi_global_variable_guid, &size);
if (!bootorder) { if (!bootorder) {
log_info("BootOrder not defined\n"); log_info("BootOrder not defined\n");
ret = EFI_NOT_FOUND; ret = EFI_NOT_FOUND;

View file

@ -3778,7 +3778,7 @@ static struct efi_boot_services efi_boot_services = {
.create_event_ex = efi_create_event_ex, .create_event_ex = efi_create_event_ex,
}; };
static u16 __efi_runtime_data firmware_vendor[] = L"Das U-Boot"; static u16 __efi_runtime_data firmware_vendor[] = u"Das U-Boot";
struct efi_system_table __efi_runtime_data systab = { struct efi_system_table __efi_runtime_data systab = {
.hdr = { .hdr = {

View file

@ -56,10 +56,10 @@ static __maybe_unused unsigned int get_last_capsule(void)
int i; int i;
size = sizeof(value16); size = sizeof(value16);
ret = efi_get_variable_int(L"CapsuleLast", &efi_guid_capsule_report, ret = efi_get_variable_int(u"CapsuleLast", &efi_guid_capsule_report,
NULL, &size, value16, NULL); NULL, &size, value16, NULL);
if (ret != EFI_SUCCESS || size != 22 || if (ret != EFI_SUCCESS || size != 22 ||
u16_strncmp(value16, L"Capsule", 7)) u16_strncmp(value16, u"Capsule", 7))
goto err; goto err;
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
u16 c = value16[i + 7]; u16 c = value16[i + 7];
@ -113,14 +113,14 @@ void set_capsule_result(int index, struct efi_capsule_header *capsule,
} }
/* Variable CapsuleLast must not include terminating 0x0000 */ /* Variable CapsuleLast must not include terminating 0x0000 */
ret = efi_set_variable_int(L"CapsuleLast", &efi_guid_capsule_report, ret = efi_set_variable_int(u"CapsuleLast", &efi_guid_capsule_report,
EFI_VARIABLE_READ_ONLY | EFI_VARIABLE_READ_ONLY |
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS, EFI_VARIABLE_RUNTIME_ACCESS,
22, variable_name16, false); 22, variable_name16, false);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
log_err("Setting %ls failed\n", L"CapsuleLast"); log_err("Setting %ls failed\n", u"CapsuleLast");
} }
#ifdef CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT #ifdef CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT
@ -707,7 +707,7 @@ static efi_status_t find_boot_device(void)
/* find active boot device in BootNext */ /* find active boot device in BootNext */
bootnext = 0; bootnext = 0;
size = sizeof(bootnext); size = sizeof(bootnext);
ret = efi_get_variable_int(L"BootNext", ret = efi_get_variable_int(u"BootNext",
(efi_guid_t *)&efi_global_variable_guid, (efi_guid_t *)&efi_global_variable_guid,
NULL, &size, &bootnext, NULL); NULL, &size, &bootnext, NULL);
if (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL) { if (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL) {
@ -734,7 +734,7 @@ static efi_status_t find_boot_device(void)
skip: skip:
/* find active boot device in BootOrder */ /* find active boot device in BootOrder */
size = 0; size = 0;
ret = efi_get_variable_int(L"BootOrder", &efi_global_variable_guid, ret = efi_get_variable_int(u"BootOrder", &efi_global_variable_guid,
NULL, &size, NULL, NULL); NULL, &size, NULL, NULL);
if (ret == EFI_BUFFER_TOO_SMALL) { if (ret == EFI_BUFFER_TOO_SMALL) {
boot_order = malloc(size); boot_order = malloc(size);
@ -743,7 +743,7 @@ skip:
goto out; goto out;
} }
ret = efi_get_variable_int(L"BootOrder", ret = efi_get_variable_int(u"BootOrder",
&efi_global_variable_guid, &efi_global_variable_guid,
NULL, &size, boot_order, NULL); NULL, &size, boot_order, NULL);
} }
@ -875,8 +875,8 @@ static efi_status_t efi_capsule_scan_dir(u16 ***files, unsigned int *num)
break; break;
if (!(dirent->attribute & EFI_FILE_DIRECTORY) && if (!(dirent->attribute & EFI_FILE_DIRECTORY) &&
u16_strcmp(dirent->file_name, L".") && u16_strcmp(dirent->file_name, u".") &&
u16_strcmp(dirent->file_name, L"..")) u16_strcmp(dirent->file_name, u".."))
tmp_files[count++] = u16_strdup(dirent->file_name); tmp_files[count++] = u16_strdup(dirent->file_name);
} }
/* ignore an error */ /* ignore an error */
@ -1052,7 +1052,7 @@ static efi_status_t check_run_capsules(void)
efi_status_t r; efi_status_t r;
size = sizeof(os_indications); size = sizeof(os_indications);
r = efi_get_variable_int(L"OsIndications", &efi_global_variable_guid, r = efi_get_variable_int(u"OsIndications", &efi_global_variable_guid,
NULL, &size, &os_indications, NULL); NULL, &size, &os_indications, NULL);
if (r != EFI_SUCCESS || size != sizeof(os_indications)) if (r != EFI_SUCCESS || size != sizeof(os_indications))
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
@ -1061,7 +1061,7 @@ static efi_status_t check_run_capsules(void)
EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED) { EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED) {
os_indications &= os_indications &=
~EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED; ~EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED;
r = efi_set_variable_int(L"OsIndications", r = efi_set_variable_int(u"OsIndications",
&efi_global_variable_guid, &efi_global_variable_guid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS |

View file

@ -36,7 +36,7 @@ static efi_status_t efi_create_current_boot_var(u16 var_name[],
u16 *pos; u16 *pos;
boot_current_size = sizeof(boot_current); boot_current_size = sizeof(boot_current);
ret = efi_get_variable_int(L"BootCurrent", ret = efi_get_variable_int(u"BootCurrent",
&efi_global_variable_guid, NULL, &efi_global_variable_guid, NULL,
&boot_current_size, &boot_current, NULL); &boot_current_size, &boot_current, NULL);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)

View file

@ -532,13 +532,13 @@ static bool efi_image_unsigned_authenticate(struct efi_image_regions *regs)
struct efi_signature_store *db = NULL, *dbx = NULL; struct efi_signature_store *db = NULL, *dbx = NULL;
bool ret = false; bool ret = false;
dbx = efi_sigstore_parse_sigdb(L"dbx"); dbx = efi_sigstore_parse_sigdb(u"dbx");
if (!dbx) { if (!dbx) {
EFI_PRINT("Getting signature database(dbx) failed\n"); EFI_PRINT("Getting signature database(dbx) failed\n");
goto out; goto out;
} }
db = efi_sigstore_parse_sigdb(L"db"); db = efi_sigstore_parse_sigdb(u"db");
if (!db) { if (!db) {
EFI_PRINT("Getting signature database(db) failed\n"); EFI_PRINT("Getting signature database(db) failed\n");
goto out; goto out;
@ -621,13 +621,13 @@ static bool efi_image_authenticate(void *efi, size_t efi_size)
/* /*
* verify signature using db and dbx * verify signature using db and dbx
*/ */
db = efi_sigstore_parse_sigdb(L"db"); db = efi_sigstore_parse_sigdb(u"db");
if (!db) { if (!db) {
EFI_PRINT("Getting signature database(db) failed\n"); EFI_PRINT("Getting signature database(db) failed\n");
goto err; goto err;
} }
dbx = efi_sigstore_parse_sigdb(L"dbx"); dbx = efi_sigstore_parse_sigdb(u"dbx");
if (!dbx) { if (!dbx) {
EFI_PRINT("Getting signature database(dbx) failed\n"); EFI_PRINT("Getting signature database(dbx) failed\n");
goto err; goto err;

View file

@ -43,7 +43,7 @@ static efi_status_t efi_init_platform_lang(void)
* Variable PlatformLangCodes defines the language codes that the * Variable PlatformLangCodes defines the language codes that the
* machine can support. * machine can support.
*/ */
ret = efi_set_variable_int(L"PlatformLangCodes", ret = efi_set_variable_int(u"PlatformLangCodes",
&efi_global_variable_guid, &efi_global_variable_guid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS |
@ -57,7 +57,7 @@ static efi_status_t efi_init_platform_lang(void)
* Variable PlatformLang defines the language that the machine has been * Variable PlatformLang defines the language that the machine has been
* configured for. * configured for.
*/ */
ret = efi_get_variable_int(L"PlatformLang", ret = efi_get_variable_int(u"PlatformLang",
&efi_global_variable_guid, &efi_global_variable_guid,
NULL, &data_size, &pos, NULL); NULL, &data_size, &pos, NULL);
if (ret == EFI_BUFFER_TOO_SMALL) { if (ret == EFI_BUFFER_TOO_SMALL) {
@ -74,7 +74,7 @@ static efi_status_t efi_init_platform_lang(void)
if (pos) if (pos)
*pos = 0; *pos = 0;
ret = efi_set_variable_int(L"PlatformLang", ret = efi_set_variable_int(u"PlatformLang",
&efi_global_variable_guid, &efi_global_variable_guid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS |
@ -100,7 +100,7 @@ static efi_status_t efi_init_secure_boot(void)
}; };
efi_status_t ret; efi_status_t ret;
ret = efi_set_variable_int(L"SignatureSupport", ret = efi_set_variable_int(u"SignatureSupport",
&efi_global_variable_guid, &efi_global_variable_guid,
EFI_VARIABLE_READ_ONLY | EFI_VARIABLE_READ_ONLY |
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS |
@ -129,12 +129,12 @@ static efi_status_t efi_init_capsule(void)
efi_status_t ret = EFI_SUCCESS; efi_status_t ret = EFI_SUCCESS;
if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_UPDATE)) { if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_UPDATE)) {
ret = efi_set_variable_int(L"CapsuleMax", ret = efi_set_variable_int(u"CapsuleMax",
&efi_guid_capsule_report, &efi_guid_capsule_report,
EFI_VARIABLE_READ_ONLY | EFI_VARIABLE_READ_ONLY |
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS, EFI_VARIABLE_RUNTIME_ACCESS,
22, L"CapsuleFFFF", false); 22, u"CapsuleFFFF", false);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
printf("EFI: cannot initialize CapsuleMax variable\n"); printf("EFI: cannot initialize CapsuleMax variable\n");
} }
@ -165,7 +165,7 @@ static efi_status_t efi_init_os_indications(void)
os_indications_supported |= os_indications_supported |=
EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED; EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED;
return efi_set_variable_int(L"OsIndicationsSupported", return efi_set_variable_int(u"OsIndicationsSupported",
&efi_global_variable_guid, &efi_global_variable_guid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS |

View file

@ -16,7 +16,7 @@
* @index: Index * @index: Index
* *
* Create a utf-16 string with @name, appending @index. * Create a utf-16 string with @name, appending @index.
* For example, L"Capsule0001" * For example, u"Capsule0001"
* *
* The caller must ensure that the buffer has enough space for the resulting * The caller must ensure that the buffer has enough space for the resulting
* string including the trailing L'\0'. * string including the trailing L'\0'.

View file

@ -1916,8 +1916,8 @@ static efi_status_t tcg2_measure_boot_variable(struct udevice *dev)
{ {
u16 *boot_order; u16 *boot_order;
u16 *boot_index; u16 *boot_index;
u16 var_name[] = L"BootOrder"; u16 var_name[] = u"BootOrder";
u16 boot_name[] = L"Boot####"; u16 boot_name[] = u"Boot####";
u8 *bootvar; u8 *bootvar;
efi_uintn_t var_data_size; efi_uintn_t var_data_size;
u32 count, i; u32 count, i;

View file

@ -229,26 +229,26 @@ static efi_status_t efi_set_secure_state(u8 secure_boot, u8 setup_mode,
efi_secure_boot = secure_boot; efi_secure_boot = secure_boot;
ret = efi_set_variable_int(L"SecureBoot", &efi_global_variable_guid, ret = efi_set_variable_int(u"SecureBoot", &efi_global_variable_guid,
attributes_ro, sizeof(secure_boot), attributes_ro, sizeof(secure_boot),
&secure_boot, false); &secure_boot, false);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
goto err; goto err;
ret = efi_set_variable_int(L"SetupMode", &efi_global_variable_guid, ret = efi_set_variable_int(u"SetupMode", &efi_global_variable_guid,
attributes_ro, sizeof(setup_mode), attributes_ro, sizeof(setup_mode),
&setup_mode, false); &setup_mode, false);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
goto err; goto err;
ret = efi_set_variable_int(L"AuditMode", &efi_global_variable_guid, ret = efi_set_variable_int(u"AuditMode", &efi_global_variable_guid,
audit_mode || setup_mode ? audit_mode || setup_mode ?
attributes_ro : attributes_rw, attributes_ro : attributes_rw,
sizeof(audit_mode), &audit_mode, false); sizeof(audit_mode), &audit_mode, false);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
goto err; goto err;
ret = efi_set_variable_int(L"DeployedMode", ret = efi_set_variable_int(u"DeployedMode",
&efi_global_variable_guid, &efi_global_variable_guid,
audit_mode || deployed_mode || setup_mode ? audit_mode || deployed_mode || setup_mode ?
attributes_ro : attributes_rw, attributes_ro : attributes_rw,
@ -280,7 +280,7 @@ static efi_status_t efi_transfer_secure_state(enum efi_secure_mode mode)
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
goto err; goto err;
} else if (mode == EFI_MODE_AUDIT) { } else if (mode == EFI_MODE_AUDIT) {
ret = efi_set_variable_int(L"PK", &efi_global_variable_guid, ret = efi_set_variable_int(u"PK", &efi_global_variable_guid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS, EFI_VARIABLE_RUNTIME_ACCESS,
0, NULL, false); 0, NULL, false);
@ -354,7 +354,7 @@ efi_status_t efi_init_secure_state(void)
return ret; return ret;
/* As we do not provide vendor keys this variable is always 0. */ /* As we do not provide vendor keys this variable is always 0. */
ret = efi_set_variable_int(L"VendorKeys", ret = efi_set_variable_int(u"VendorKeys",
&efi_global_variable_guid, &efi_global_variable_guid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS |

View file

@ -145,15 +145,15 @@ static efi_status_t efi_variable_authenticate(const u16 *variable,
case EFI_AUTH_VAR_PK: case EFI_AUTH_VAR_PK:
case EFI_AUTH_VAR_KEK: case EFI_AUTH_VAR_KEK:
/* with PK */ /* with PK */
truststore = efi_sigstore_parse_sigdb(L"PK"); truststore = efi_sigstore_parse_sigdb(u"PK");
if (!truststore) if (!truststore)
goto err; goto err;
break; break;
case EFI_AUTH_VAR_DB: case EFI_AUTH_VAR_DB:
case EFI_AUTH_VAR_DBX: case EFI_AUTH_VAR_DBX:
/* with PK and KEK */ /* with PK and KEK */
truststore = efi_sigstore_parse_sigdb(L"KEK"); truststore = efi_sigstore_parse_sigdb(u"KEK");
truststore2 = efi_sigstore_parse_sigdb(L"PK"); truststore2 = efi_sigstore_parse_sigdb(u"PK");
if (!truststore) { if (!truststore) {
if (!truststore2) if (!truststore2)
goto err; goto err;

View file

@ -588,7 +588,7 @@ efi_status_t efi_set_variable_int(const u16 *variable_name,
if (alt_ret != EFI_SUCCESS) if (alt_ret != EFI_SUCCESS)
goto out; goto out;
if (!u16_strcmp(variable_name, L"PK")) if (!u16_strcmp(variable_name, u"PK"))
alt_ret = efi_init_secure_state(); alt_ret = efi_init_secure_state();
out: out:
free(comm_buf); free(comm_buf);

View file

@ -34,7 +34,7 @@ static struct efi_simple_text_output_protocol *con_out;
*/ */
static void print_uefi_revision(void) static void print_uefi_revision(void)
{ {
u16 rev[] = L"0.0.0"; u16 rev[] = u"0.0.0";
rev[0] = (systable->hdr.revision >> 16) + '0'; rev[0] = (systable->hdr.revision >> 16) + '0';
rev[4] = systable->hdr.revision & 0xffff; rev[4] = systable->hdr.revision & 0xffff;
@ -48,9 +48,9 @@ static void print_uefi_revision(void)
else else
rev[3] = 0; rev[3] = 0;
con_out->output_string(con_out, L"Running on UEFI "); con_out->output_string(con_out, u"Running on UEFI ");
con_out->output_string(con_out, rev); con_out->output_string(con_out, rev);
con_out->output_string(con_out, L"\r\n"); con_out->output_string(con_out, u"\r\n");
} }
/** /**
@ -65,15 +65,15 @@ static void print_config_tables(void)
if (!memcmp(&systable->tables[i].guid, &fdt_guid, if (!memcmp(&systable->tables[i].guid, &fdt_guid,
sizeof(efi_guid_t))) sizeof(efi_guid_t)))
con_out->output_string con_out->output_string
(con_out, L"Have device tree\r\n"); (con_out, u"Have device tree\r\n");
if (!memcmp(&systable->tables[i].guid, &acpi_guid, if (!memcmp(&systable->tables[i].guid, &acpi_guid,
sizeof(efi_guid_t))) sizeof(efi_guid_t)))
con_out->output_string con_out->output_string
(con_out, L"Have ACPI 2.0 table\r\n"); (con_out, u"Have ACPI 2.0 table\r\n");
if (!memcmp(&systable->tables[i].guid, &smbios_guid, if (!memcmp(&systable->tables[i].guid, &smbios_guid,
sizeof(efi_guid_t))) sizeof(efi_guid_t)))
con_out->output_string con_out->output_string
(con_out, L"Have SMBIOS table\r\n"); (con_out, u"Have SMBIOS table\r\n");
} }
} }
@ -86,13 +86,13 @@ static void print_config_tables(void)
void print_load_options(struct efi_loaded_image *loaded_image) void print_load_options(struct efi_loaded_image *loaded_image)
{ {
/* Output the load options */ /* Output the load options */
con_out->output_string(con_out, L"Load options: "); con_out->output_string(con_out, u"Load options: ");
if (loaded_image->load_options_size && loaded_image->load_options) if (loaded_image->load_options_size && loaded_image->load_options)
con_out->output_string(con_out, con_out->output_string(con_out,
(u16 *)loaded_image->load_options); (u16 *)loaded_image->load_options);
else else
con_out->output_string(con_out, L"<none>"); con_out->output_string(con_out, u"<none>");
con_out->output_string(con_out, L"\r\n"); con_out->output_string(con_out, u"\r\n");
} }
/** /**
@ -108,21 +108,21 @@ efi_status_t print_device_path(struct efi_device_path *device_path,
efi_status_t ret; efi_status_t ret;
if (!device_path) { if (!device_path) {
con_out->output_string(con_out, L"<none>\r\n"); con_out->output_string(con_out, u"<none>\r\n");
return EFI_SUCCESS; return EFI_SUCCESS;
} }
string = dp2txt->convert_device_path_to_text(device_path, true, false); string = dp2txt->convert_device_path_to_text(device_path, true, false);
if (!string) { if (!string) {
con_out->output_string con_out->output_string
(con_out, L"Cannot convert device path to text\r\n"); (con_out, u"Cannot convert device path to text\r\n");
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
con_out->output_string(con_out, string); con_out->output_string(con_out, string);
con_out->output_string(con_out, L"\r\n"); con_out->output_string(con_out, u"\r\n");
ret = boottime->free_pool(string); ret = boottime->free_pool(string);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
con_out->output_string(con_out, L"Cannot free pool memory\r\n"); con_out->output_string(con_out, u"Cannot free pool memory\r\n");
return ret; return ret;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
@ -148,7 +148,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
con_out = systable->con_out; con_out = systable->con_out;
/* UEFI requires CR LF */ /* UEFI requires CR LF */
con_out->output_string(con_out, L"Hello, world!\r\n"); con_out->output_string(con_out, u"Hello, world!\r\n");
print_uefi_revision(); print_uefi_revision();
print_config_tables(); print_config_tables();
@ -158,7 +158,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
(void **)&loaded_image); (void **)&loaded_image);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
con_out->output_string con_out->output_string
(con_out, L"Cannot open loaded image protocol\r\n"); (con_out, u"Cannot open loaded image protocol\r\n");
goto out; goto out;
} }
print_load_options(loaded_image); print_load_options(loaded_image);
@ -168,12 +168,12 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
NULL, (void **)&device_path_to_text); NULL, (void **)&device_path_to_text);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
con_out->output_string con_out->output_string
(con_out, L"Cannot open device path to text protocol\r\n"); (con_out, u"Cannot open device path to text protocol\r\n");
goto out; goto out;
} }
if (!loaded_image->device_handle) { if (!loaded_image->device_handle) {
con_out->output_string con_out->output_string
(con_out, L"Missing device handle\r\n"); (con_out, u"Missing device handle\r\n");
goto out; goto out;
} }
ret = boottime->handle_protocol(loaded_image->device_handle, ret = boottime->handle_protocol(loaded_image->device_handle,
@ -181,14 +181,14 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
(void **)&device_path); (void **)&device_path);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
con_out->output_string con_out->output_string
(con_out, L"Missing device path for device handle\r\n"); (con_out, u"Missing device path for device handle\r\n");
goto out; goto out;
} }
con_out->output_string(con_out, L"Boot device: "); con_out->output_string(con_out, u"Boot device: ");
ret = print_device_path(device_path, device_path_to_text); ret = print_device_path(device_path, device_path_to_text);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
goto out; goto out;
con_out->output_string(con_out, L"File path: "); con_out->output_string(con_out, u"File path: ");
ret = print_device_path(loaded_image->file_path, device_path_to_text); ret = print_device_path(loaded_image->file_path, device_path_to_text);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
goto out; goto out;

View file

@ -109,7 +109,7 @@ static efi_status_t efi_input(u16 *buffer, efi_uintn_t buffer_size)
struct efi_input_key key = {0}; struct efi_input_key key = {0};
efi_uintn_t index; efi_uintn_t index;
efi_uintn_t pos = 0; efi_uintn_t pos = 0;
u16 outbuf[2] = L" "; u16 outbuf[2] = u" ";
efi_status_t ret; efi_status_t ret;
/* Drain the console input */ /* Drain the console input */
@ -124,7 +124,7 @@ static efi_status_t efi_input(u16 *buffer, efi_uintn_t buffer_size)
continue; continue;
switch (key.scan_code) { switch (key.scan_code) {
case 0x17: /* Escape */ case 0x17: /* Escape */
print(L"\r\nAborted\r\n"); print(u"\r\nAborted\r\n");
return EFI_ABORTED; return EFI_ABORTED;
default: default:
break; break;
@ -133,12 +133,12 @@ static efi_status_t efi_input(u16 *buffer, efi_uintn_t buffer_size)
case 0x08: /* Backspace */ case 0x08: /* Backspace */
if (pos) { if (pos) {
buffer[pos--] = 0; buffer[pos--] = 0;
print(L"\b \b"); print(u"\b \b");
} }
break; break;
case 0x0a: /* Linefeed */ case 0x0a: /* Linefeed */
case 0x0d: /* Carriage return */ case 0x0d: /* Carriage return */
print(L"\r\n"); print(u"\r\n");
return EFI_SUCCESS; return EFI_SUCCESS;
default: default:
break; break;
@ -228,9 +228,9 @@ bool starts_with(u16 *string, u16 *keyword)
*/ */
void do_help(void) void do_help(void)
{ {
error(L"load <dtb> - load device-tree from file\r\n"); error(u"load <dtb> - load device-tree from file\r\n");
error(L"save <dtb> - save device-tree to file\r\n"); error(u"save <dtb> - save device-tree to file\r\n");
error(L"exit - exit the shell\r\n"); error(u"exit - exit the shell\r\n");
} }
/** /**
@ -251,7 +251,7 @@ open_file_system(struct efi_simple_file_system_protocol **file_system)
(void **)&loaded_image, NULL, NULL, (void **)&loaded_image, NULL, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL); EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Loaded image protocol not found\r\n"); error(u"Loaded image protocol not found\r\n");
return ret; return ret;
} }
@ -272,7 +272,7 @@ open_file_system(struct efi_simple_file_system_protocol **file_system)
(void **)file_system, NULL, NULL, (void **)file_system, NULL, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL); EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
error(L"Failed to open simple file system protocol\r\n"); error(u"Failed to open simple file system protocol\r\n");
if (handle) if (handle)
bs->free_pool(handle_buffer); bs->free_pool(handle_buffer);
@ -300,7 +300,7 @@ efi_status_t do_load(u16 *filename)
ret = bs->locate_protocol(&efi_dt_fixup_protocol_guid, NULL, ret = bs->locate_protocol(&efi_dt_fixup_protocol_guid, NULL,
(void **)&dt_fixup_prot); (void **)&dt_fixup_prot);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Device-tree fix-up protocol not found\r\n"); error(u"Device-tree fix-up protocol not found\r\n");
return ret; return ret;
} }
@ -313,50 +313,50 @@ efi_status_t do_load(u16 *filename)
/* Open volume */ /* Open volume */
ret = file_system->open_volume(file_system, &root); ret = file_system->open_volume(file_system, &root);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Failed to open volume\r\n"); error(u"Failed to open volume\r\n");
goto out; goto out;
} }
/* Open file */ /* Open file */
ret = root->open(root, &file, filename, EFI_FILE_MODE_READ, 0); ret = root->open(root, &file, filename, EFI_FILE_MODE_READ, 0);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"File not found\r\n"); error(u"File not found\r\n");
goto out; goto out;
} }
/* Get file size */ /* Get file size */
buffer_size = 0; buffer_size = 0;
ret = file->getinfo(file, &efi_file_info_guid, &buffer_size, NULL); ret = file->getinfo(file, &efi_file_info_guid, &buffer_size, NULL);
if (ret != EFI_BUFFER_TOO_SMALL) { if (ret != EFI_BUFFER_TOO_SMALL) {
error(L"Can't get file info size\r\n"); error(u"Can't get file info size\r\n");
goto out; goto out;
} }
ret = bs->allocate_pool(EFI_LOADER_DATA, buffer_size, (void **)&info); ret = bs->allocate_pool(EFI_LOADER_DATA, buffer_size, (void **)&info);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Out of memory\r\n"); error(u"Out of memory\r\n");
goto out; goto out;
} }
ret = file->getinfo(file, &efi_file_info_guid, &buffer_size, info); ret = file->getinfo(file, &efi_file_info_guid, &buffer_size, info);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Can't get file info\r\n"); error(u"Can't get file info\r\n");
goto out; goto out;
} }
buffer_size = info->file_size; buffer_size = info->file_size;
pages = efi_size_in_pages(buffer_size); pages = efi_size_in_pages(buffer_size);
ret = bs->free_pool(info); ret = bs->free_pool(info);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
error(L"Can't free memory pool\r\n"); error(u"Can't free memory pool\r\n");
/* Read file */ /* Read file */
ret = bs->allocate_pages(EFI_ALLOCATE_ANY_PAGES, ret = bs->allocate_pages(EFI_ALLOCATE_ANY_PAGES,
EFI_ACPI_RECLAIM_MEMORY, EFI_ACPI_RECLAIM_MEMORY,
pages, &addr); pages, &addr);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Out of memory\r\n"); error(u"Out of memory\r\n");
goto out; goto out;
} }
dtb = (struct fdt_header *)(uintptr_t)addr; dtb = (struct fdt_header *)(uintptr_t)addr;
ret = file->read(file, &buffer_size, dtb); ret = file->read(file, &buffer_size, dtb);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Can't read file\r\n"); error(u"Can't read file\r\n");
goto out; goto out;
} }
/* Fixup file, expecting EFI_BUFFER_TOO_SMALL */ /* Fixup file, expecting EFI_BUFFER_TOO_SMALL */
@ -367,24 +367,24 @@ efi_status_t do_load(u16 *filename)
/* Read file into larger buffer */ /* Read file into larger buffer */
ret = bs->free_pages(addr, pages); ret = bs->free_pages(addr, pages);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
error(L"Can't free memory pages\r\n"); error(u"Can't free memory pages\r\n");
pages = efi_size_in_pages(buffer_size); pages = efi_size_in_pages(buffer_size);
ret = bs->allocate_pages(EFI_ALLOCATE_ANY_PAGES, ret = bs->allocate_pages(EFI_ALLOCATE_ANY_PAGES,
EFI_ACPI_RECLAIM_MEMORY, EFI_ACPI_RECLAIM_MEMORY,
pages, &addr); pages, &addr);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Out of memory\r\n"); error(u"Out of memory\r\n");
goto out; goto out;
} }
dtb = (struct fdt_header *)(uintptr_t)addr; dtb = (struct fdt_header *)(uintptr_t)addr;
ret = file->setpos(file, 0); ret = file->setpos(file, 0);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Can't position file\r\n"); error(u"Can't position file\r\n");
goto out; goto out;
} }
ret = file->read(file, &buffer_size, dtb); ret = file->read(file, &buffer_size, dtb);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Can't read file\r\n"); error(u"Can't read file\r\n");
goto out; goto out;
} }
buffer_size = pages << EFI_PAGE_SHIFT; buffer_size = pages << EFI_PAGE_SHIFT;
@ -394,24 +394,24 @@ efi_status_t do_load(u16 *filename)
EFI_DT_INSTALL_TABLE); EFI_DT_INSTALL_TABLE);
} }
if (ret == EFI_SUCCESS) if (ret == EFI_SUCCESS)
print(L"device-tree installed\r\n"); print(u"device-tree installed\r\n");
else else
error(L"Device-tree fix-up failed\r\n"); error(u"Device-tree fix-up failed\r\n");
out: out:
if (addr) { if (addr) {
ret2 = bs->free_pages(addr, pages); ret2 = bs->free_pages(addr, pages);
if (ret2 != EFI_SUCCESS) if (ret2 != EFI_SUCCESS)
error(L"Can't free memory pages\r\n"); error(u"Can't free memory pages\r\n");
} }
if (file) { if (file) {
ret2 = file->close(file); ret2 = file->close(file);
if (ret2 != EFI_SUCCESS) if (ret2 != EFI_SUCCESS)
error(L"Can't close file\r\n"); error(u"Can't close file\r\n");
} }
if (root) { if (root) {
ret2 = root->close(root); ret2 = root->close(root);
if (ret2 != EFI_SUCCESS) if (ret2 != EFI_SUCCESS)
error(L"Can't close volume\r\n"); error(u"Can't close volume\r\n");
} }
return ret; return ret;
} }
@ -432,11 +432,11 @@ efi_status_t do_save(u16 *filename)
dtb = get_dtb(systable); dtb = get_dtb(systable);
if (!dtb) { if (!dtb) {
error(L"DTB not found\r\n"); error(u"DTB not found\r\n");
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
if (f2h(dtb->magic) != FDT_MAGIC) { if (f2h(dtb->magic) != FDT_MAGIC) {
error(L"Wrong device tree magic\r\n"); error(u"Wrong device tree magic\r\n");
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
dtb_size = f2h(dtb->totalsize); dtb_size = f2h(dtb->totalsize);
@ -450,19 +450,19 @@ efi_status_t do_save(u16 *filename)
/* Open volume */ /* Open volume */
ret = file_system->open_volume(file_system, &root); ret = file_system->open_volume(file_system, &root);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Failed to open volume\r\n"); error(u"Failed to open volume\r\n");
return ret; return ret;
} }
/* Check if file already exists */ /* Check if file already exists */
ret = root->open(root, &file, filename, EFI_FILE_MODE_READ, 0); ret = root->open(root, &file, filename, EFI_FILE_MODE_READ, 0);
if (ret == EFI_SUCCESS) { if (ret == EFI_SUCCESS) {
file->close(file); file->close(file);
print(L"Overwrite existing file (y/n)? "); print(u"Overwrite existing file (y/n)? ");
ret = efi_input_yn(); ret = efi_input_yn();
print(L"\r\n"); print(u"\r\n");
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
root->close(root); root->close(root);
error(L"Aborted by user\r\n"); error(u"Aborted by user\r\n");
return ret; return ret;
} }
} }
@ -475,16 +475,16 @@ efi_status_t do_save(u16 *filename)
/* Write file */ /* Write file */
ret = file->write(file, &dtb_size, dtb); ret = file->write(file, &dtb_size, dtb);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
error(L"Failed to write file\r\n"); error(u"Failed to write file\r\n");
file->close(file); file->close(file);
} else { } else {
error(L"Failed to open file\r\n"); error(u"Failed to open file\r\n");
} }
root->close(root); root->close(root);
if (ret == EFI_SUCCESS) { if (ret == EFI_SUCCESS) {
print(filename); print(filename);
print(L" written\r\n"); print(u" written\r\n");
} }
return ret; return ret;
@ -510,7 +510,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image_handle,
cout->set_attribute(cout, EFI_LIGHTBLUE | EFI_BACKGROUND_BLACK); cout->set_attribute(cout, EFI_LIGHTBLUE | EFI_BACKGROUND_BLACK);
cout->clear_screen(cout); cout->clear_screen(cout);
cout->set_attribute(cout, EFI_WHITE | EFI_BACKGROUND_BLACK); cout->set_attribute(cout, EFI_WHITE | EFI_BACKGROUND_BLACK);
print(L"DTB Dump\r\n========\r\n\r\n"); print(u"DTB Dump\r\n========\r\n\r\n");
cout->set_attribute(cout, EFI_LIGHTBLUE | EFI_BACKGROUND_BLACK); cout->set_attribute(cout, EFI_LIGHTBLUE | EFI_BACKGROUND_BLACK);
for (;;) { for (;;) {
@ -518,16 +518,16 @@ efi_status_t EFIAPI efi_main(efi_handle_t image_handle,
u16 *pos; u16 *pos;
efi_uintn_t ret; efi_uintn_t ret;
print(L"=> "); print(u"=> ");
ret = efi_input(command, sizeof(command)); ret = efi_input(command, sizeof(command));
if (ret == EFI_ABORTED) if (ret == EFI_ABORTED)
break; break;
pos = skip_whitespace(command); pos = skip_whitespace(command);
if (starts_with(pos, L"exit")) if (starts_with(pos, u"exit"))
break; break;
else if (starts_with(pos, L"load ")) else if (starts_with(pos, u"load "))
do_load(pos + 5); do_load(pos + 5);
else if (starts_with(pos, L"save ")) else if (starts_with(pos, u"save "))
do_save(pos + 5); do_save(pos + 5);
else else
do_help(); do_help();

View file

@ -18,7 +18,7 @@ static const struct efi_system_table *systable;
static const struct efi_boot_services *boottime; static const struct efi_boot_services *boottime;
static const struct efi_runtime_services *runtime; static const struct efi_runtime_services *runtime;
static efi_handle_t handle; static efi_handle_t handle;
static u16 reset_message[] = L"Selftest completed"; static u16 reset_message[] = u"Selftest completed";
static int *setup_status; static int *setup_status;
/* /*

View file

@ -407,7 +407,7 @@ static int execute(void)
} }
/* Read file */ /* Read file */
ret = root->open(root, &file, L"hello.txt", EFI_FILE_MODE_READ, ret = root->open(root, &file, u"hello.txt", EFI_FILE_MODE_READ,
0); 0);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
efi_st_error("Failed to open file\n"); efi_st_error("Failed to open file\n");
@ -451,7 +451,7 @@ static int execute(void)
#ifdef CONFIG_FAT_WRITE #ifdef CONFIG_FAT_WRITE
/* Write file */ /* Write file */
ret = root->open(root, &file, L"u-boot.txt", EFI_FILE_MODE_READ | ret = root->open(root, &file, u"u-boot.txt", EFI_FILE_MODE_READ |
EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0); EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
efi_st_error("Failed to open file\n"); efi_st_error("Failed to open file\n");
@ -483,7 +483,7 @@ static int execute(void)
/* Verify file */ /* Verify file */
boottime->set_mem(buf, sizeof(buf), 0); boottime->set_mem(buf, sizeof(buf), 0);
ret = root->open(root, &file, L"u-boot.txt", EFI_FILE_MODE_READ, ret = root->open(root, &file, u"u-boot.txt", EFI_FILE_MODE_READ,
0); 0);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
efi_st_error("Failed to open file\n"); efi_st_error("Failed to open file\n");

View file

@ -319,7 +319,7 @@ static int execute(void)
{ DEVICE_PATH_TYPE_MEDIA_DEVICE, { DEVICE_PATH_TYPE_MEDIA_DEVICE,
DEVICE_PATH_SUB_TYPE_FILE_PATH, DEVICE_PATH_SUB_TYPE_FILE_PATH,
sizeof(struct efi_device_path) + 12}, sizeof(struct efi_device_path) + 12},
L"u-boot.bin", u"u-boot.bin",
}; };
u16 *string; u16 *string;
efi_status_t ret; efi_status_t ret;

View file

@ -31,7 +31,7 @@ static struct {
DEVICE_PATH_SUB_TYPE_FILE_PATH, DEVICE_PATH_SUB_TYPE_FILE_PATH,
sizeof(dp.dp) + sizeof(dp.filename), sizeof(dp.dp) + sizeof(dp.filename),
}, },
L"bug.efi", u"bug.efi",
{ {
DEVICE_PATH_TYPE_END, DEVICE_PATH_TYPE_END,
DEVICE_PATH_SUB_TYPE_END, DEVICE_PATH_SUB_TYPE_END,

View file

@ -199,7 +199,7 @@ static int execute(void)
char *str; char *str;
efi_status_t ret; efi_status_t ret;
str = get_property(L"compatible", NULL); str = get_property(u"compatible", NULL);
if (str) { if (str) {
efi_st_printf("compatible: %s\n", str); efi_st_printf("compatible: %s\n", str);
ret = boottime->free_pool(str); ret = boottime->free_pool(str);
@ -211,7 +211,7 @@ static int execute(void)
efi_st_error("Missing property 'compatible'\n"); efi_st_error("Missing property 'compatible'\n");
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
str = get_property(L"serial-number", NULL); str = get_property(u"serial-number", NULL);
if (str) { if (str) {
efi_st_printf("serial-number: %s\n", str); efi_st_printf("serial-number: %s\n", str);
ret = boottime->free_pool(str); ret = boottime->free_pool(str);
@ -220,7 +220,7 @@ static int execute(void)
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
} }
str = get_property(L"boot-hartid", L"chosen"); str = get_property(u"boot-hartid", u"chosen");
if (IS_ENABLED(CONFIG_RISCV)) { if (IS_ENABLED(CONFIG_RISCV)) {
if (str) { if (str) {
efi_st_printf("boot-hartid: %u\n", efi_st_printf("boot-hartid: %u\n",

View file

@ -699,7 +699,7 @@ static int test_hii_string_new_string(void)
ret = hii_string_protocol->new_string(hii_string_protocol, handle, ret = hii_string_protocol->new_string(hii_string_protocol, handle,
&id, (u8 *)"en-US", &id, (u8 *)"en-US",
L"Japanese", L"Japanese", NULL); u"Japanese", u"Japanese", NULL);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
efi_st_error("new_string returned %u\n", efi_st_error("new_string returned %u\n",
(unsigned int)ret); (unsigned int)ret);
@ -752,7 +752,7 @@ static int test_hii_string_get_string(void)
ret = hii_string_protocol->new_string(hii_string_protocol, handle, ret = hii_string_protocol->new_string(hii_string_protocol, handle,
&id, (u8 *)"en-US", &id, (u8 *)"en-US",
L"Japanese", L"Japanese", NULL); u"Japanese", u"Japanese", NULL);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
efi_st_error("new_string returned %u\n", efi_st_error("new_string returned %u\n",
(unsigned int)ret); (unsigned int)ret);
@ -831,7 +831,7 @@ static int test_hii_string_set_string(void)
ret = hii_string_protocol->new_string(hii_string_protocol, handle, ret = hii_string_protocol->new_string(hii_string_protocol, handle,
&id, (u8 *)"en-US", &id, (u8 *)"en-US",
L"Japanese", L"Japanese", NULL); u"Japanese", u"Japanese", NULL);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
efi_st_error("new_string returned %u\n", efi_st_error("new_string returned %u\n",
(unsigned int)ret); (unsigned int)ret);
@ -840,7 +840,7 @@ static int test_hii_string_set_string(void)
ret = hii_string_protocol->set_string(hii_string_protocol, handle, ret = hii_string_protocol->set_string(hii_string_protocol, handle,
id, (u8 *)"en-US", id, (u8 *)"en-US",
L"Nihongo", NULL); u"Nihongo", NULL);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
efi_st_error("set_string returned %u\n", efi_st_error("set_string returned %u\n",
(unsigned int)ret); (unsigned int)ret);

View file

@ -101,7 +101,7 @@ static struct {
FILE_NAME_SIZE * sizeof(u16), FILE_NAME_SIZE * sizeof(u16),
} }
}, },
L"\\lf.efi", u"\\lf.efi",
{ {
DEVICE_PATH_TYPE_END, DEVICE_PATH_TYPE_END,
DEVICE_PATH_SUB_TYPE_END, DEVICE_PATH_SUB_TYPE_END,
@ -152,7 +152,7 @@ static struct {
FILE_NAME_SIZE * sizeof(u16), FILE_NAME_SIZE * sizeof(u16),
} }
}, },
L"\\lf2.efi", u"\\lf2.efi",
{ {
DEVICE_PATH_TYPE_END, DEVICE_PATH_TYPE_END,
DEVICE_PATH_SUB_TYPE_END, DEVICE_PATH_SUB_TYPE_END,

View file

@ -20,8 +20,8 @@
/* Binary logarithm of the block size */ /* Binary logarithm of the block size */
#define LB_BLOCK_SIZE 9 #define LB_BLOCK_SIZE 9
#define FILE_NAME L"app.efi" #define FILE_NAME u"app.efi"
#define VOLUME_NAME L"EfiDisk" #define VOLUME_NAME u"EfiDisk"
static struct efi_boot_services *boottime; static struct efi_boot_services *boottime;
static efi_handle_t handle_image; static efi_handle_t handle_image;

View file

@ -23,7 +23,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
struct efi_simple_text_output_protocol *con_out = systable->con_out; struct efi_simple_text_output_protocol *con_out = systable->con_out;
con_out->output_string(con_out, con_out->output_string(con_out,
L"EFI application triggers exception.\n"); u"EFI application triggers exception.\n");
#if defined(CONFIG_ARM) #if defined(CONFIG_ARM)
/* /*
@ -38,6 +38,6 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
#elif defined(CONFIG_X86) #elif defined(CONFIG_X86)
asm volatile (".word 0xffff\n"); asm volatile (".word 0xffff\n");
#endif #endif
con_out->output_string(con_out, L"Exception not triggered.\n"); con_out->output_string(con_out, u"Exception not triggered.\n");
return EFI_ABORTED; return EFI_ABORTED;
} }

View file

@ -40,7 +40,7 @@ static efi_status_t EFIAPI check_loaded_image_protocol
NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
cout->output_string(cout, cout->output_string(cout,
L"Could not open loaded image protocol"); u"Could not open loaded image protocol");
return ret; return ret;
} }
if ((void *)check_loaded_image_protocol < if ((void *)check_loaded_image_protocol <
@ -49,7 +49,7 @@ static efi_status_t EFIAPI check_loaded_image_protocol
loaded_image_protocol->image_base + loaded_image_protocol->image_base +
loaded_image_protocol->image_size) { loaded_image_protocol->image_size) {
cout->output_string(cout, cout->output_string(cout,
L"Incorrect image_base or image_size\n"); u"Incorrect image_base or image_size\n");
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
@ -69,11 +69,11 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
efi_status_t ret; efi_status_t ret;
u16 text[] = EFI_ST_SUCCESS_STR; u16 text[] = EFI_ST_SUCCESS_STR;
con_out->output_string(con_out, L"EFI application calling Exit\n"); con_out->output_string(con_out, u"EFI application calling Exit\n");
if (check_loaded_image_protocol(handle, systable) != EFI_SUCCESS) { if (check_loaded_image_protocol(handle, systable) != EFI_SUCCESS) {
con_out->output_string(con_out, con_out->output_string(con_out,
L"Loaded image protocol missing\n"); u"Loaded image protocol missing\n");
ret = EFI_NOT_FOUND; ret = EFI_NOT_FOUND;
goto out; goto out;
} }

View file

@ -24,7 +24,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
struct efi_simple_text_output_protocol *con_out = systable->con_out; struct efi_simple_text_output_protocol *con_out = systable->con_out;
con_out->output_string(con_out, con_out->output_string(con_out,
L"EFI application returning w/o calling Exit\n"); u"EFI application returning w/o calling Exit\n");
/* The return value is checked by the calling test */ /* The return value is checked by the calling test */
return EFI_INCOMPATIBLE_VERSION; return EFI_INCOMPATIBLE_VERSION;

View file

@ -33,7 +33,7 @@ static int setup(const efi_handle_t handle,
*/ */
static int execute(void) static int execute(void)
{ {
u16 reset_data[] = L"Reset by selftest"; u16 reset_data[] = u"Reset by selftest";
runtime->reset_system(EFI_RESET_COLD, EFI_SUCCESS, runtime->reset_system(EFI_RESET_COLD, EFI_SUCCESS,
sizeof(reset_data), reset_data); sizeof(reset_data), reset_data);

View file

@ -44,14 +44,14 @@ static int execute(void)
} }
/* TestString */ /* TestString */
ret = con_out->test_string(con_out, ret = con_out->test_string(con_out,
L" !\"#$%&'()*+,-./0-9:;<=>?@A-Z[\\]^_`a-z{|}~\n"); u" !\"#$%&'()*+,-./0-9:;<=>?@A-Z[\\]^_`a-z{|}~\n");
if (ret != EFI_ST_SUCCESS) { if (ret != EFI_ST_SUCCESS) {
efi_st_error("TestString failed for ANSI characters\n"); efi_st_error("TestString failed for ANSI characters\n");
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
/* OutputString */ /* OutputString */
ret = con_out->output_string(con_out, ret = con_out->output_string(con_out,
L"Testing cursor column update\n"); u"Testing cursor column update\n");
if (ret != EFI_ST_SUCCESS) { if (ret != EFI_ST_SUCCESS) {
efi_st_error("OutputString failed for ANSI characters"); efi_st_error("OutputString failed for ANSI characters");
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
@ -75,7 +75,7 @@ static int execute(void)
efi_st_error("Cursor column not 0 at beginning of line\n"); efi_st_error("Cursor column not 0 at beginning of line\n");
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
ret = con_out->output_string(con_out, L"123"); ret = con_out->output_string(con_out, u"123");
if (ret != EFI_ST_SUCCESS) { if (ret != EFI_ST_SUCCESS) {
efi_st_error("OutputString failed for ANSI characters\n"); efi_st_error("OutputString failed for ANSI characters\n");
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
@ -84,7 +84,7 @@ static int execute(void)
efi_st_error("Cursor column not incremented properly\n"); efi_st_error("Cursor column not incremented properly\n");
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
ret = con_out->output_string(con_out, L"\b"); ret = con_out->output_string(con_out, u"\b");
if (ret != EFI_ST_SUCCESS) { if (ret != EFI_ST_SUCCESS) {
efi_st_error("OutputString failed for backspace\n"); efi_st_error("OutputString failed for backspace\n");
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
@ -93,7 +93,7 @@ static int execute(void)
efi_st_error("Cursor column not decremented properly\n"); efi_st_error("Cursor column not decremented properly\n");
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
ret = con_out->output_string(con_out, L"\b\b"); ret = con_out->output_string(con_out, u"\b\b");
if (ret != EFI_ST_SUCCESS) { if (ret != EFI_ST_SUCCESS) {
efi_st_error("OutputString failed for backspace\n"); efi_st_error("OutputString failed for backspace\n");
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
@ -102,7 +102,7 @@ static int execute(void)
efi_st_error("Cursor column not decremented properly\n"); efi_st_error("Cursor column not decremented properly\n");
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
ret = con_out->output_string(con_out, L"\b\b"); ret = con_out->output_string(con_out, u"\b\b");
if (ret != EFI_ST_SUCCESS) { if (ret != EFI_ST_SUCCESS) {
efi_st_error("OutputString failed for backspace\n"); efi_st_error("OutputString failed for backspace\n");
return EFI_ST_FAILURE; return EFI_ST_FAILURE;

View file

@ -44,9 +44,9 @@ static int setup(const efi_handle_t handle,
static int test_stri_coll(void) static int test_stri_coll(void)
{ {
efi_intn_t ret; efi_intn_t ret;
u16 c1[] = L"first"; u16 c1[] = u"first";
u16 c2[] = L"FIRST"; u16 c2[] = u"FIRST";
u16 c3[] = L"second"; u16 c3[] = u"second";
ret = unicode_collation_protocol->stri_coll(unicode_collation_protocol, ret = unicode_collation_protocol->stri_coll(unicode_collation_protocol,
c1, c2); c1, c2);
@ -78,66 +78,66 @@ static int test_stri_coll(void)
static int test_metai_match(void) static int test_metai_match(void)
{ {
bool ret; bool ret;
const u16 c[] = L"Das U-Boot"; const u16 c[] = u"Das U-Boot";
ret = unicode_collation_protocol->metai_match( ret = unicode_collation_protocol->metai_match(
unicode_collation_protocol, c, L"*"); unicode_collation_protocol, c, u"*");
if (!ret) { if (!ret) {
efi_st_error("metai_match returned %u\n", ret); efi_st_error("metai_match returned %u\n", ret);
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
ret = unicode_collation_protocol->metai_match( ret = unicode_collation_protocol->metai_match(
unicode_collation_protocol, c, L"Da[rstu] U-Boot"); unicode_collation_protocol, c, u"Da[rstu] U-Boot");
if (!ret) { if (!ret) {
efi_st_error("metai_match returned %u\n", ret); efi_st_error("metai_match returned %u\n", ret);
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
ret = unicode_collation_protocol->metai_match( ret = unicode_collation_protocol->metai_match(
unicode_collation_protocol, c, L"Da[q-v] U-Boot"); unicode_collation_protocol, c, u"Da[q-v] U-Boot");
if (!ret) { if (!ret) {
efi_st_error("metai_match returned %u\n", ret); efi_st_error("metai_match returned %u\n", ret);
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
ret = unicode_collation_protocol->metai_match( ret = unicode_collation_protocol->metai_match(
unicode_collation_protocol, c, L"Da? U-Boot"); unicode_collation_protocol, c, u"Da? U-Boot");
if (!ret) { if (!ret) {
efi_st_error("metai_match returned %u\n", ret); efi_st_error("metai_match returned %u\n", ret);
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
ret = unicode_collation_protocol->metai_match( ret = unicode_collation_protocol->metai_match(
unicode_collation_protocol, c, L"D*Bo*t"); unicode_collation_protocol, c, u"D*Bo*t");
if (!ret) { if (!ret) {
efi_st_error("metai_match returned %u\n", ret); efi_st_error("metai_match returned %u\n", ret);
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
ret = unicode_collation_protocol->metai_match( ret = unicode_collation_protocol->metai_match(
unicode_collation_protocol, c, L"Da[xyz] U-Boot"); unicode_collation_protocol, c, u"Da[xyz] U-Boot");
if (ret) { if (ret) {
efi_st_error("metai_match returned %u\n", ret); efi_st_error("metai_match returned %u\n", ret);
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
ret = unicode_collation_protocol->metai_match( ret = unicode_collation_protocol->metai_match(
unicode_collation_protocol, c, L"Da[a-d] U-Boot"); unicode_collation_protocol, c, u"Da[a-d] U-Boot");
if (ret) { if (ret) {
efi_st_error("metai_match returned %u\n", ret); efi_st_error("metai_match returned %u\n", ret);
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
ret = unicode_collation_protocol->metai_match( ret = unicode_collation_protocol->metai_match(
unicode_collation_protocol, c, L"Da?? U-Boot"); unicode_collation_protocol, c, u"Da?? U-Boot");
if (ret) { if (ret) {
efi_st_error("metai_match returned %u\n", ret); efi_st_error("metai_match returned %u\n", ret);
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
ret = unicode_collation_protocol->metai_match( ret = unicode_collation_protocol->metai_match(
unicode_collation_protocol, c, L"D*Bo*tt"); unicode_collation_protocol, c, u"D*Bo*tt");
if (ret) { if (ret) {
efi_st_error("metai_match returned %u\n", ret); efi_st_error("metai_match returned %u\n", ret);
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
@ -148,7 +148,7 @@ static int test_metai_match(void)
static int test_str_lwr(void) static int test_str_lwr(void)
{ {
u16 c[] = L"U-Boot"; u16 c[] = u"U-Boot";
unicode_collation_protocol->str_lwr(unicode_collation_protocol, c); unicode_collation_protocol->str_lwr(unicode_collation_protocol, c);
if (efi_st_strcmp_16_8(c, "u-boot")) { if (efi_st_strcmp_16_8(c, "u-boot")) {
@ -161,7 +161,7 @@ static int test_str_lwr(void)
static int test_str_upr(void) static int test_str_upr(void)
{ {
u16 c[] = L"U-Boot"; u16 c[] = u"U-Boot";
unicode_collation_protocol->str_upr(unicode_collation_protocol, c); unicode_collation_protocol->str_upr(unicode_collation_protocol, c);
if (efi_st_strcmp_16_8(c, "U-BOOT")) { if (efi_st_strcmp_16_8(c, "U-BOOT")) {
@ -194,16 +194,16 @@ static int test_str_to_fat(void)
boottime->set_mem(fat, sizeof(fat), 0); boottime->set_mem(fat, sizeof(fat), 0);
ret = unicode_collation_protocol->str_to_fat(unicode_collation_protocol, ret = unicode_collation_protocol->str_to_fat(unicode_collation_protocol,
L"U -Boo.t", 6, fat); u"U -Boo.t", 6, fat);
if (ret || efi_st_strcmp_16_8(L"U-BOOT", fat)) { if (ret || efi_st_strcmp_16_8(u"U-BOOT", fat)) {
efi_st_error("str_to_fat returned %u, \"%s\"\n", ret, fat); efi_st_error("str_to_fat returned %u, \"%s\"\n", ret, fat);
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
boottime->set_mem(fat, 16, 0); boottime->set_mem(fat, 16, 0);
ret = unicode_collation_protocol->str_to_fat(unicode_collation_protocol, ret = unicode_collation_protocol->str_to_fat(unicode_collation_protocol,
L"U\\Boot", 6, fat); u"U\\Boot", 6, fat);
if (!ret || efi_st_strcmp_16_8(L"U_BOOT", fat)) { if (!ret || efi_st_strcmp_16_8(u"U_BOOT", fat)) {
efi_st_error("str_to_fat returned %u, \"%s\"\n", ret, fat); efi_st_error("str_to_fat returned %u, \"%s\"\n", ret, fat);
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }

View file

@ -15,64 +15,64 @@ struct efi_st_translate {
}; };
static struct efi_st_translate efi_st_control_characters[] = { static struct efi_st_translate efi_st_control_characters[] = {
{0, L"Null"}, {0, u"Null"},
{8, L"BS"}, {8, u"BS"},
{9, L"TAB"}, {9, u"TAB"},
{10, L"LF"}, {10, u"LF"},
{13, L"CR"}, {13, u"CR"},
{0, NULL}, {0, NULL},
}; };
static u16 efi_st_ch[] = L"' '"; static u16 efi_st_ch[] = u"' '";
static u16 efi_st_unknown[] = L"unknown"; static u16 efi_st_unknown[] = u"unknown";
static struct efi_st_translate efi_st_scan_codes[] = { static struct efi_st_translate efi_st_scan_codes[] = {
{0x00, L"Null"}, {0x00, u"Null"},
{0x01, L"Up"}, {0x01, u"Up"},
{0x02, L"Down"}, {0x02, u"Down"},
{0x03, L"Right"}, {0x03, u"Right"},
{0x04, L"Left"}, {0x04, u"Left"},
{0x05, L"Home"}, {0x05, u"Home"},
{0x06, L"End"}, {0x06, u"End"},
{0x07, L"Insert"}, {0x07, u"Insert"},
{0x08, L"Delete"}, {0x08, u"Delete"},
{0x09, L"Page Up"}, {0x09, u"Page Up"},
{0x0a, L"Page Down"}, {0x0a, u"Page Down"},
{0x0b, L"FN 1"}, {0x0b, u"FN 1"},
{0x0c, L"FN 2"}, {0x0c, u"FN 2"},
{0x0d, L"FN 3"}, {0x0d, u"FN 3"},
{0x0e, L"FN 4"}, {0x0e, u"FN 4"},
{0x0f, L"FN 5"}, {0x0f, u"FN 5"},
{0x10, L"FN 6"}, {0x10, u"FN 6"},
{0x11, L"FN 7"}, {0x11, u"FN 7"},
{0x12, L"FN 8"}, {0x12, u"FN 8"},
{0x13, L"FN 9"}, {0x13, u"FN 9"},
{0x14, L"FN 10"}, {0x14, u"FN 10"},
{0x15, L"FN 11"}, {0x15, u"FN 11"},
{0x16, L"FN 12"}, {0x16, u"FN 12"},
{0x17, L"Escape"}, {0x17, u"Escape"},
{0x68, L"FN 13"}, {0x68, u"FN 13"},
{0x69, L"FN 14"}, {0x69, u"FN 14"},
{0x6a, L"FN 15"}, {0x6a, u"FN 15"},
{0x6b, L"FN 16"}, {0x6b, u"FN 16"},
{0x6c, L"FN 17"}, {0x6c, u"FN 17"},
{0x6d, L"FN 18"}, {0x6d, u"FN 18"},
{0x6e, L"FN 19"}, {0x6e, u"FN 19"},
{0x6f, L"FN 20"}, {0x6f, u"FN 20"},
{0x70, L"FN 21"}, {0x70, u"FN 21"},
{0x71, L"FN 22"}, {0x71, u"FN 22"},
{0x72, L"FN 23"}, {0x72, u"FN 23"},
{0x73, L"FN 24"}, {0x73, u"FN 24"},
{0x7f, L"Mute"}, {0x7f, u"Mute"},
{0x80, L"Volume Up"}, {0x80, u"Volume Up"},
{0x81, L"Volume Down"}, {0x81, u"Volume Down"},
{0x100, L"Brightness Up"}, {0x100, u"Brightness Up"},
{0x101, L"Brightness Down"}, {0x101, u"Brightness Down"},
{0x102, L"Suspend"}, {0x102, u"Suspend"},
{0x103, L"Hibernate"}, {0x103, u"Hibernate"},
{0x104, L"Toggle Display"}, {0x104, u"Toggle Display"},
{0x105, L"Recovery"}, {0x105, u"Recovery"},
{0x106, L"Reject"}, {0x106, u"Reject"},
{0x0, NULL}, {0x0, NULL},
}; };

View file

@ -63,7 +63,7 @@ static int execute(void)
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
/* Set variable 0 */ /* Set variable 0 */
ret = runtime->set_variable(L"efi_st_var0", &guid_vendor0, ret = runtime->set_variable(u"efi_st_var0", &guid_vendor0,
EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS,
3, v + 4); 3, v + 4);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
@ -72,7 +72,7 @@ static int execute(void)
} }
data[3] = 0xff; data[3] = 0xff;
len = 3; len = 3;
ret = runtime->get_variable(L"efi_st_var0", &guid_vendor0, ret = runtime->get_variable(u"efi_st_var0", &guid_vendor0,
&attr, &len, data); &attr, &len, data);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
efi_st_error("GetVariable failed\n"); efi_st_error("GetVariable failed\n");
@ -87,7 +87,7 @@ static int execute(void)
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
/* Set variable 1 */ /* Set variable 1 */
ret = runtime->set_variable(L"efi_st_var1", &guid_vendor1, ret = runtime->set_variable(u"efi_st_var1", &guid_vendor1,
EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS,
8, v); 8, v);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
@ -95,7 +95,7 @@ static int execute(void)
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
len = EFI_ST_MAX_DATA_SIZE; len = EFI_ST_MAX_DATA_SIZE;
ret = runtime->get_variable(L"efi_st_var1", &guid_vendor1, ret = runtime->get_variable(u"efi_st_var1", &guid_vendor1,
&attr, &len, data); &attr, &len, data);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
efi_st_error("GetVariable failed\n"); efi_st_error("GetVariable failed\n");
@ -111,7 +111,7 @@ static int execute(void)
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
/* Append variable 1 */ /* Append variable 1 */
ret = runtime->set_variable(L"efi_st_var1", &guid_vendor1, ret = runtime->set_variable(u"efi_st_var1", &guid_vendor1,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_APPEND_WRITE, EFI_VARIABLE_APPEND_WRITE,
7, v + 8); 7, v + 8);
@ -120,7 +120,7 @@ static int execute(void)
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
len = EFI_ST_MAX_DATA_SIZE; len = EFI_ST_MAX_DATA_SIZE;
ret = runtime->get_variable(L"efi_st_var1", &guid_vendor1, ret = runtime->get_variable(u"efi_st_var1", &guid_vendor1,
&attr, &len, data); &attr, &len, data);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
efi_st_error("GetVariable failed\n"); efi_st_error("GetVariable failed\n");
@ -132,7 +132,7 @@ static int execute(void)
if (memcmp(data, v, len)) if (memcmp(data, v, len))
efi_st_todo("GetVariable returned wrong value\n"); efi_st_todo("GetVariable returned wrong value\n");
/* Append variable 2 */ /* Append variable 2 */
ret = runtime->set_variable(L"efi_none", &guid_vendor1, ret = runtime->set_variable(u"efi_none", &guid_vendor1,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_APPEND_WRITE, EFI_VARIABLE_APPEND_WRITE,
15, v); 15, v);
@ -173,28 +173,28 @@ static int execute(void)
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
/* Delete variable 1 */ /* Delete variable 1 */
ret = runtime->set_variable(L"efi_st_var1", &guid_vendor1, ret = runtime->set_variable(u"efi_st_var1", &guid_vendor1,
0, 0, NULL); 0, 0, NULL);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
efi_st_error("SetVariable failed\n"); efi_st_error("SetVariable failed\n");
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
len = EFI_ST_MAX_DATA_SIZE; len = EFI_ST_MAX_DATA_SIZE;
ret = runtime->get_variable(L"efi_st_var1", &guid_vendor1, ret = runtime->get_variable(u"efi_st_var1", &guid_vendor1,
&attr, &len, data); &attr, &len, data);
if (ret != EFI_NOT_FOUND) { if (ret != EFI_NOT_FOUND) {
efi_st_error("Variable was not deleted\n"); efi_st_error("Variable was not deleted\n");
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
/* Delete variable 0 */ /* Delete variable 0 */
ret = runtime->set_variable(L"efi_st_var0", &guid_vendor0, ret = runtime->set_variable(u"efi_st_var0", &guid_vendor0,
0, 0, NULL); 0, 0, NULL);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
efi_st_error("SetVariable failed\n"); efi_st_error("SetVariable failed\n");
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
len = EFI_ST_MAX_DATA_SIZE; len = EFI_ST_MAX_DATA_SIZE;
ret = runtime->get_variable(L"efi_st_var0", &guid_vendor0, ret = runtime->get_variable(u"efi_st_var0", &guid_vendor0,
&attr, &len, data); &attr, &len, data);
if (ret != EFI_NOT_FOUND) { if (ret != EFI_NOT_FOUND) {
efi_st_error("Variable was not deleted\n"); efi_st_error("Variable was not deleted\n");

View file

@ -58,7 +58,7 @@ static int execute(void)
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
ret = runtime->set_variable(L"efi_st_var0", &guid_vendor0, ret = runtime->set_variable(u"efi_st_var0", &guid_vendor0,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS, EFI_VARIABLE_RUNTIME_ACCESS,
3, v + 4); 3, v + 4);
@ -67,7 +67,7 @@ static int execute(void)
return EFI_ST_FAILURE; return EFI_ST_FAILURE;
} }
len = EFI_ST_MAX_DATA_SIZE; len = EFI_ST_MAX_DATA_SIZE;
ret = runtime->get_variable(L"PlatformLangCodes", &guid_vendor0, ret = runtime->get_variable(u"PlatformLangCodes", &guid_vendor0,
&attr, &len, data); &attr, &len, data);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
efi_st_error("GetVariable failed\n"); efi_st_error("GetVariable failed\n");

View file

@ -150,7 +150,7 @@ static efi_status_t efi_input(u16 *buffer, efi_uintn_t buffer_size)
struct efi_input_key key = {0}; struct efi_input_key key = {0};
efi_uintn_t index; efi_uintn_t index;
efi_uintn_t pos = 0; efi_uintn_t pos = 0;
u16 outbuf[2] = L" "; u16 outbuf[2] = u" ";
efi_status_t ret; efi_status_t ret;
/* Drain the console input */ /* Drain the console input */
@ -165,7 +165,7 @@ static efi_status_t efi_input(u16 *buffer, efi_uintn_t buffer_size)
continue; continue;
switch (key.scan_code) { switch (key.scan_code) {
case 0x17: /* Escape */ case 0x17: /* Escape */
print(L"\r\nAborted\r\n"); print(u"\r\nAborted\r\n");
return EFI_ABORTED; return EFI_ABORTED;
default: default:
break; break;
@ -174,12 +174,12 @@ static efi_status_t efi_input(u16 *buffer, efi_uintn_t buffer_size)
case 0x08: /* Backspace */ case 0x08: /* Backspace */
if (pos) { if (pos) {
buffer[pos--] = 0; buffer[pos--] = 0;
print(L"\b \b"); print(u"\b \b");
} }
break; break;
case 0x0a: /* Linefeed */ case 0x0a: /* Linefeed */
case 0x0d: /* Carriage return */ case 0x0d: /* Carriage return */
print(L"\r\n"); print(u"\r\n");
return EFI_SUCCESS; return EFI_SUCCESS;
default: default:
break; break;
@ -231,9 +231,9 @@ static bool starts_with(u16 *string, u16 *keyword)
*/ */
static void do_help(void) static void do_help(void)
{ {
error(L"load - show length and CRC32 of initial RAM disk\r\n"); error(u"load - show length and CRC32 of initial RAM disk\r\n");
error(L"save <initrd> - save initial RAM disk to file\r\n"); error(u"save <initrd> - save initial RAM disk to file\r\n");
error(L"exit - exit the shell\r\n"); error(u"exit - exit the shell\r\n");
} }
/** /**
@ -255,7 +255,7 @@ static efi_status_t get_initrd(void **initrd, efi_uintn_t *initrd_size)
*initrd_size = 0; *initrd_size = 0;
ret = bs->locate_device_path(&load_file2_guid, &dp, &handle); ret = bs->locate_device_path(&load_file2_guid, &dp, &handle);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Load File2 protocol not found\r\n"); error(u"Load File2 protocol not found\r\n");
return ret; return ret;
} }
ret = bs->handle_protocol(handle, &load_file2_guid, ret = bs->handle_protocol(handle, &load_file2_guid,
@ -263,20 +263,20 @@ static efi_status_t get_initrd(void **initrd, efi_uintn_t *initrd_size)
ret = load_file2_prot->load_file(load_file2_prot, dp, false, ret = load_file2_prot->load_file(load_file2_prot, dp, false,
initrd_size, NULL); initrd_size, NULL);
if (ret != EFI_BUFFER_TOO_SMALL) { if (ret != EFI_BUFFER_TOO_SMALL) {
error(L"Load File2 protocol does not provide file length\r\n"); error(u"Load File2 protocol does not provide file length\r\n");
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
} }
ret = bs->allocate_pages(EFI_ALLOCATE_ANY_PAGES, EFI_LOADER_DATA, ret = bs->allocate_pages(EFI_ALLOCATE_ANY_PAGES, EFI_LOADER_DATA,
efi_size_in_pages(*initrd_size), &buffer); efi_size_in_pages(*initrd_size), &buffer);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Out of memory\r\n"); error(u"Out of memory\r\n");
return ret; return ret;
} }
*initrd = (void *)(uintptr_t)buffer; *initrd = (void *)(uintptr_t)buffer;
ret = load_file2_prot->load_file(load_file2_prot, dp, false, ret = load_file2_prot->load_file(load_file2_prot, dp, false,
initrd_size, *initrd); initrd_size, *initrd);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Load File2 protocol failed to provide file\r\n"); error(u"Load File2 protocol failed to provide file\r\n");
bs->free_pages(buffer, efi_size_in_pages(*initrd_size)); bs->free_pages(buffer, efi_size_in_pages(*initrd_size));
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
} }
@ -299,18 +299,18 @@ static efi_status_t do_load(void)
ret = get_initrd(&initrd, &initrd_size); ret = get_initrd(&initrd, &initrd_size);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
return ret; return ret;
print(L"length: 0x"); print(u"length: 0x");
printx(initrd_size, 1); printx(initrd_size, 1);
print(L"\r\n"); print(u"\r\n");
ret = bs->calculate_crc32(initrd, initrd_size, &crc32); ret = bs->calculate_crc32(initrd, initrd_size, &crc32);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Calculating CRC32 failed\r\n"); error(u"Calculating CRC32 failed\r\n");
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
} }
print(L"crc32: 0x"); print(u"crc32: 0x");
printx(crc32, 8); printx(crc32, 8);
print(L"\r\n"); print(u"\r\n");
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -340,7 +340,7 @@ static efi_status_t do_save(u16 *filename)
(void **)&loaded_image, NULL, NULL, (void **)&loaded_image, NULL, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL); EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Loaded image protocol not found\r\n"); error(u"Loaded image protocol not found\r\n");
goto out; goto out;
} }
@ -350,26 +350,26 @@ static efi_status_t do_save(u16 *filename)
(void **)&file_system, NULL, NULL, (void **)&file_system, NULL, NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL); EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Failed to open simple file system protocol\r\n"); error(u"Failed to open simple file system protocol\r\n");
goto out; goto out;
} }
/* Open volume */ /* Open volume */
ret = file_system->open_volume(file_system, &root); ret = file_system->open_volume(file_system, &root);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Failed to open volume\r\n"); error(u"Failed to open volume\r\n");
goto out; goto out;
} }
/* Check if file already exists */ /* Check if file already exists */
ret = root->open(root, &file, filename, EFI_FILE_MODE_READ, 0); ret = root->open(root, &file, filename, EFI_FILE_MODE_READ, 0);
if (ret == EFI_SUCCESS) { if (ret == EFI_SUCCESS) {
file->close(file); file->close(file);
print(L"Overwrite existing file (y/n)? "); print(u"Overwrite existing file (y/n)? ");
ret = efi_input_yn(); ret = efi_input_yn();
print(L"\r\n"); print(u"\r\n");
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
root->close(root); root->close(root);
error(L"Aborted by user\r\n"); error(u"Aborted by user\r\n");
goto out; goto out;
} }
} }
@ -382,14 +382,14 @@ static efi_status_t do_save(u16 *filename)
/* Write file */ /* Write file */
ret = file->write(file, &initrd_size, initrd); ret = file->write(file, &initrd_size, initrd);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
error(L"Failed to write file\r\n"); error(u"Failed to write file\r\n");
} else { } else {
print(filename); print(filename);
print(L" written\r\n"); print(u" written\r\n");
} }
file->close(file); file->close(file);
} else { } else {
error(L"Failed to open file\r\n"); error(u"Failed to open file\r\n");
} }
root->close(root); root->close(root);
@ -420,7 +420,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image_handle,
cout->set_attribute(cout, EFI_LIGHTBLUE | EFI_BACKGROUND_BLACK); cout->set_attribute(cout, EFI_LIGHTBLUE | EFI_BACKGROUND_BLACK);
cout->clear_screen(cout); cout->clear_screen(cout);
cout->set_attribute(cout, EFI_WHITE | EFI_BACKGROUND_BLACK); cout->set_attribute(cout, EFI_WHITE | EFI_BACKGROUND_BLACK);
print(L"INITRD Dump\r\n========\r\n\r\n"); print(u"INITRD Dump\r\n========\r\n\r\n");
cout->set_attribute(cout, EFI_LIGHTBLUE | EFI_BACKGROUND_BLACK); cout->set_attribute(cout, EFI_LIGHTBLUE | EFI_BACKGROUND_BLACK);
for (;;) { for (;;) {
@ -428,16 +428,16 @@ efi_status_t EFIAPI efi_main(efi_handle_t image_handle,
u16 *pos; u16 *pos;
efi_uintn_t ret; efi_uintn_t ret;
print(L"=> "); print(u"=> ");
ret = efi_input(command, sizeof(command)); ret = efi_input(command, sizeof(command));
if (ret == EFI_ABORTED) if (ret == EFI_ABORTED)
break; break;
pos = skip_whitespace(command); pos = skip_whitespace(command);
if (starts_with(pos, L"exit")) if (starts_with(pos, u"exit"))
break; break;
else if (starts_with(pos, L"load")) else if (starts_with(pos, u"load"))
do_load(); do_load();
else if (starts_with(pos, L"save ")) else if (starts_with(pos, u"save "))
do_save(pos + 5); do_save(pos + 5);
else else
do_help(); do_help();