1
0
mirror of https://github.com/systemd/systemd synced 2026-04-25 16:34:50 +02:00

Compare commits

..

No commits in common. "bac8fe924e6599168e8bd54487eb85215ffe26ad" and "4bcf5c11c8a951f9feef2964a721cc245b753873" have entirely different histories.

7 changed files with 22 additions and 51 deletions

View File

@ -493,7 +493,7 @@ static void print_status(Config *config, CHAR16 *loaded_image_path) {
Print(L" secure boot: %s (%s)\n", yes_no(IN_SET(secure, SECURE_BOOT_USER, SECURE_BOOT_DEPLOYED)), secure_boot_mode_to_string(secure)); Print(L" secure boot: %s (%s)\n", yes_no(IN_SET(secure, SECURE_BOOT_USER, SECURE_BOOT_DEPLOYED)), secure_boot_mode_to_string(secure));
ps_bool(L" shim: %s\n", shim_loaded()); ps_bool(L" shim: %s\n", shim_loaded());
ps_bool(L" TPM: %s\n", tpm_present()); ps_bool(L" TPM: %s\n", tpm_present());
Print(L" console mode: %d/%ld (%" PRIuN L"x%" PRIuN L" @%ux%u)\n", ST->ConOut->Mode->Mode, ST->ConOut->Mode->MaxMode - INT64_C(1), x_max, y_max, screen_width, screen_height); Print(L" console mode: %d/%d (%lux%lu @%ux%u)\n", ST->ConOut->Mode->Mode, ST->ConOut->Mode->MaxMode - 1LL, x_max, y_max, screen_width, screen_height);
if (!ps_continue()) if (!ps_continue())
return; return;
@ -506,7 +506,7 @@ static void print_status(Config *config, CHAR16 *loaded_image_path) {
case TIMEOUT_MENU_HIDDEN: case TIMEOUT_MENU_HIDDEN:
Print(L" timeout: menu-hidden\n"); break; Print(L" timeout: menu-hidden\n"); break;
default: default:
Print(L" timeout: %u s\n", config->timeout_sec_config); Print(L" timeout: %lu s\n", config->timeout_sec_config);
} }
switch (config->timeout_sec_efivar) { switch (config->timeout_sec_efivar) {
@ -517,7 +517,7 @@ static void print_status(Config *config, CHAR16 *loaded_image_path) {
case TIMEOUT_MENU_HIDDEN: case TIMEOUT_MENU_HIDDEN:
Print(L" timeout (EFI var): menu-hidden\n"); break; Print(L" timeout (EFI var): menu-hidden\n"); break;
default: default:
Print(L" timeout (EFI var): %u s\n", config->timeout_sec_efivar); Print(L" timeout (EFI var): %lu s\n", config->timeout_sec_efivar);
} }
ps_string(L" default: %s\n", config->entry_default_config); ps_string(L" default: %s\n", config->entry_default_config);
@ -552,7 +552,7 @@ static void print_status(Config *config, CHAR16 *loaded_image_path) {
for (UINTN i = 0; i < config->entry_count; i++) { for (UINTN i = 0; i < config->entry_count; i++) {
ConfigEntry *entry = config->entries[i]; ConfigEntry *entry = config->entries[i];
Print(L" config entry: %" PRIuN L"/%" PRIuN L"\n", i + 1, config->entry_count); Print(L" config entry: %lu/%lu\n", i + 1, config->entry_count);
ps_string(L" id: %s\n", entry->id); ps_string(L" id: %s\n", entry->id);
ps_string(L" title: %s\n", entry->title); ps_string(L" title: %s\n", entry->title);
ps_string(L" title show: %s\n", streq_ptr(entry->title, entry->title_show) ? NULL : entry->title_show); ps_string(L" title show: %s\n", streq_ptr(entry->title, entry->title_show) ? NULL : entry->title_show);
@ -568,7 +568,7 @@ static void print_status(Config *config, CHAR16 *loaded_image_path) {
ps_bool(L"counting boots: %s\n", entry->tries_left != UINTN_MAX); ps_bool(L"counting boots: %s\n", entry->tries_left != UINTN_MAX);
if (entry->tries_left != UINTN_MAX) { if (entry->tries_left != UINTN_MAX) {
Print(L" tries: %" PRIuN L" done, %" PRIuN L" left\n", entry->tries_done, entry->tries_left); Print(L" tries: %lu done, %lu left\n", entry->tries_done, entry->tries_left);
Print(L" current path: %s\\%s\n", entry->path, entry->current_name); Print(L" current path: %s\\%s\n", entry->path, entry->current_name);
Print(L" next path: %s\\%s\n", entry->path, entry->next_name); Print(L" next path: %s\\%s\n", entry->path, entry->next_name);
} }
@ -920,14 +920,10 @@ static BOOLEAN menu_run(
break; break;
case KEYPRESS(0, 0, 'v'): case KEYPRESS(0, 0, 'v'):
status = xpool_print( status = xpool_print(L"systemd-boot " GIT_VERSION " (" EFI_MACHINE_TYPE_NAME "), "
L"systemd-boot " GIT_VERSION L" (" EFI_MACHINE_TYPE_NAME L"), " L"UEFI Specification %d.%02d, Vendor %s %d.%02d",
L"UEFI Specification %u.%02u, Vendor %s %u.%02u", ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff,
ST->Hdr.Revision >> 16, ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff);
ST->Hdr.Revision & 0xffff,
ST->FirmwareVendor,
ST->FirmwareRevision >> 16,
ST->FirmwareRevision & 0xffff);
break; break;
case KEYPRESS(0, 0, 'p'): case KEYPRESS(0, 0, 'p'):
@ -1366,7 +1362,7 @@ good:
prefix = xstrdup(file); prefix = xstrdup(file);
prefix[i] = 0; prefix[i] = 0;
entry->next_name = xpool_print(L"%s+%" PRIuN L"-%" PRIuN L"%s", prefix, next_left, next_done, suffix ?: L""); entry->next_name = xpool_print(L"%s+%u-%u%s", prefix, next_left, next_done, suffix ?: L"");
} }
static void config_entry_bump_counters(ConfigEntry *entry, EFI_FILE *root_dir) { static void config_entry_bump_counters(ConfigEntry *entry, EFI_FILE *root_dir) {
@ -2078,7 +2074,7 @@ static EFI_STATUS boot_windows_bitlocker(void) {
CHAR16 name[sizeof(L"Boot0000")]; CHAR16 name[sizeof(L"Boot0000")];
UINTN buf_size; UINTN buf_size;
SPrint(name, sizeof(name), L"Boot%04x", (UINT32) boot_order[i]); SPrint(name, sizeof(name), L"Boot%04x", boot_order[i]);
err = efivar_get_raw(EFI_GLOBAL_GUID, name, &buf, &buf_size); err = efivar_get_raw(EFI_GLOBAL_GUID, name, &buf, &buf_size);
if (EFI_ERROR(err)) if (EFI_ERROR(err))
continue; continue;
@ -2316,6 +2312,7 @@ static void config_load_xbootldr(
} }
static EFI_STATUS image_start( static EFI_STATUS image_start(
EFI_FILE *root_dir,
EFI_HANDLE parent_image, EFI_HANDLE parent_image,
const Config *config, const Config *config,
const ConfigEntry *entry) { const ConfigEntry *entry) {
@ -2333,10 +2330,6 @@ static EFI_STATUS image_start(
if (entry->call) if (entry->call)
(void) entry->call(); (void) entry->call();
_cleanup_(file_closep) EFI_FILE *image_root = LibOpenRoot(entry->device);
if (!image_root)
return log_error_status_stall(EFI_DEVICE_ERROR, L"Error opening root path.");
path = FileDevicePath(entry->device, entry->loader); path = FileDevicePath(entry->device, entry->loader);
if (!path) if (!path)
return log_error_status_stall(EFI_INVALID_PARAMETER, L"Error getting device path."); return log_error_status_stall(EFI_INVALID_PARAMETER, L"Error getting device path.");
@ -2346,7 +2339,7 @@ static EFI_STATUS image_start(
return log_error_status_stall(err, L"Error loading %s: %r", entry->loader, err); return log_error_status_stall(err, L"Error loading %s: %r", entry->loader, err);
if (entry->devicetree) { if (entry->devicetree) {
err = devicetree_install(&dtstate, image_root, entry->devicetree); err = devicetree_install(&dtstate, root_dir, entry->devicetree);
if (EFI_ERROR(err)) if (EFI_ERROR(err))
return log_error_status_stall(err, L"Error loading %s: %r", entry->devicetree, err); return log_error_status_stall(err, L"Error loading %s: %r", entry->devicetree, err);
} }
@ -2465,10 +2458,10 @@ static void export_variables(
efivar_set_time_usec(LOADER_GUID, L"LoaderTimeInitUSec", init_usec); efivar_set_time_usec(LOADER_GUID, L"LoaderTimeInitUSec", init_usec);
efivar_set(LOADER_GUID, L"LoaderInfo", L"systemd-boot " GIT_VERSION, 0); efivar_set(LOADER_GUID, L"LoaderInfo", L"systemd-boot " GIT_VERSION, 0);
infostr = xpool_print(L"%s %u.%02u", ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff); infostr = xpool_print(L"%s %d.%02d", ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff);
efivar_set(LOADER_GUID, L"LoaderFirmwareInfo", infostr, 0); efivar_set(LOADER_GUID, L"LoaderFirmwareInfo", infostr, 0);
typestr = xpool_print(L"UEFI %u.%02u", ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff); typestr = xpool_print(L"UEFI %d.%02d", ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff);
efivar_set(LOADER_GUID, L"LoaderFirmwareType", typestr, 0); efivar_set(LOADER_GUID, L"LoaderFirmwareType", typestr, 0);
(void) efivar_set_uint64_le(LOADER_GUID, L"LoaderFeatures", loader_features, 0); (void) efivar_set_uint64_le(LOADER_GUID, L"LoaderFeatures", loader_features, 0);
@ -2621,7 +2614,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
/* Optionally, read a random seed off the ESP and pass it to the OS */ /* Optionally, read a random seed off the ESP and pass it to the OS */
(void) process_random_seed(root_dir, config.random_seed_mode); (void) process_random_seed(root_dir, config.random_seed_mode);
err = image_start(image, &config, entry); err = image_start(root_dir, image, &config, entry);
if (EFI_ERROR(err)) { if (EFI_ERROR(err)) {
graphics_mode(FALSE); graphics_mode(FALSE);
log_error_stall(L"Failed to execute %s (%s): %r", entry->title_show, entry->loader, err); log_error_stall(L"Failed to execute %s (%s): %r", entry->title_show, entry->loader, err);

View File

@ -71,7 +71,7 @@ static EFI_STATUS reconnect(void) {
if (err == EFI_NOT_FOUND) /* No drivers for this handle */ if (err == EFI_NOT_FOUND) /* No drivers for this handle */
continue; continue;
if (EFI_ERROR(err)) if (EFI_ERROR(err))
log_error_status_stall(err, L"Failed to reconnect handle %" PRIuN L", ignoring: %r", i, err); log_error_status_stall(err, L"Failed to reconnect handle %u, ignoring: %r", i, err);
} }
return EFI_SUCCESS; return EFI_SUCCESS;

View File

@ -131,14 +131,14 @@ static void export_variables(EFI_LOADED_IMAGE *loaded_image) {
/* if LoaderFirmwareInfo is not set, let's set it */ /* if LoaderFirmwareInfo is not set, let's set it */
if (efivar_get_raw(LOADER_GUID, L"LoaderFirmwareInfo", NULL, NULL) != EFI_SUCCESS) { if (efivar_get_raw(LOADER_GUID, L"LoaderFirmwareInfo", NULL, NULL) != EFI_SUCCESS) {
_cleanup_freepool_ CHAR16 *s = NULL; _cleanup_freepool_ CHAR16 *s = NULL;
s = xpool_print(L"%s %u.%02u", ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff); s = xpool_print(L"%s %d.%02d", ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff);
efivar_set(LOADER_GUID, L"LoaderFirmwareInfo", s, 0); efivar_set(LOADER_GUID, L"LoaderFirmwareInfo", s, 0);
} }
/* ditto for LoaderFirmwareType */ /* ditto for LoaderFirmwareType */
if (efivar_get_raw(LOADER_GUID, L"LoaderFirmwareType", NULL, NULL) != EFI_SUCCESS) { if (efivar_get_raw(LOADER_GUID, L"LoaderFirmwareType", NULL, NULL) != EFI_SUCCESS) {
_cleanup_freepool_ CHAR16 *s = NULL; _cleanup_freepool_ CHAR16 *s = NULL;
s = xpool_print(L"UEFI %u.%02u", ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff); s = xpool_print(L"UEFI %d.%02d", ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff);
efivar_set(LOADER_GUID, L"LoaderFirmwareType", s, 0); efivar_set(LOADER_GUID, L"LoaderFirmwareType", s, 0);
} }

View File

@ -57,10 +57,7 @@ EFI_STATUS efivar_set_uint_string(const EFI_GUID *vendor, const CHAR16 *name, UI
assert(vendor); assert(vendor);
assert(name); assert(name);
/* Note that SPrint has no native sized length specifier and will always use ValueToString() SPrint(str, ELEMENTSOF(str), L"%u", i);
* regardless of what sign we tell it to use. Therefore, UINTN_MAX will come out as -1 on
* 64bit machines. */
ValueToString(str, FALSE, i);
return efivar_set(vendor, name, str, flags); return efivar_set(vendor, name, str, flags);
} }
@ -239,8 +236,7 @@ void efivar_set_time_usec(const EFI_GUID *vendor, const CHAR16 *name, UINT64 use
if (usec == 0) if (usec == 0)
return; return;
/* See comment on ValueToString in efivar_set_uint_string(). */ SPrint(str, ELEMENTSOF(str), L"%ld", usec);
ValueToString(str, FALSE, usec);
efivar_set(vendor, name, str, 0); efivar_set(vendor, name, str, 0);
} }

View File

@ -17,20 +17,6 @@
#define UINT64_MAX ((UINT64) -1) #define UINT64_MAX ((UINT64) -1)
#endif #endif
/* gnu-efi format specifiers for integers are fixed to either 64bit with 'l' and 32bit without a size prefix.
* We rely on %u/%d/%x to format regular ints, so ensure the size is what we expect. At the same time, we also
* need specifiers for (U)INTN which are native (pointer) sized. */
assert_cc(sizeof(int) == sizeof(UINT32));
#if __SIZEOF_POINTER__ == 4
# define PRIuN L"u"
# define PRIiN L"d"
#elif __SIZEOF_POINTER__ == 8
# define PRIuN L"lu"
# define PRIiN L"ld"
#else
# error "Unexpected pointer size"
#endif
#define xnew_alloc(type, n, alloc) \ #define xnew_alloc(type, n, alloc) \
({ \ ({ \
UINTN _alloc_size; \ UINTN _alloc_size; \
@ -160,7 +146,7 @@ void debug_break(void);
extern UINT8 _text, _data; extern UINT8 _text, _data;
/* Report the relocated position of text and data sections so that a debugger /* Report the relocated position of text and data sections so that a debugger
* can attach to us. See debug-sd-boot.sh for how this can be done. */ * can attach to us. See debug-sd-boot.sh for how this can be done. */
# define debug_hook(identity) Print(identity L"@0x%lx,0x%lx\n", POINTER_TO_PHYSICAL_ADDRESS(&_text), POINTER_TO_PHYSICAL_ADDRESS(&_data)) # define debug_hook(identity) Print(identity L"@0x%x,0x%x\n", &_text, &_data)
#else #else
# define debug_hook(identity) # define debug_hook(identity)
#endif #endif

View File

@ -336,7 +336,6 @@ Unit.ConditionSecurity, config_parse_unit_condition_string,
Unit.ConditionCapability, config_parse_unit_condition_string, CONDITION_CAPABILITY, offsetof(Unit, conditions) Unit.ConditionCapability, config_parse_unit_condition_string, CONDITION_CAPABILITY, offsetof(Unit, conditions)
Unit.ConditionACPower, config_parse_unit_condition_string, CONDITION_AC_POWER, offsetof(Unit, conditions) Unit.ConditionACPower, config_parse_unit_condition_string, CONDITION_AC_POWER, offsetof(Unit, conditions)
Unit.ConditionMemory, config_parse_unit_condition_string, CONDITION_MEMORY, offsetof(Unit, conditions) Unit.ConditionMemory, config_parse_unit_condition_string, CONDITION_MEMORY, offsetof(Unit, conditions)
Unit.ConditionCPUFeature, config_parse_unit_condition_string, CONDITION_CPU_FEATURE, offsetof(Unit, conditions)
Unit.ConditionCPUs, config_parse_unit_condition_string, CONDITION_CPUS, offsetof(Unit, conditions) Unit.ConditionCPUs, config_parse_unit_condition_string, CONDITION_CPUS, offsetof(Unit, conditions)
Unit.ConditionEnvironment, config_parse_unit_condition_string, CONDITION_ENVIRONMENT, offsetof(Unit, conditions) Unit.ConditionEnvironment, config_parse_unit_condition_string, CONDITION_ENVIRONMENT, offsetof(Unit, conditions)
Unit.ConditionUser, config_parse_unit_condition_string, CONDITION_USER, offsetof(Unit, conditions) Unit.ConditionUser, config_parse_unit_condition_string, CONDITION_USER, offsetof(Unit, conditions)
@ -367,7 +366,6 @@ Unit.AssertSecurity, config_parse_unit_condition_string,
Unit.AssertCapability, config_parse_unit_condition_string, CONDITION_CAPABILITY, offsetof(Unit, asserts) Unit.AssertCapability, config_parse_unit_condition_string, CONDITION_CAPABILITY, offsetof(Unit, asserts)
Unit.AssertACPower, config_parse_unit_condition_string, CONDITION_AC_POWER, offsetof(Unit, asserts) Unit.AssertACPower, config_parse_unit_condition_string, CONDITION_AC_POWER, offsetof(Unit, asserts)
Unit.AssertMemory, config_parse_unit_condition_string, CONDITION_MEMORY, offsetof(Unit, asserts) Unit.AssertMemory, config_parse_unit_condition_string, CONDITION_MEMORY, offsetof(Unit, asserts)
Unit.AssertCPUFeature, config_parse_unit_condition_string, CONDITION_CPU_FEATURE, offsetof(Unit, asserts)
Unit.AssertCPUs, config_parse_unit_condition_string, CONDITION_CPUS, offsetof(Unit, asserts) Unit.AssertCPUs, config_parse_unit_condition_string, CONDITION_CPUS, offsetof(Unit, asserts)
Unit.AssertEnvironment, config_parse_unit_condition_string, CONDITION_ENVIRONMENT, offsetof(Unit, asserts) Unit.AssertEnvironment, config_parse_unit_condition_string, CONDITION_ENVIRONMENT, offsetof(Unit, asserts)
Unit.AssertUser, config_parse_unit_condition_string, CONDITION_USER, offsetof(Unit, asserts) Unit.AssertUser, config_parse_unit_condition_string, CONDITION_USER, offsetof(Unit, asserts)

View File

@ -4,7 +4,6 @@ After=
AllowIsolate= AllowIsolate=
AssertACPower= AssertACPower=
AssertArchitecture= AssertArchitecture=
AssertCPUFeature=
AssertCPUPressure= AssertCPUPressure=
AssertCPUs= AssertCPUs=
AssertCapability= AssertCapability=
@ -41,7 +40,6 @@ BindsTo=
CollectMode= CollectMode=
ConditionACPower= ConditionACPower=
ConditionArchitecture= ConditionArchitecture=
ConditionCPUFeature=
ConditionCPUPressure= ConditionCPUPressure=
ConditionCPUs= ConditionCPUs=
ConditionFirmware= ConditionFirmware=