summaryrefslogtreecommitdiffstats
path: root/src/boot/efi
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/boot/efi/bcd.c92
-rw-r--r--src/boot/efi/bcd.h2
-rw-r--r--src/boot/efi/boot.c60
-rw-r--r--src/boot/efi/console.c24
-rw-r--r--src/boot/efi/console.h10
-rw-r--r--src/boot/efi/cpio.c28
-rw-r--r--src/boot/efi/cpio.h6
-rw-r--r--src/boot/efi/linux.c6
-rw-r--r--src/boot/efi/linux_x86.c150
-rw-r--r--src/boot/efi/measure.c14
-rw-r--r--src/boot/efi/measure.h4
-rw-r--r--src/boot/efi/pe.c148
-rw-r--r--src/boot/efi/pe.h6
-rw-r--r--src/boot/efi/random-seed.c12
-rw-r--r--src/boot/efi/shim.c10
-rw-r--r--src/boot/efi/splash.c60
-rw-r--r--src/boot/efi/splash.h2
-rw-r--r--src/boot/efi/stub.c12
-rw-r--r--src/boot/efi/ticks.c28
-rw-r--r--src/boot/efi/ticks.h5
-rw-r--r--src/boot/efi/util.c74
-rw-r--r--src/boot/efi/util.h28
-rw-r--r--src/boot/efi/xbootldr.c12
23 files changed, 391 insertions, 402 deletions
diff --git a/src/boot/efi/bcd.c b/src/boot/efi/bcd.c
index 11f2a81c10..7418473d8e 100644
--- a/src/boot/efi/bcd.c
+++ b/src/boot/efi/bcd.c
@@ -12,10 +12,6 @@
# define CHAR8 char
# define CHAR16 char16_t
-# define UINT8 uint8_t
-# define UINT16 uint16_t
-# define UINT32 uint32_t
-# define UINT64 uint64_t
# define UINTN size_t
# define TEST_STATIC static
#endif
@@ -36,16 +32,16 @@ enum {
* been squashed into _padN for our convenience. */
typedef struct {
- UINT32 sig;
- UINT32 primary_seqnum;
- UINT32 secondary_seqnum;
- UINT64 _pad1;
- UINT32 version_major;
- UINT32 version_minor;
- UINT32 type;
- UINT32 _pad2;
- UINT32 root_cell_offset;
- UINT64 _pad3[507];
+ uint32_t sig;
+ uint32_t primary_seqnum;
+ uint32_t secondary_seqnum;
+ uint64_t _pad1;
+ uint32_t version_major;
+ uint32_t version_minor;
+ uint32_t type;
+ uint32_t _pad2;
+ uint32_t root_cell_offset;
+ uint64_t _pad3[507];
} _packed_ BaseBlock;
assert_cc(sizeof(BaseBlock) == 4096);
assert_cc(offsetof(BaseBlock, sig) == 0);
@@ -58,19 +54,19 @@ assert_cc(offsetof(BaseBlock, root_cell_offset) == 36);
/* All offsets are relative to the base block and technically point to a hive
* cell struct. But for our usecase we don't need to bother about that one,
- * so skip over the cell_size UINT32. */
+ * so skip over the cell_size uint32_t. */
#define HIVE_CELL_OFFSET (sizeof(BaseBlock) + 4)
typedef struct {
- UINT16 sig;
- UINT16 _pad1[13];
- UINT32 subkeys_offset;
- UINT32 _pad2;
- UINT32 n_key_values;
- UINT32 key_values_offset;
- UINT32 _pad3[7];
- UINT16 key_name_len;
- UINT16 _pad4;
+ uint16_t sig;
+ uint16_t _pad1[13];
+ uint32_t subkeys_offset;
+ uint32_t _pad2;
+ uint32_t n_key_values;
+ uint32_t key_values_offset;
+ uint32_t _pad3[7];
+ uint16_t key_name_len;
+ uint16_t _pad4;
CHAR8 key_name[];
} _packed_ Key;
assert_cc(offsetof(Key, sig) == 0);
@@ -81,10 +77,10 @@ assert_cc(offsetof(Key, key_name_len) == 72);
assert_cc(offsetof(Key, key_name) == 76);
typedef struct {
- UINT16 sig;
- UINT16 n_entries;
+ uint16_t sig;
+ uint16_t n_entries;
struct SubkeyFastEntry {
- UINT32 key_offset;
+ uint32_t key_offset;
CHAR8 name_hint[4];
} _packed_ entries[];
} _packed_ SubkeyFast;
@@ -93,12 +89,12 @@ assert_cc(offsetof(SubkeyFast, n_entries) == 2);
assert_cc(offsetof(SubkeyFast, entries) == 4);
typedef struct {
- UINT16 sig;
- UINT16 name_len;
- UINT32 data_size;
- UINT32 data_offset;
- UINT32 data_type;
- UINT32 _pad;
+ uint16_t sig;
+ uint16_t name_len;
+ uint32_t data_size;
+ uint32_t data_offset;
+ uint32_t data_type;
+ uint32_t _pad;
CHAR8 name[];
} _packed_ KeyValue;
assert_cc(offsetof(KeyValue, sig) == 0);
@@ -109,18 +105,18 @@ assert_cc(offsetof(KeyValue, data_type) == 12);
assert_cc(offsetof(KeyValue, name) == 20);
#define BAD_OFFSET(offset, len, max) \
- ((UINT64) (offset) + (len) >= (max))
+ ((uint64_t) (offset) + (len) >= (max))
#define BAD_STRUCT(type, offset, max) \
- ((UINT64) (offset) + sizeof(type) >= (max))
+ ((uint64_t) (offset) + sizeof(type) >= (max))
#define BAD_ARRAY(type, array, offset, array_len, max) \
- ((UINT64) (offset) + offsetof(type, array) + \
- sizeof((type){}.array[0]) * (UINT64) (array_len) >= (max))
+ ((uint64_t) (offset) + offsetof(type, array) + \
+ sizeof((type){}.array[0]) * (uint64_t) (array_len) >= (max))
-static const Key *get_key(const UINT8 *bcd, UINT32 bcd_len, UINT32 offset, const CHAR8 *name);
+static const Key *get_key(const uint8_t *bcd, uint32_t bcd_len, uint32_t offset, const CHAR8 *name);
-static const Key *get_subkey(const UINT8 *bcd, UINT32 bcd_len, UINT32 offset, const CHAR8 *name) {
+static const Key *get_subkey(const uint8_t *bcd, uint32_t bcd_len, uint32_t offset, const CHAR8 *name) {
assert(bcd);
assert(name);
@@ -134,7 +130,7 @@ static const Key *get_subkey(const UINT8 *bcd, UINT32 bcd_len, UINT32 offset, co
if (BAD_ARRAY(SubkeyFast, entries, offset, subkey->n_entries, bcd_len))
return NULL;
- for (UINT16 i = 0; i < subkey->n_entries; i++) {
+ for (uint16_t i = 0; i < subkey->n_entries; i++) {
if (!strncaseeq8((char *) name, (char *) subkey->entries[i].name_hint, sizeof(subkey->entries[i].name_hint)))
continue;
@@ -149,7 +145,7 @@ static const Key *get_subkey(const UINT8 *bcd, UINT32 bcd_len, UINT32 offset, co
/* We use NUL as registry path separators for convenience. To start from the root, begin
* name with a NUL. Name must end with two NUL. The lookup depth is not restricted, so
* name must be properly validated before calling get_key(). */
-static const Key *get_key(const UINT8 *bcd, UINT32 bcd_len, UINT32 offset, const CHAR8 *name) {
+static const Key *get_key(const uint8_t *bcd, uint32_t bcd_len, uint32_t offset, const CHAR8 *name) {
assert(bcd);
assert(name);
@@ -174,7 +170,7 @@ static const Key *get_key(const UINT8 *bcd, UINT32 bcd_len, UINT32 offset, const
return *name ? get_subkey(bcd, bcd_len, key->subkeys_offset, name) : key;
}
-static const KeyValue *get_key_value(const UINT8 *bcd, UINT32 bcd_len, const Key *key, const CHAR8 *name) {
+static const KeyValue *get_key_value(const uint8_t *bcd, uint32_t bcd_len, const Key *key, const CHAR8 *name) {
assert(bcd);
assert(key);
assert(name);
@@ -182,13 +178,13 @@ static const KeyValue *get_key_value(const UINT8 *bcd, UINT32 bcd_len, const Key
if (key->n_key_values == 0)
return NULL;
- if (BAD_OFFSET(key->key_values_offset, sizeof(UINT32) * (UINT64) key->n_key_values, bcd_len) ||
- (UINTN)(bcd + key->key_values_offset) % sizeof(UINT32) != 0)
+ if (BAD_OFFSET(key->key_values_offset, sizeof(uint32_t) * (uint64_t) key->n_key_values, bcd_len) ||
+ (UINTN)(bcd + key->key_values_offset) % sizeof(uint32_t) != 0)
return NULL;
- const UINT32 *key_value_list = (const UINT32 *) (bcd + key->key_values_offset);
- for (UINT32 i = 0; i < key->n_key_values; i++) {
- UINT32 offset = *(key_value_list + i);
+ const uint32_t *key_value_list = (const uint32_t *) (bcd + key->key_values_offset);
+ for (uint32_t i = 0; i < key->n_key_values; i++) {
+ uint32_t offset = *(key_value_list + i);
if (BAD_STRUCT(KeyValue, offset, bcd_len))
continue;
@@ -233,7 +229,7 @@ static const KeyValue *get_key_value(const UINT8 *bcd, UINT32 bcd_len, const Key
* (it always has the GUID 9dea862c-5cdd-4e70-acc1-f32b344d4795). If it contains more than
* one GUID, the BCD is multi-boot and we stop looking. Otherwise we take that GUID, look it
* up, and return its description property. */
-TEST_STATIC CHAR16 *get_bcd_title(UINT8 *bcd, UINTN bcd_len) {
+TEST_STATIC CHAR16 *get_bcd_title(uint8_t *bcd, UINTN bcd_len) {
assert(bcd);
if (HIVE_CELL_OFFSET >= bcd_len)
diff --git a/src/boot/efi/bcd.h b/src/boot/efi/bcd.h
index e55565acba..63be54566a 100644
--- a/src/boot/efi/bcd.h
+++ b/src/boot/efi/bcd.h
@@ -3,4 +3,4 @@
#include <efi.h>
-CHAR16 *get_bcd_title(UINT8 *bcd, UINTN bcd_len);
+CHAR16 *get_bcd_title(uint8_t *bcd, UINTN bcd_len);
diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c
index f4b987f2f5..0c02396662 100644
--- a/src/boot/efi/boot.c
+++ b/src/boot/efi/boot.c
@@ -77,9 +77,9 @@ typedef struct {
UINTN entry_count;
UINTN idx_default;
UINTN idx_default_efivar;
- UINT32 timeout_sec; /* Actual timeout used (efi_main() override > efivar > config). */
- UINT32 timeout_sec_config;
- UINT32 timeout_sec_efivar;
+ uint32_t timeout_sec; /* Actual timeout used (efi_main() override > efivar > config). */
+ uint32_t timeout_sec_config;
+ uint32_t timeout_sec_efivar;
CHAR16 *entry_default_config;
CHAR16 *entry_default_efivar;
CHAR16 *entry_oneshot;
@@ -92,8 +92,8 @@ typedef struct {
BOOLEAN use_saved_entry;
BOOLEAN use_saved_entry_efivar;
BOOLEAN beep;
- INT64 console_mode;
- INT64 console_mode_efivar;
+ int64_t console_mode;
+ int64_t console_mode_efivar;
RandomSeedMode random_seed_mode;
} Config;
@@ -157,7 +157,7 @@ static BOOLEAN line_edit(
for (;;) {
EFI_STATUS err;
- UINT64 key;
+ uint64_t key;
UINTN j;
UINTN cursor_color = TEXT_ATTR_SWAP(COLOR_EDIT);
@@ -396,7 +396,7 @@ static UINTN entry_lookup_key(Config *config, UINTN start, CHAR16 key) {
return IDX_INVALID;
}
-static CHAR16 *update_timeout_efivar(UINT32 *t, BOOLEAN inc) {
+static CHAR16 *update_timeout_efivar(uint32_t *t, BOOLEAN inc) {
assert(t);
switch (*t) {
@@ -456,14 +456,14 @@ static BOOLEAN ps_continue(void) {
else
Print(L"\n--- Press any key to continue, ESC or q to quit. ---\n\n");
- UINT64 key;
+ uint64_t key;
return console_key_read(&key, UINT64_MAX) == EFI_SUCCESS &&
!IN_SET(key, KEYPRESS(0, SCAN_ESC, 0), KEYPRESS(0, 0, 'q'), KEYPRESS(0, 0, 'Q'));
}
static void print_status(Config *config, CHAR16 *loaded_image_path) {
UINTN x_max, y_max;
- UINT32 screen_width = 0, screen_height = 0;
+ uint32_t screen_width = 0, screen_height = 0;
SecureBootMode secure;
_cleanup_freepool_ CHAR16 *device_part_uuid = NULL;
@@ -578,7 +578,7 @@ static void print_status(Config *config, CHAR16 *loaded_image_path) {
}
static EFI_STATUS reboot_into_firmware(void) {
- UINT64 osind = 0;
+ uint64_t osind = 0;
EFI_STATUS err;
if (!FLAGS_SET(get_os_indications_supported(), EFI_OS_INDICATIONS_BOOT_TO_FW_UI))
@@ -615,10 +615,10 @@ static BOOLEAN menu_run(
UINTN x_max, y_max;
_cleanup_(strv_freep) CHAR16 **lines = NULL;
_cleanup_freepool_ CHAR16 *clearline = NULL, *separator = NULL, *status = NULL;
- UINT32 timeout_efivar_saved = config->timeout_sec_efivar;
- UINT32 timeout_remain = config->timeout_sec == TIMEOUT_MENU_FORCE ? 0 : config->timeout_sec;
+ uint32_t timeout_efivar_saved = config->timeout_sec_efivar;
+ uint32_t timeout_remain = config->timeout_sec == TIMEOUT_MENU_FORCE ? 0 : config->timeout_sec;
BOOLEAN exit = FALSE, run = TRUE, firmware_setup = FALSE;
- INT64 console_mode_initial = ST->ConOut->Mode->Mode, console_mode_efivar_saved = config->console_mode_efivar;
+ int64_t console_mode_initial = ST->ConOut->Mode->Mode, console_mode_efivar_saved = config->console_mode_efivar;
UINTN default_efivar_saved = config->idx_default_efivar;
graphics_mode(FALSE);
@@ -637,7 +637,7 @@ static BOOLEAN menu_run(
UINTN line_width = 0, entry_padding = 3;
while (!exit) {
- UINT64 key;
+ uint64_t key;
if (new_mode) {
console_query_mode(&x_max, &y_max);
@@ -1459,8 +1459,8 @@ static void config_entry_add_type1(
if (streq8((char *) key, "initrd")) {
entry->initrd = xrealloc(
entry->initrd,
- n_initrd == 0 ? 0 : (n_initrd + 1) * sizeof(UINT16 *),
- (n_initrd + 2) * sizeof(UINT16 *));
+ n_initrd == 0 ? 0 : (n_initrd + 1) * sizeof(uint16_t *),
+ (n_initrd + 2) * sizeof(uint16_t *));
entry->initrd[n_initrd++] = xstra_to_path(value);
entry->initrd[n_initrd] = NULL;
continue;
@@ -1950,28 +1950,28 @@ static EFI_STATUS boot_windows_bitlocker(void) {
if (!found)
return EFI_NOT_FOUND;
- _cleanup_freepool_ UINT16 *boot_order = NULL;
+ _cleanup_freepool_ uint16_t *boot_order = NULL;
UINTN boot_order_size;
/* There can be gaps in Boot#### entries. Instead of iterating over the full
- * EFI var list or UINT16 namespace, just look for "Windows Boot Manager" in BootOrder. */
+ * EFI var list or uint16_t namespace, just look for "Windows Boot Manager" in BootOrder. */
err = efivar_get_raw(EFI_GLOBAL_GUID, L"BootOrder", (CHAR8 **) &boot_order, &boot_order_size);
- if (err != EFI_SUCCESS || boot_order_size % sizeof(UINT16) != 0)
+ if (err != EFI_SUCCESS || boot_order_size % sizeof(uint16_t) != 0)
return err;
- for (UINTN i = 0; i < boot_order_size / sizeof(UINT16); i++) {
+ for (UINTN i = 0; i < boot_order_size / sizeof(uint16_t); i++) {
_cleanup_freepool_ CHAR8 *buf = NULL;
CHAR16 name[sizeof(L"Boot0000")];
UINTN buf_size;
- SPrint(name, sizeof(name), L"Boot%04x", (UINT32) boot_order[i]);
+ SPrint(name, sizeof(name), L"Boot%04x", (uint32_t) boot_order[i]);
err = efivar_get_raw(EFI_GLOBAL_GUID, name, &buf, &buf_size);
if (err != EFI_SUCCESS)
continue;
/* Boot#### are EFI_LOAD_OPTION. But we really are only interested
* for the description, which is at this offset. */
- UINTN offset = sizeof(UINT32) + sizeof(UINT16);
+ UINTN offset = sizeof(uint32_t) + sizeof(uint16_t);
if (buf_size < offset + sizeof(CHAR16))
continue;
@@ -2009,7 +2009,7 @@ static void config_entry_add_windows(Config *config, EFI_HANDLE *device, EFI_FIL
/* Try to find a better title. */
err = file_read(root_dir, L"\\EFI\\Microsoft\\Boot\\BCD", 0, 100*1024, &bcd, &len);
if (err == EFI_SUCCESS)
- title = get_bcd_title((UINT8 *) bcd, len);
+ title = get_bcd_title((uint8_t *) bcd, len);
ConfigEntry *e = config_entry_add_loader_auto(config, device, root_dir, NULL,
L"auto-windows", 'w', title ?: L"Windows Boot Manager",
@@ -2233,7 +2233,7 @@ static EFI_STATUS initrd_prepare(
EFI_STATUS err;
UINTN size = 0;
- _cleanup_freepool_ UINT8 *initrd = NULL;
+ _cleanup_freepool_ uint8_t *initrd = NULL;
STRV_FOREACH(i, entry->initrd) {
_cleanup_freepool_ CHAR16 *o = options;
@@ -2345,7 +2345,7 @@ static EFI_STATUS image_start(
/* Try calling the kernel compat entry point if one exists. */
if (err == EFI_UNSUPPORTED && entry->type == LOADER_LINUX) {
- UINT32 kernel_entry_address;
+ uint32_t kernel_entry_address;
err = pe_alignment_info(loaded_image->ImageBase, &kernel_entry_address, NULL, NULL);
if (err != EFI_SUCCESS) {
@@ -2353,7 +2353,7 @@ static EFI_STATUS image_start(
return log_error_status_stall(err, L"Error finding kernel compat entry address: %r", err);
} else {
EFI_IMAGE_ENTRY_POINT kernel_entry =
- (EFI_IMAGE_ENTRY_POINT) ((UINT8 *) loaded_image->ImageBase + kernel_entry_address);
+ (EFI_IMAGE_ENTRY_POINT) ((uint8_t *) loaded_image->ImageBase + kernel_entry_address);
err = kernel_entry(image, ST);
graphics_mode(FALSE);
@@ -2427,9 +2427,9 @@ static void save_selected_entry(const Config *config, const ConfigEntry *entry)
static void export_variables(
EFI_LOADED_IMAGE *loaded_image,
const CHAR16 *loaded_image_path,
- UINT64 init_usec) {
+ uint64_t init_usec) {
- static const UINT64 loader_features =
+ static const uint64_t loader_features =
EFI_LOADER_FEATURE_CONFIG_TIMEOUT |
EFI_LOADER_FEATURE_CONFIG_TIMEOUT_ONE_SHOT |
EFI_LOADER_FEATURE_ENTRY_DEFAULT |
@@ -2527,7 +2527,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
_cleanup_(config_free) Config config = {};
CHAR16 *loaded_image_path;
EFI_STATUS err;
- UINT64 init_usec;
+ uint64_t init_usec;
BOOLEAN menu = FALSE;
InitializeLib(image, sys_table);
@@ -2574,7 +2574,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
if (config.force_menu || config.timeout_sec > 0)
menu = TRUE;
else {
- UINT64 key;
+ uint64_t key;
/* Block up to 100ms to give firmware time to get input working. */
err = console_key_read(&key, 100 * 1000);
diff --git a/src/boot/efi/console.c b/src/boot/efi/console.c
index f78cfbd7c7..f09f83f73b 100644
--- a/src/boot/efi/console.c
+++ b/src/boot/efi/console.c
@@ -37,7 +37,7 @@ static inline void event_closep(EFI_EVENT *event) {
* will replace ConInEx permanently if it ever reports a key press.
* Lastly, a timer event allows us to provide a input timeout without having to call into
* any input functions that can freeze on us or using a busy/stall loop. */
-EFI_STATUS console_key_read(UINT64 *key, UINT64 timeout_usec) {
+EFI_STATUS console_key_read(uint64_t *key, uint64_t timeout_usec) {
static EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *conInEx = NULL, *extraInEx = NULL;
static BOOLEAN checked = FALSE;
UINTN index;
@@ -79,7 +79,7 @@ EFI_STATUS console_key_read(UINT64 *key, UINT64 timeout_usec) {
/* Watchdog rearming loop in case the user never provides us with input or some
* broken firmware never returns from WaitForEvent. */
for (;;) {
- UINT64 watchdog_timeout_sec = 5 * 60,
+ uint64_t watchdog_timeout_sec = 5 * 60,
watchdog_ping_usec = watchdog_timeout_sec / 2 * 1000 * 1000;
/* SetTimer expects 100ns units for some reason. */
@@ -124,7 +124,7 @@ EFI_STATUS console_key_read(UINT64 *key, UINT64 timeout_usec) {
* The two may be out of sync on some firmware, giving us double input. */
if (conInEx) {
EFI_KEY_DATA keydata;
- UINT32 shift = 0;
+ uint32_t shift = 0;
err = conInEx->ReadKeyStrokeEx(conInEx, &keydata);
if (err != EFI_SUCCESS)
@@ -159,9 +159,9 @@ EFI_STATUS console_key_read(UINT64 *key, UINT64 timeout_usec) {
return EFI_NOT_READY;
}
-static EFI_STATUS change_mode(INT64 mode) {
+static EFI_STATUS change_mode(int64_t mode) {
EFI_STATUS err;
- INT32 old_mode;
+ int32_t old_mode;
/* SetMode expects a UINTN, so make sure these values are sane. */
mode = CLAMP(mode, CONSOLE_MODE_RANGE_MIN, CONSOLE_MODE_RANGE_MAX);
@@ -181,7 +181,7 @@ static EFI_STATUS change_mode(INT64 mode) {
return err;
}
-EFI_STATUS query_screen_resolution(UINT32 *ret_w, UINT32 *ret_h) {
+EFI_STATUS query_screen_resolution(uint32_t *ret_w, uint32_t *ret_h) {
EFI_STATUS err;
EFI_GRAPHICS_OUTPUT_PROTOCOL *go;
@@ -197,8 +197,8 @@ EFI_STATUS query_screen_resolution(UINT32 *ret_w, UINT32 *ret_h) {
return EFI_SUCCESS;
}
-static INT64 get_auto_mode(void) {
- UINT32 screen_width, screen_height;
+static int64_t get_auto_mode(void) {
+ uint32_t screen_width, screen_height;
if (query_screen_resolution(&screen_width, &screen_height) == EFI_SUCCESS) {
BOOLEAN keep = FALSE;
@@ -212,12 +212,12 @@ static INT64 get_auto_mode(void) {
* area to the text viewport area. If it's less than 10 times bigger,
* then assume the text is readable and keep the text mode. */
else {
- UINT64 text_area;
+ uint64_t text_area;
UINTN x_max, y_max;
- UINT64 screen_area = (UINT64)screen_width * (UINT64)screen_height;
+ uint64_t screen_area = (uint64_t)screen_width * (uint64_t)screen_height;
console_query_mode(&x_max, &y_max);
- text_area = SYSTEM_FONT_WIDTH * SYSTEM_FONT_HEIGHT * (UINT64)x_max * (UINT64)y_max;
+ text_area = SYSTEM_FONT_WIDTH * SYSTEM_FONT_HEIGHT * (uint64_t)x_max * (uint64_t)y_max;
if (text_area != 0 && screen_area/text_area < VIEWPORT_RATIO)
keep = TRUE;
@@ -244,7 +244,7 @@ static INT64 get_auto_mode(void) {
return CONSOLE_MODE_80_25;
}
-EFI_STATUS console_set_mode(INT64 mode) {
+EFI_STATUS console_set_mode(int64_t mode) {
switch (mode) {
case CONSOLE_MODE_KEEP:
/* If the firmware indicates the current mode is invalid, change it anyway. */
diff --git a/src/boot/efi/console.h b/src/boot/efi/console.h
index cada643077..ac8b2f8362 100644
--- a/src/boot/efi/console.h
+++ b/src/boot/efi/console.h
@@ -10,12 +10,12 @@ enum {
EFI_LOGO_PRESSED = EFI_RIGHT_LOGO_PRESSED|EFI_LEFT_LOGO_PRESSED,
};
-#define KEYPRESS(keys, scan, uni) ((((UINT64)keys) << 32) | (((UINT64)scan) << 16) | (uni))
+#define KEYPRESS(keys, scan, uni) ((((uint64_t)keys) << 32) | (((uint64_t)scan) << 16) | (uni))
#define KEYCHAR(k) ((CHAR16)(k))
#define CHAR_CTRL(c) ((c) - 'a' + 1)
enum {
- /* Console mode is a INT32 in EFI. We use INT64 to make room for our special values. */
+ /* Console mode is a int32_t in EFI. We use int64_t to make room for our special values. */
CONSOLE_MODE_RANGE_MIN = 0,
CONSOLE_MODE_RANGE_MAX = INT32_MAX, /* This is just the theoretical limit. */
CONSOLE_MODE_INVALID = -1, /* UEFI uses -1 if the device is not in a valid text mode. */
@@ -31,7 +31,7 @@ enum {
CONSOLE_MODE_FIRMWARE_MAX, /* 'max' in config. */
};
-EFI_STATUS console_key_read(UINT64 *key, UINT64 timeout_usec);
-EFI_STATUS console_set_mode(INT64 mode);
+EFI_STATUS console_key_read(uint64_t *key, uint64_t timeout_usec);
+EFI_STATUS console_set_mode(int64_t mode);
EFI_STATUS console_query_mode(UINTN *x_max, UINTN *y_max);
-EFI_STATUS query_screen_resolution(UINT32 *ret_width, UINT32 *ret_height);
+EFI_STATUS query_screen_resolution(uint32_t *ret_width, uint32_t *ret_height);
diff --git a/src/boot/efi/cpio.c b/src/boot/efi/cpio.c
index b3f674149e..6769d4e2e7 100644
--- a/src/boot/efi/cpio.c
+++ b/src/boot/efi/cpio.c
@@ -4,7 +4,7 @@
#include "measure.h"
#include "util.h"
-static CHAR8* write_cpio_word(CHAR8 *p, UINT32 v) {
+static CHAR8* write_cpio_word(CHAR8 *p, uint32_t v) {
static const char hex[] = "0123456789abcdef";
assert(p);
@@ -54,8 +54,8 @@ static EFI_STATUS pack_cpio_one(
const void *contents,
UINTN contents_size,
const CHAR8 *target_dir_prefix,
- UINT32 access_mode,
- UINT32 *inode_counter,
+ uint32_t access_mode,
+ uint32_t *inode_counter,
void **cpio_buffer,
UINTN *cpio_buffer_size) {
@@ -161,8 +161,8 @@ static EFI_STATUS pack_cpio_one(
static EFI_STATUS pack_cpio_dir(
const CHAR8 *path,
- UINT32 access_mode,
- UINT32 *inode_counter,
+ uint32_t access_mode,
+ uint32_t *inode_counter,
void **cpio_buffer,
UINTN *cpio_buffer_size) {
@@ -229,8 +229,8 @@ static EFI_STATUS pack_cpio_dir(
static EFI_STATUS pack_cpio_prefix(
const CHAR8 *path,
- UINT32 dir_mode,
- UINT32 *inode_counter,
+ uint32_t dir_mode,
+ uint32_t *inode_counter,
void **cpio_buffer,
UINTN *cpio_buffer_size) {
@@ -298,7 +298,7 @@ static EFI_STATUS pack_cpio_trailer(
assert_cc(sizeof(trailer) % 4 == 0);
*cpio_buffer = xrealloc(*cpio_buffer, *cpio_buffer_size, *cpio_buffer_size + sizeof(trailer));
- memcpy((UINT8*) *cpio_buffer + *cpio_buffer_size, trailer, sizeof(trailer));
+ memcpy((uint8_t*) *cpio_buffer + *cpio_buffer_size, trailer, sizeof(trailer));
*cpio_buffer_size += sizeof(trailer);
return EFI_SUCCESS;
@@ -309,9 +309,9 @@ EFI_STATUS pack_cpio(
const CHAR16 *dropin_dir,
const CHAR16 *match_suffix,
const CHAR8 *target_dir_prefix,
- UINT32 dir_mode,
- UINT32 access_mode,
- const UINT32 tpm_pcr[],
+ uint32_t dir_mode,
+ uint32_t access_mode,
+ const uint32_t tpm_pcr[],
UINTN n_tpm_pcr,
const CHAR16 *tpm_description,
void **ret_buffer,
@@ -323,7 +323,7 @@ EFI_STATUS pack_cpio(
_cleanup_freepool_ EFI_FILE_INFO *dirent = NULL;
_cleanup_(strv_freep) CHAR16 **items = NULL;
_cleanup_freepool_ void *buffer = NULL;
- UINT32 inode = 1; /* inode counter, so that each item gets a new inode */
+ uint32_t inode = 1; /* inode counter, so that each item gets a new inode */
EFI_STATUS err;
EFI_FILE_IO_INTERFACE *volume;
@@ -397,11 +397,11 @@ EFI_STATUS pack_cpio(
UINTN m;
/* We allocate 16 entries at a time, as a matter of optimization */
- if (n_items > (UINTN_MAX / sizeof(UINT16)) - 16) /* Overflow check, just in case */
+ if (n_items > (UINTN_MAX / sizeof(uint16_t)) - 16) /* Overflow check, just in case */
return log_oom();
m = n_items + 16;
- items = xrealloc(items, n_allocated * sizeof(UINT16*), m * sizeof(UINT16*));
+ items = xrealloc(items, n_allocated * sizeof(uint16_t *), m * sizeof(uint16_t *));
n_allocated = m;
}
diff --git a/src/boot/efi/cpio.h b/src/boot/efi/cpio.h
index 5f6698fd12..e1600a3d19 100644
--- a/src/boot/efi/cpio.h
+++ b/src/boot/efi/cpio.h
@@ -8,9 +8,9 @@ EFI_STATUS pack_cpio(
const CHAR16 *dropin_dir,
const CHAR16 *match_suffix,
const CHAR8 *target_dir_prefix,
- UINT32 dir_mode,
- UINT32 access_mode,
- const UINT32 tpm_pcr[],
+ uint32_t dir_mode,
+ uint32_t access_mode,
+ const uint32_t tpm_pcr[],
UINTN n_tpm_pcr,
const CHAR16 *tpm_description,
void **ret_buffer,
diff --git a/src/boot/efi/linux.c b/src/boot/efi/linux.c
index b35c782db2..a9e1b57855 100644
--- a/src/boot/efi/linux.c
+++ b/src/boot/efi/linux.c
@@ -112,7 +112,7 @@ EFI_STATUS linux_exec(
_cleanup_(cleanup_initrd) EFI_HANDLE initrd_handle = NULL;
_cleanup_(cleanup_loaded_image) EFI_HANDLE loaded_image_handle = NULL;
- UINT32 kernel_alignment, kernel_size_of_image, kernel_entry_address;
+ uint32_t kernel_alignment, kernel_size_of_image, kernel_entry_address;
EFI_IMAGE_ENTRY_POINT kernel_entry;
_cleanup_(cleanup_pages) struct pages kernel = {};
void *new_buffer;
@@ -147,10 +147,10 @@ EFI_STATUS linux_exec(
new_buffer = PHYSICAL_ADDRESS_TO_POINTER(ALIGN_TO(kernel.addr, kernel_alignment));
memcpy(new_buffer, linux_buffer, linux_length);
/* zero out rest of memory (probably not needed, but BSS section should be 0) */
- memset((UINT8 *)new_buffer + linux_length, 0, kernel_size_of_image - linux_length);
+ memset((uint8_t *)new_buffer + linux_length, 0, kernel_size_of_image - linux_length);
/* get the entry point inside the relocated kernel */
- kernel_entry = (EFI_IMAGE_ENTRY_POINT) ((const UINT8 *)new_buffer + kernel_entry_address);
+ kernel_entry = (EFI_IMAGE_ENTRY_POINT) ((const uint8_t *)new_buffer + kernel_entry_address);
/* register a LoadedImage Protocol in order to pass on the commandline */
err = loaded_image_register(cmdline, cmdline_len, new_buffer, linux_length, &loaded_image_handle);
diff --git a/src/boot/efi/linux_x86.c b/src/boot/efi/linux_x86.c
index 1032b762e5..78a4872e39 100644
--- a/src/boot/efi/linux_x86.c
+++ b/src/boot/efi/linux_x86.c
@@ -21,81 +21,81 @@
#define SETUP_MAGIC 0x53726448 /* "HdrS" */
struct setup_header {
- UINT8 setup_sects;
- UINT16 root_flags;
- UINT32 syssize;
- UINT16 ram_size;
- UINT16 vid_mode;
- UINT16 root_dev;
- UINT16 boot_flag;
- UINT16 jump;
- UINT32 header;
- UINT16 version;
- UINT32 realmode_swtch;
- UINT16 start_sys_seg;
- UINT16 kernel_version;
- UINT8 type_of_loader;
- UINT8 loadflags;
- UINT16 setup_move_size;
- UINT32 code32_start;
- UINT32 ramdisk_image;
- UINT32 ramdisk_size;
- UINT32 bootsect_kludge;
- UINT16 heap_end_ptr;
- UINT8 ext_loader_ver;
- UINT8 ext_loader_type;
- UINT32 cmd_line_ptr;
- UINT32 initrd_addr_max;
- UINT32 kernel_alignment;
- UINT8 relocatable_kernel;
- UINT8 min_alignment;
- UINT16 xloadflags;
- UINT32 cmdline_size;
- UINT32 hardware_subarch;
- UINT64 hardware_subarch_data;
- UINT32 payload_offset;
- UINT32 payload_length;
- UINT64 setup_data;
- UINT64 pref_address;
- UINT32 init_size;
- UINT32 handover_offset;
+ uint8_t setup_sects;
+ uint16_t root_flags;
+ uint32_t syssize;
+ uint16_t ram_size;
+ uint16_t vid_mode;
+ uint16_t root_dev;
+ uint16_t boot_flag;
+ uint16_t jump;
+ uint32_t header;
+ uint16_t version;
+ uint32_t realmode_swtch;
+ uint16_t start_sys_seg;
+ uint16_t kernel_version;
+ uint8_t type_of_loader;
+ uint8_t loadflags;
+ uint16_t setup_move_size;
+ uint32_t code32_start;
+ uint32_t ramdisk_image;
+ uint32_t ramdisk_size;
+ uint32_t bootsect_kludge;
+ uint16_t heap_end_ptr;
+ uint8_t ext_loader_ver;
+ uint8_t ext_loader_type;
+ uint32_t cmd_line_ptr;
+ uint32_t initrd_addr_max;
+ uint32_t kernel_alignment;
+ uint8_t relocatable_kernel;
+ uint8_t min_alignment;
+ uint16_t xloadflags;
+ uint32_t cmdline_size;
+ uint32_t hardware_subarch;
+ uint64_t hardware_subarch_data;
+ uint32_t payload_offset;
+ uint32_t payload_length;
+ uint64_t setup_data;
+ uint64_t pref_address;
+ uint32_t init_size;
+ uint32_t handover_offset;
} _packed_;
/* adapted from linux' bootparam.h */
struct boot_params {
- UINT8 screen_info[64]; // was: struct screen_info
- UINT8 apm_bios_info[20]; // was: struct apm_bios_info
- UINT8 _pad2[4];
- UINT64 tboot_addr;
- UINT8 ist_info[16]; // was: struct ist_info
- UINT8 _pad3[16];
- UINT8 hd0_info[16];
- UINT8 hd1_info[16];
- UINT8 sys_desc_table[16]; // was: struct sys_desc_table
- UINT8 olpc_ofw_header[16]; // was: struct olpc_ofw_header
- UINT32 ext_ramdisk_image;
- UINT32 ext_ramdisk_size;
- UINT32 ext_cmd_line_ptr;
- UINT8 _pad4[116];
- UINT8 edid_info[128]; // was: struct edid_info
- UINT8 efi_info[32]; // was: struct efi_info
- UINT32 alt_mem_k;
- UINT32 scratch;
- UINT8 e820_entries;
- UINT8 eddbuf_entries;
- UINT8 edd_mbr_sig_buf_entries;
- UINT8 kbd_status;
- UINT8 secure_boot;
- UINT8 _pad5[2];
- UINT8 sentinel;
- UINT8 _pad6[1];
+ uint8_t screen_info[64]; // was: struct screen_info
+ uint8_t apm_bios_info[20]; // was: struct apm_bios_info
+ uint8_t _pad2[4];
+ uint64_t tboot_addr;
+ uint8_t ist_info[16]; // was: struct ist_info
+ uint8_t _pad3[16];
+ uint8_t hd0_info[16];
+ uint8_t hd1_info[16];
+ uint8_t sys_desc_table[16]; // was: struct sys_desc_table
+ uint8_t olpc_ofw_header[16]; // was: struct olpc_ofw_header
+ uint32_t ext_ramdisk_image;
+ uint32_t ext_ramdisk_size;
+ uint32_t ext_cmd_line_ptr;
+ uint8_t _pad4[116];
+ uint8_t edid_info[128]; // was: struct edid_info
+ uint8_t efi_info[32]; // was: struct efi_info
+ uint32_t alt_mem_k;
+ uint32_t scratch;
+ uint8_t e820_entries;
+ uint8_t eddbuf_entries;
+ uint8_t edd_mbr_sig_buf_entries;
+ uint8_t kbd_status;
+ uint8_t secure_boot;
+ uint8_t _pad5[2];
+ uint8_t sentinel;
+ uint8_t _pad6[1];
struct setup_header hdr;
- UINT8 _pad7[0x290-0x1f1-sizeof(struct setup_header)];
- UINT32 edd_mbr_sig_buffer[16]; // was: edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]
- UINT8 e820_table[20*128]; // was: struct boot_e820_entry e820_table[E820_MAX_ENTRIES_ZEROPAGE]
- UINT8 _pad8[48];
- UINT8 eddbuf[6*82]; // was: struct edd_info eddbuf[EDDMAXNR]
- UINT8 _pad9[276];
+ uint8_t _pad7[0x290-0x1f1-sizeof(struct setup_header)];
+ uint32_t edd_mbr_sig_buffer[16]; // was: edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]
+ uint8_t e820_table[20*128]; // was: struct boot_e820_entry e820_table[E820_MAX_ENTRIES_ZEROPAGE]
+ uint8_t _pad8[48];
+ uint8_t eddbuf[6*82]; // was: struct edd_info eddbuf[EDDMAXNR]
+ uint8_t _pad9[276];
} _packed_;
#ifdef __i386__
@@ -130,7 +130,7 @@ EFI_STATUS linux_exec(
struct boot_params *boot_params;
EFI_HANDLE initrd_handle = NULL;
EFI_PHYSICAL_ADDRESS addr;
- UINT8 setup_sectors;
+ uint8_t setup_sectors;
EFI_STATUS err;
assert(image);
@@ -163,7 +163,7 @@ EFI_STATUS linux_exec(
boot_params->hdr = image_params->hdr;
boot_params->hdr.type_of_loader = 0xff;
setup_sectors = image_params->hdr.setup_sects > 0 ? image_params->hdr.setup_sects : 4;
- boot_params->hdr.code32_start = (UINT32) POINTER_TO_PHYSICAL_ADDRESS(linux_buffer) + (setup_sectors + 1) * 512;
+ boot_params->hdr.code32_start = (uint32_t) POINTER_TO_PHYSICAL_ADDRESS(linux_buffer) + (setup_sectors + 1) * 512;
if (cmdline) {
addr = 0xA0000;
@@ -178,7 +178,7 @@ EFI_STATUS linux_exec(
memcpy(PHYSICAL_ADDRESS_TO_POINTER(addr), cmdline, cmdline_len);
((CHAR8 *) PHYSICAL_ADDRESS_TO_POINTER(addr))[cmdline_len] = 0;
- boot_params->hdr.cmd_line_ptr = (UINT32) addr;
+ boot_params->hdr.cmd_line_ptr = (uint32_t) addr;
}
/* Providing the initrd via LINUX_INITRD_MEDIA_GUID is only supported by Linux 5.8+ (5.7+ on ARM64).
@@ -187,8 +187,8 @@ EFI_STATUS linux_exec(
If you need to know which protocol was used by the kernel, pass "efi=debug" to the kernel,
this will print a line when InitrdMediaGuid was successfully used to load the initrd.
*/
- boot_params->hdr.ramdisk_image = (UINT32) POINTER_TO_PHYSICAL_ADDRESS(initrd_buffer);
- boot_params->hdr.ramdisk_size = (UINT32) initrd_length;
+ boot_params->hdr.ramdisk_image = (uint32_t) POINTER_TO_PHYSICAL_ADDRESS(initrd_buffer);
+ boot_params->hdr.ramdisk_size = (uint32_t) initrd_length;
/* register LINUX_INITRD_MEDIA_GUID */
err = initrd_register(initrd_buffer, initrd_length, &initrd_handle);
diff --git a/src/boot/efi/measure.c b/src/boot/efi/measure.c
index 2b9ad75aed..3ca1a835e7 100644
--- a/src/boot/efi/measure.c
+++ b/src/boot/efi/measure.c
@@ -12,14 +12,14 @@
static EFI_STATUS tpm1_measure_to_pcr_and_event_log(
const EFI_TCG *tcg,
- UINT32 pcrindex,
+ uint32_t pcrindex,
EFI_PHYSICAL_ADDRESS buffer,
UINTN buffer_size,
const CHAR16 *description) {
_cleanup_freepool_ TCG_PCR_EVENT *tcg_event = NULL;
EFI_PHYSICAL_ADDRESS event_log_last;
- UINT32 event_number = 1;
+ uint32_t event_number = 1;
UINTN desc_len;
assert(tcg);
@@ -46,9 +46,9 @@ static EFI_STATUS tpm1_measure_to_pcr_and_event_log(
static EFI_STATUS tpm2_measure_to_pcr_and_event_log(
EFI_TCG2 *tcg,
- UINT32 pcrindex,
+ uint32_t pcrindex,
EFI_PHYSICAL_ADDRESS buffer,
- UINT64 buffer_size,
+ uint64_t buffer_size,
const CHAR16 *description) {
_cleanup_freepool_ EFI_TCG2_EVENT *tcg_event = NULL;
@@ -83,7 +83,7 @@ static EFI_TCG *tcg1_interface_check(void) {
.Size = sizeof(capability),
};
EFI_STATUS err;
- UINT32 features;
+ uint32_t features;
EFI_TCG *tcg;
err = BS->LocateProtocol((EFI_GUID *) EFI_TCG_GUID, NULL, (void **) &tcg);
@@ -141,7 +141,7 @@ BOOLEAN tpm_present(void) {
return tcg2_interface_check() || tcg1_interface_check();
}
-EFI_STATUS tpm_log_event(UINT32 pcrindex, EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const CHAR16 *description) {
+EFI_STATUS tpm_log_event(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const CHAR16 *description) {
EFI_TCG *tpm1;
EFI_TCG2 *tpm2;
@@ -169,7 +169,7 @@ EFI_STATUS tpm_log_load_options(const CHAR16 *load_options) {
/* Measures a load options string into the TPM2, i.e. the kernel command line */
for (UINTN i = 0; i < 2; i++) {
- UINT32 pcr = i == 0 ? TPM_PCR_INDEX_KERNEL_PARAMETERS : TPM_PCR_INDEX_KERNEL_PARAMETERS_COMPAT;
+ uint32_t pcr = i == 0 ? TPM_PCR_INDEX_KERNEL_PARAMETERS : TPM_PCR_INDEX_KERNEL_PARAMETERS_COMPAT;
err = tpm_log_event(pcr,
POINTER_TO_PHYSICAL_ADDRESS(load_options),
diff --git a/src/boot/efi/measure.h b/src/boot/efi/measure.h
index e951ff7ef0..060b8eded7 100644
--- a/src/boot/efi/measure.h
+++ b/src/boot/efi/measure.h
@@ -20,7 +20,7 @@
#if ENABLE_TPM
BOOLEAN tpm_present(void);
-EFI_STATUS tpm_log_event(UINT32 pcrindex, EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const CHAR16 *description);
+EFI_STATUS tpm_log_event(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const CHAR16 *description);
EFI_STATUS tpm_log_load_options(const CHAR16 *cmdline);
#else
@@ -29,7 +29,7 @@ static inline BOOLEAN tpm_present(void) {
return FALSE;
}
-static inline EFI_STATUS tpm_log_event(UINT32 pcrindex, EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const CHAR16 *description) {
+static inline EFI_STATUS tpm_log_event(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const CHAR16 *description) {
return EFI_SUCCESS;
}
diff --git a/src/boot/efi/pe.c b/src/boot/efi/pe.c
index 0b48663359..754176c84b 100644
--- a/src/boot/efi/pe.c
+++ b/src/boot/efi/pe.c
@@ -31,90 +31,90 @@
#endif
struct DosFileHeader {
- UINT8 Magic[2];
- UINT16 LastSize;
- UINT16 nBlocks;
- UINT16 nReloc;
- UINT16 HdrSize;
- UINT16 MinAlloc;
- UINT16 MaxAlloc;
- UINT16 ss;
- UINT16 sp;
- UINT16 Checksum;
- UINT16 ip;
- UINT16 cs;
- UINT16 RelocPos;
- UINT16 nOverlay;
- UINT16 reserved[4];
- UINT16 OEMId;
- UINT16 OEMInfo;
- UINT16 reserved2[10];
- UINT32 ExeHeader;
+ uint8_t Magic[2];
+ uint16_t LastSize;
+ uint16_t nBlocks;
+ uint16_t nReloc;
+ uint16_t HdrSize;
+ uint16_t MinAlloc;
+ uint16_t MaxAlloc;
+ uint16_t ss;
+ uint16_t sp;
+ uint16_t Checksum;
+ uint16_t ip;
+ uint16_t cs;
+ uint16_t RelocPos;
+ uint16_t nOverlay;
+ uint16_t reserved[4];
+ uint16_t OEMId;
+ uint16_t OEMInfo;
+ uint16_t reserved2[10];
+ uint32_t ExeHeader;
} _packed_;
struct CoffFileHeader {
- UINT16 Machine;
- UINT16 NumberOfSections;
- UINT32 TimeDateStamp;
- UINT32 PointerToSymbolTable;
- UINT32 NumberOfSymbols;
- UINT16 SizeOfOptionalHeader;
- UINT16 Characteristics;
+ uint16_t Machine;
+ uint16_t NumberOfSections;
+ uint32_t TimeDateStamp;
+ uint32_t PointerToSymbolTable;
+ uint32_t NumberOfSymbols;
+ uint16_t SizeOfOptionalHeader;
+ uint16_t Characteristics;
} _packed_;
#define OPTHDR32_MAGIC 0x10B /* PE32 OptionalHeader */
#define OPTHDR64_MAGIC 0x20B /* PE32+ OptionalHeader */
struct PeOptionalHeader {
- UINT16 Magic;
- UINT8 LinkerMajor;
- UINT8 LinkerMinor;
- UINT32 SizeOfCode;
- UINT32 SizeOfInitializedData;
- UINT32 SizeOfUninitializeData;
- UINT32 AddressOfEntryPoint;
- UINT32 BaseOfCode;
+ uint16_t Magic;
+ uint8_t LinkerMajor;
+ uint8_t LinkerMinor;
+ uint32_t SizeOfCode;
+ uint32_t SizeOfInitializedData;
+ uint32_t SizeOfUninitializeData;
+ uint32_t AddressOfEntryPoint;
+ uint32_t BaseOfCode;
union {
struct { /* PE32 */
- UINT32 BaseOfData;
- UINT32 ImageBase32;
+ uint32_t BaseOfData;
+ uint32_t ImageBase32;
};
- UINT64 ImageBase64; /* PE32+ */
+ uint64_t ImageBase64; /* PE32+ */
};
- UINT32 SectionAlignment;
- UINT32 FileAlignment;
- UINT16 MajorOperatingSystemVersion;
- UINT16 MinorOperatingSystemVersion;
- UINT16 MajorImageVersion;
- UINT16 MinorImageVersion;
- UINT16 MajorSubsystemVersion;
- UINT16 MinorSubsystemVersion;
- UINT32 Win32VersionValue;
- UINT32 SizeOfImage;
- UINT32 SizeOfHeaders;
- UINT32 CheckSum;
- UINT16 Subsystem;
- UINT16 DllCharacteristics;
+ uint32_t SectionAlignment;
+ uint32_t FileAlignment;
+ uint16_t MajorOperatingSystemVersion;
+ uint16_t MinorOperatingSystemVersion;
+ uint16_t MajorImageVersion;
+ uint16_t MinorImageVersion;
+ uint16_t MajorSubsystemVersion;
+ uint16_t MinorSubsystemVersion;
+ uint32_t Win32VersionValue;
+ uint32_t SizeOfImage;
+ uint32_t SizeOfHeaders;
+ uint32_t CheckSum;
+ uint16_t Subsystem;
+ uint16_t DllCharacteristics;
/* fields with different sizes for 32/64 omitted */
} _packed_;
struct PeFileHeader {
- UINT8 Magic[4];
+ uint8_t Magic[4];
struct CoffFileHeader FileHeader;
struct PeOptionalHeader OptionalHeader;
} _packed_;
struct PeSectionHeader {
- UINT8 Name[8];
- UINT32 VirtualSize;
- UINT32 VirtualAddress;
- UINT32 SizeOfRawData;
- UINT32 PointerToRawData;
- UINT32 PointerToRelocations;
- UINT32 PointerToLinenumbers;
- UINT16 NumberOfRelocations;
- UINT16 NumberOfLinenumbers;
- UINT32 Characteristics;
+ uint8_t Name[8];
+ uint32_t VirtualSize;
+ uint32_t VirtualAddress;
+ uint32_t SizeOfRawData;
+ uint32_t PointerToRawData;
+ uint32_t PointerToRelocations;
+ uint32_t PointerToLinenumbers;
+ uint16_t NumberOfRelocations;
+ uint16_t NumberOfLinenumbers;
+ uint32_t Characteristics;
} _packed_;
static inline BOOLEAN verify_dos(const struct DosFileHeader *dos) {
@@ -166,7 +166,7 @@ static void locate_sections(
}
}
-static UINT32 get_compatibility_entry_address(const struct DosFileHeader *dos, const struct PeFileHeader *pe) {
+static uint32_t get_compatibility_entry_address(const struct DosFileHeader *dos, const struct PeFileHeader *pe) {
UINTN addr = 0, size = 0;
static const CHAR8 *sections[] = { (CHAR8 *) ".compat", NULL };
@@ -174,7 +174,7 @@ static UINT32 get_compatibility_entry_address(const struct DosFileHeader *dos, c
* booting a 64bit kernel on 32bit EFI that is otherwise running on a 64bit CPU. The locations of any
* such compat entry points are located in a special PE section. */
- locate_sections((const struct PeSectionHeader *) ((const UINT8 *) dos + section_table_offset(dos, pe)),
+ locate_sections((const struct PeSectionHeader *) ((const uint8_t *) dos + section_table_offset(dos, pe)),
pe->FileHeader.NumberOfSections,
sections,
&addr,
@@ -185,14 +185,14 @@ static UINT32 get_compatibility_entry_address(const struct DosFileHeader *dos, c
return 0;
typedef struct {
- UINT8 type;
- UINT8 size;
- UINT16 machine_type;
- UINT32 entry_point;
+ uint8_t type;
+ uint8_t size;
+ uint16_t machine_type;
+ uint32_t entry_point;
} _packed_ LinuxPeCompat1;
while (size >= sizeof(LinuxPeCompat1) && addr % __alignof__(LinuxPeCompat1) == 0) {
- LinuxPeCompat1 *compat = (LinuxPeCompat1 *) ((UINT8 *) dos + addr);
+ LinuxPeCompat1 *compat = (LinuxPeCompat1 *) ((uint8_t *) dos + addr);
if (compat->type == 0 || compat->size == 0 || compat->size > size)
break;
@@ -211,9 +211,9 @@ static UINT32 get_compatibility_entry_address(const struct DosFileHeader *dos, c
EFI_STATUS pe_alignment_info(
const void *base,
- UINT32 *ret_entry_point_address,
- UINT32 *ret_size_of_image,
- UINT32 *ret_section_alignment) {
+ uint32_t *ret_entry_point_address,
+ uint32_t *ret_size_of_image,
+ uint32_t *ret_section_alignment) {
const struct DosFileHeader *dos;
const struct PeFileHeader *pe;
@@ -225,11 +225,11 @@ EFI_STATUS pe_alignment_info(
if (!verify_dos(dos))
return EFI_LOAD_ERROR;
- pe = (const struct PeFileHeader*) ((const UINT8 *)base + dos->ExeHeader);
+ pe = (const struct PeFileHeader*) ((const uint8_t *)base + dos->ExeHeader);
if (!verify_pe(pe, /* allow_compatibility= */ TRUE))
return EFI_LOAD_ERROR;
- UINT32 entry_address = pe->OptionalHeader.AddressOfEntryPoint;
+ uint32_t entry_address = pe->OptionalHeader.AddressOfEntryPoint;
/* Look for a compat entry point. */
if (pe->FileHeader.Machine != TARGET_MACHINE_TYPE) {
diff --git a/src/boot/efi/pe.h b/src/boot/efi/pe.h
index 3faa5f8730..54bc2428ff 100644
--- a/src/boot/efi/pe.h
+++ b/src/boot/efi/pe.h
@@ -18,6 +18,6 @@ EFI_STATUS pe_file_locate_sections(
EFI_STATUS pe_alignment_info(
const void *base,
- UINT32 *ret_entry_point_address,
- UINT32 *ret_size_of_image,
- UINT32 *ret_section_alignment);
+ uint32_t *ret_entry_point_address,
+ uint32_t *ret_size_of_image,
+ uint32_t *ret_section_alignment);
diff --git a/src/boot/efi/random-seed.c b/src/boot/efi/random-seed.c
index a1053f9a58..c4c9fa45a7 100644
--- a/src/boot/efi/random-seed.c
+++ b/src/boot/efi/random-seed.c
@@ -48,9 +48,9 @@ static void hash_once(
UINTN size,
const void *system_token,
UINTN system_token_size,
- UINT64 uefi_monotonic_counter,
+ uint64_t uefi_monotonic_counter,
UINTN counter,
- UINT8 ret[static HASH_VALUE_SIZE]) {
+ uint8_t ret[static HASH_VALUE_SIZE]) {
/* This hashes together:
*
@@ -85,7 +85,7 @@ static EFI_STATUS hash_many(
UINTN size,
const void *system_token,
UINTN system_token_size,
- UINT64 uefi_monotonic_counter,
+ uint64_t uefi_monotonic_counter,
UINTN counter_start,
UINTN n,
void **ret) {
@@ -106,7 +106,7 @@ static EFI_STATUS hash_many(
system_token, system_token_size,
uefi_monotonic_counter,
counter_start + i,
- (UINT8*) output + (i * HASH_VALUE_SIZE));
+ (uint8_t*) output + (i * HASH_VALUE_SIZE));
*ret = TAKE_PTR(output);
return EFI_SUCCESS;
@@ -118,7 +118,7 @@ static EFI_STATUS mangle_random_seed(
UINTN size,
const void *system_token,
UINTN system_token_size,
- UINT64 uefi_monotonic_counter,
+ uint64_t uefi_monotonic_counter,
void **ret_new_seed,
void **ret_for_kernel) {
@@ -234,7 +234,7 @@ EFI_STATUS process_random_seed(EFI_FILE *root_dir, RandomSeedMode mode) {
_cleanup_(file_closep) EFI_FILE *handle = NULL;
UINTN size, rsize, wsize, system_token_size = 0;
_cleanup_freepool_ EFI_FILE_INFO *info = NULL;
- UINT64 uefi_monotonic_counter = 0;
+ uint64_t uefi_monotonic_counter = 0;
EFI_STATUS err;
assert(root_dir);
diff --git a/src/boot/efi/shim.c b/src/boot/efi/shim.c
index 0df705a331..3d5690f670 100644
--- a/src/boot/efi/shim.c
+++ b/src/boot/efi/shim.c
@@ -22,13 +22,13 @@
#endif
struct ShimLock {
- EFI_STATUS __sysv_abi__ (*shim_verify) (void *buffer, UINT32 size);
+ EFI_STATUS __sysv_abi__ (*shim_verify) (void *buffer, uint32_t size);
/* context is actually a struct for the PE header, but it isn't needed so void is sufficient just do define the interface
* see shim.c/shim.h and PeHeader.h in the github shim repo */
- EFI_STATUS __sysv_abi__ (*generate_hash) (void *data, UINT32 datasize, void *context, UINT8 *sha256hash, UINT8 *sha1hash);
+ EFI_STATUS __sysv_abi__ (*generate_hash) (void *data, uint32_t datasize, void *context, uint8_t *sha256hash, uint8_t *sha1hash);
- EFI_STATUS __sysv_abi__ (*read_header) (void *data, UINT32 datasize, void *context);
+ EFI_STATUS __sysv_abi__ (*read_header) (void *data, uint32_t datasize, void *context);
};
#define SHIM_LOCK_GUID \
@@ -40,7 +40,7 @@ BOOLEAN shim_loaded(void) {
return BS->LocateProtocol((EFI_GUID*) SHIM_LOCK_GUID, NULL, (void**) &shim_lock) == EFI_SUCCESS;
}
-static BOOLEAN shim_validate(void *data, UINT32 size) {
+static BOOLEAN shim_validate(void *data, uint32_t size) {
struct ShimLock *shim_lock;
if (!data)
@@ -99,7 +99,7 @@ static EFIAPI EFI_STATUS security2_policy_authentication (const EFI_SECURITY2_PR
* authentication failure, be it EFI_ACCESS_DENIED, EFI_SECURITY_VIOLATION, or something
* else. (This seems to vary between implementations.)
*/
-static EFIAPI EFI_STATUS security_policy_authentication (const EFI_SECURITY_PROTOCOL *this, UINT32 authentication_status,
+static EFIAPI EFI_STATUS security_policy_authentication (const EFI_SECURITY_PROTOCOL *this, uint32_t authentication_status,
const EFI_DEVICE_PATH_PROTOCOL *device_path_const) {
EFI_STATUS err;
_cleanup_freepool_ CHAR16 *dev_path_str = NULL;
diff --git a/src/boot/efi/splash.c b/src/boot/efi/splash.c
index e2e105b776..9163d52698 100644
--- a/src/boot/efi/splash.c
+++ b/src/boot/efi/splash.c
@@ -9,40 +9,40 @@
struct bmp_file {
CHAR8 signature[2];
- UINT32 size;
- UINT16 reserved[2];
- UINT32 offset;
+ uint32_t size;
+ uint16_t reserved[2];
+ uint32_t offset;
} _packed_;
/* we require at least BITMAPINFOHEADER, later versions are
accepted, but their features ignored */
struct bmp_dib {
- UINT32 size;
- UINT32 x;
- UINT32 y;
- UINT16 planes;
- UINT16 depth;
- UINT32 compression;
- UINT32 image_size;
- INT32 x_pixel_meter;
- INT32 y_pixel_meter;
- UINT32 colors_used;
- UINT32 colors_important;
+ uint32_t size;
+ uint32_t x;
+ uint32_t y;
+ uint16_t planes;
+ uint16_t depth;
+ uint32_t compression;
+ uint32_t image_size;
+ int32_t x_pixel_meter;
+ int32_t y_pixel_meter;
+ uint32_t colors_used;
+ uint32_t colors_important;
} _packed_;
struct bmp_map {
- UINT8 blue;
- UINT8 green;
- UINT8 red;
- UINT8 reserved;
+ uint8_t blue;
+ uint8_t green;
+ uint8_t red;
+ uint8_t reserved;
} _packed_;
static EFI_STATUS bmp_parse_header(
- const UINT8 *bmp,
+ const uint8_t *bmp,
UINTN size,
struct bmp_dib **ret_dib,
struct bmp_map **ret_map,
- const UINT8 **pixmap) {
+ const uint8_t **pixmap) {
struct bmp_file *file;
struct bmp_dib *dib;
@@ -104,7 +104,7 @@ static EFI_STATUS bmp_parse_header(
return EFI_INVALID_PARAMETER;
if (file->offset > sizeof(struct bmp_file) + dib->size) {
- UINT32 map_count;
+ uint32_t map_count;
UINTN map_size;
if (dib->colors_used)
@@ -135,8 +135,8 @@ static EFI_STATUS bmp_parse_header(
return EFI_SUCCESS;
}
-static void pixel_blend(UINT32 *dst, const UINT32 source) {
- UINT32 alpha, src, src_rb, src_g, dst_rb, dst_g, rb, g;
+static void pixel_blend(uint32_t *dst, const uint32_t source) {
+ uint32_t alpha, src, src_rb, src_g, dst_rb, dst_g, rb, g;
assert(dst);
@@ -163,9 +163,9 @@ static EFI_STATUS bmp_to_blt(
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *buf,
struct bmp_dib *dib,
struct bmp_map *map,
- const UINT8 *pixmap) {
+ const uint8_t *pixmap) {
- const UINT8 *in;
+ const uint8_t *in;
assert(buf);
assert(dib);
@@ -219,7 +219,7 @@ static EFI_STATUS bmp_to_blt(
break;
case 16: {
- UINT16 i = *(UINT16 *) in;
+ uint16_t i = *(uint16_t *) in;
out->Red = (i & 0x7c00) >> 7;
out->Green = (i & 0x3e0) >> 2;
@@ -236,9 +236,9 @@ static EFI_STATUS bmp_to_blt(
break;
case 32: {
- UINT32 i = *(UINT32 *) in;
+ uint32_t i = *(uint32_t *) in;
- pixel_blend((UINT32 *)out, i);
+ pixel_blend((uint32_t *)out, i);
in += 3;
break;
@@ -254,12 +254,12 @@ static EFI_STATUS bmp_to_blt(
return EFI_SUCCESS;
}
-EFI_STATUS graphics_splash(const UINT8 *content, UINTN len, const EFI_GRAPHICS_OUTPUT_BLT_PIXEL *background) {
+EFI_STATUS graphics_splash(const uint8_t *content, UINTN len, const EFI_GRAPHICS_OUTPUT_BLT_PIXEL *background) {
EFI_GRAPHICS_OUTPUT_BLT_PIXEL pixel = {};
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput = NULL;
struct bmp_dib *dib;
struct bmp_map *map;
- const UINT8 *pixmap;
+ const uint8_t *pixmap;
_cleanup_freepool_ void *blt = NULL;
UINTN x_pos = 0;
UINTN y_pos = 0;
diff --git a/src/boot/efi/splash.h b/src/boot/efi/splash.h
index 37ccc6b6a4..ec36451ff0 100644
--- a/src/boot/efi/splash.h
+++ b/src/boot/efi/splash.h
@@ -3,4 +3,4 @@
#include <efi.h>
-EFI_STATUS graphics_splash(const UINT8 *content, UINTN len, const EFI_GRAPHICS_OUTPUT_BLT_PIXEL *background);
+EFI_STATUS graphics_splash(const uint8_t *content, UINTN len, const EFI_GRAPHICS_OUTPUT_BLT_PIXEL *background);
diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c
index c7ceec3a42..29ccfa3b4f 100644
--- a/src/boot/efi/stub.c
+++ b/src/boot/efi/stub.c
@@ -26,7 +26,7 @@ static EFI_STATUS combine_initrd(
EFI_PHYSICAL_ADDRESS base = UINT32_MAX; /* allocate an area below the 32bit boundary for this */
EFI_STATUS err;
- UINT8 *p;
+ uint8_t *p;
UINTN n;
assert(ret_initrd_base);
@@ -93,7 +93,7 @@ static EFI_STATUS combine_initrd(
p += sysext_initrd_size;
}
- assert((UINT8*) PHYSICAL_ADDRESS_TO_POINTER(base) + n == p);
+ assert((uint8_t*) PHYSICAL_ADDRESS_TO_POINTER(base) + n == p);
*ret_initrd_base = base;
*ret_initrd_size = n;
@@ -203,7 +203,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
}
/* Show splash screen as early as possible */
- graphics_splash((const UINT8*) loaded_image->ImageBase + addrs[SECTION_SPLASH], szs[SECTION_SPLASH], NULL);
+ graphics_splash((const uint8_t*) loaded_image->ImageBase + addrs[SECTION_SPLASH], szs[SECTION_SPLASH], NULL);
if (szs[SECTION_CMDLINE] > 0) {
cmdline = (CHAR8*) loaded_image->ImageBase + addrs[SECTION_CMDLINE];
@@ -234,7 +234,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
(const CHAR8*) ".extra/credentials",
/* dir_mode= */ 0500,
/* access_mode= */ 0400,
- /* tpm_pcr= */ (UINT32[]) { TPM_PCR_INDEX_KERNEL_PARAMETERS, TPM_PCR_INDEX_KERNEL_PARAMETERS_COMPAT },
+ /* tpm_pcr= */ (uint32_t[]) { TPM_PCR_INDEX_KERNEL_PARAMETERS, TPM_PCR_INDEX_KERNEL_PARAMETERS_COMPAT },
/* n_tpm_pcr= */ 2,
L"Credentials initrd",
&credential_initrd,
@@ -246,7 +246,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
(const CHAR8*) ".extra/global_credentials",
/* dir_mode= */ 0500,
/* access_mode= */ 0400,
- /* tpm_pcr= */ (UINT32[]) { TPM_PCR_INDEX_KERNEL_PARAMETERS, TPM_PCR_INDEX_KERNEL_PARAMETERS_COMPAT },
+ /* tpm_pcr= */ (uint32_t[]) { TPM_PCR_INDEX_KERNEL_PARAMETERS, TPM_PCR_INDEX_KERNEL_PARAMETERS_COMPAT },
/* n_tpm_pcr= */ 2,
L"Global credentials initrd",
&global_credential_initrd,
@@ -258,7 +258,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
(const CHAR8*) ".extra/sysext",
/* dir_mode= */ 0555,
/* access_mode= */ 0444,
- /* tpm_pcr= */ (UINT32[]) { TPM_PCR_INDEX_INITRD },
+ /* tpm_pcr= */ (uint32_t[]) { TPM_PCR_INDEX_INITRD },
/* n_tpm_pcr= */ 1,
L"System extension initrd",
&sysext_initrd,
diff --git a/src/boot/efi/ticks.c b/src/boot/efi/ticks.c
index 45980bafe8..dd8c06a53e 100644
--- a/src/boot/efi/ticks.c
+++ b/src/boot/efi/ticks.c
@@ -27,8 +27,8 @@ static BOOLEAN in_hypervisor(void) {
#endif
#ifdef __x86_64__
-static UINT64 ticks_read(void) {
- UINT64 a, d;
+static uint64_t ticks_read(void) {
+ uint64_t a, d;
if (in_hypervisor())
return 0;
@@ -37,8 +37,8 @@ static UINT64 ticks_read(void) {
return (d << 32) | a;
}
#elif defined(__i386__)
-static UINT64 ticks_read(void) {
- UINT64 val;
+static uint64_t ticks_read(void) {
+ uint64_t val;
if (in_hypervisor())
return 0;
@@ -47,28 +47,28 @@ static UINT64 ticks_read(void) {
return val;
}
#elif defined(__aarch64__)
-static UINT64 ticks_read(void) {
- UINT64 val;
+static uint64_t ticks_read(void) {
+ uint64_t val;
__asm__ volatile ("mrs %0, cntpct_el0" : "=r" (val));
return val;
}
#else
-static UINT64 ticks_read(void) {
+static uint64_t ticks_read(void) {
return 0;
}
#endif
#if defined(__aarch64__)
-static UINT64 ticks_freq(void) {
- UINT64 freq;
+static uint64_t ticks_freq(void) {
+ uint64_t freq;
__asm__ volatile ("mrs %0, cntfrq_el0": "=r" (freq));
return freq;
}
#else
/* count TSC ticks during a millisecond delay */
-static UINT64 ticks_freq(void) {
- UINT64 ticks_start, ticks_end;
- static UINT64 cache = 0;
+static uint64_t ticks_freq(void) {
+ uint64_t ticks_start, ticks_end;
+ static uint64_t cache = 0;
if (cache != 0)
return cache;
@@ -86,8 +86,8 @@ static UINT64 ticks_freq(void) {
}
#endif
-UINT64 time_usec(void) {
- UINT64 ticks, freq;
+uint64_t time_usec(void) {
+ uint64_t ticks, freq;
ticks = ticks_read();
if (ticks == 0)
diff --git a/src/boot/efi/ticks.h b/src/boot/efi/ticks.h
index ba259a6cc9..fec3764dd4 100644
--- a/src/boot/efi/ticks.h
+++ b/src/boot/efi/ticks.h
@@ -1,7 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
-#include <efi.h>
-#include <efilib.h>
+#include <stdint.h>
-UINT64 time_usec(void);
+uint64_t time_usec(void);
diff --git a/src/boot/efi/util.c b/src/boot/efi/util.c
index bddad8eda9..9e38dfbc48 100644
--- a/src/boot/efi/util.c
+++ b/src/boot/efi/util.c
@@ -27,7 +27,7 @@ EFI_STATUS parse_boolean(const CHAR8 *v, BOOLEAN *b) {
return EFI_INVALID_PARAMETER;
}
-EFI_STATUS efivar_set_raw(const EFI_GUID *vendor, const CHAR16 *name, const void *buf, UINTN size, UINT32 flags) {
+EFI_STATUS efivar_set_raw(const EFI_GUID *vendor, const CHAR16 *name, const void *buf, UINTN size, uint32_t flags) {
assert(vendor);
assert(name);
assert(buf || size == 0);
@@ -36,14 +36,14 @@ EFI_STATUS efivar_set_raw(const EFI_GUID *vendor, const CHAR16 *name, const void
return RT->SetVariable((CHAR16 *) name, (EFI_GUID *) vendor, flags, size, (void *) buf);
}
-EFI_STATUS efivar_set(const EFI_GUID *vendor, const CHAR16 *name, const CHAR16 *value, UINT32 flags) {
+EFI_STATUS efivar_set(const EFI_GUID *vendor, const CHAR16 *name, const CHAR16 *value, uint32_t flags) {
assert(vendor);
assert(name);
return efivar_set_raw(vendor, name, value, value ? strsize16(value) : 0, flags);
}
-EFI_STATUS efivar_set_uint_string(const EFI_GUID *vendor, const CHAR16 *name, UINTN i, UINT32 flags) {
+EFI_STATUS efivar_set_uint_string(const EFI_GUID *vendor, const CHAR16 *name, UINTN i, uint32_t flags) {
CHAR16 str[32];
assert(vendor);
@@ -56,34 +56,34 @@ EFI_STATUS efivar_set_uint_string(const EFI_GUID *vendor, const CHAR16 *name, UI
return efivar_set(vendor, name, str, flags);
}
-EFI_STATUS efivar_set_uint32_le(const EFI_GUID *vendor, const CHAR16 *name, UINT32 value, UINT32 flags) {
- UINT8 buf[4];
+EFI_STATUS efivar_set_uint32_le(const EFI_GUID *vendor, const CHAR16 *name, uint32_t value, uint32_t flags) {
+ uint8_t buf[4];
assert(vendor);
assert(name);
- buf[0] = (UINT8)(value >> 0U & 0xFF);
- buf[1] = (UINT8)(value >> 8U & 0xFF);
- buf[2] = (UINT8)(value >> 16U & 0xFF);
- buf[3] = (UINT8)(value >> 24U & 0xFF);
+ buf[0] = (uint8_t)(value >> 0U & 0xFF);
+ buf[1] = (uint8_t)(value >> 8U & 0xFF);
+ buf[2] = (uint8_t)(value >> 16U & 0xFF);
+ buf[3] = (uint8_t)(value >> 24U & 0xFF);
return efivar_set_raw(vendor, name, buf, sizeof(buf), flags);
}
-EFI_STATUS efivar_set_uint64_le(const EFI_GUID *vendor, const CHAR16 *name, UINT64 value, UINT32 flags) {
- UINT8 buf[8];
+EFI_STATUS efivar_set_uint64_le(const EFI_GUID *vendor, const CHAR16 *name, uint64_t value, uint32_t flags) {
+ uint8_t buf[8];
assert(vendor);
assert(name);
- buf[0] = (UINT8)(value >> 0U & 0xFF);
- buf[1] = (UINT8)(value >> 8U & 0xFF);
- buf[2] = (UINT8)(value >> 16U & 0xFF);
- buf[3] = (UINT8)(value >> 24U & 0xFF);
- buf[4] = (UINT8)(value >> 32U & 0xFF);
- buf[5] = (UINT8)(value >> 40U & 0xFF);
- buf[6] = (UINT8)(value >> 48U & 0xFF);
- buf[7] = (UINT8)(value >> 56U & 0xFF);
+ buf[0] = (uint8_t)(value >> 0U & 0xFF);
+ buf[1] = (uint8_t)(value >> 8U & 0xFF);
+ buf[2] = (uint8_t)(value >> 16U & 0xFF);
+ buf[3] = (uint8_t)(value >> 24U & 0xFF);
+ buf[4] = (uint8_t)(value >> 32U & 0xFF);
+ buf[5] = (uint8_t)(value >> 40U & 0xFF);
+ buf[6] = (uint8_t)(value >> 48U & 0xFF);
+ buf[7] = (uint8_t)(value >> 56U & 0xFF);
return efivar_set_raw(vendor, name, buf, sizeof(buf), flags);
}
@@ -144,7 +144,7 @@ EFI_STATUS efivar_get_uint_string(const EFI_GUID *vendor, const CHAR16 *name, UI
return EFI_SUCCESS;
}
-EFI_STATUS efivar_get_uint32_le(const EFI_GUID *vendor, const CHAR16 *name, UINT32 *ret) {
+EFI_STATUS efivar_get_uint32_le(const EFI_GUID *vendor, const CHAR16 *name, uint32_t *ret) {
_cleanup_freepool_ CHAR8 *buf = NULL;
UINTN size;
EFI_STATUS err;
@@ -154,17 +154,17 @@ EFI_STATUS efivar_get_uint32_le(const EFI_GUID *vendor, const CHAR16 *name, UINT
err = efivar_get_raw(vendor, name, &buf, &size);
if (err == EFI_SUCCESS && ret) {
- if (size != sizeof(UINT32))
+ if (size != sizeof(uint32_t))
return EFI_BUFFER_TOO_SMALL;
- *ret = (UINT32) buf[0] << 0U | (UINT32) buf[1] << 8U | (UINT32) buf[2] << 16U |
- (UINT32) buf[3] << 24U;
+ *ret = (uint32_t) buf[0] << 0U | (uint32_t) buf[1] << 8U | (uint32_t) buf[2] << 16U |
+ (uint32_t) buf[3] << 24U;
}
return err;
}
-EFI_STATUS efivar_get_uint64_le(const EFI_GUID *vendor, const CHAR16 *name, UINT64 *ret) {
+EFI_STATUS efivar_get_uint64_le(const EFI_GUID *vendor, const CHAR16 *name, uint64_t *ret) {
_cleanup_freepool_ CHAR8 *buf = NULL;
UINTN size;
EFI_STATUS err;
@@ -174,12 +174,12 @@ EFI_STATUS efivar_get_uint64_le(const EFI_GUID *vendor, const CHAR16 *name, UINT
err = efivar_get_raw(vendor, name, &buf, &size);
if (err == EFI_SUCCESS && ret) {
- if (size != sizeof(UINT64))
+ if (size != sizeof(uint64_t))
return EFI_BUFFER_TOO_SMALL;
- *ret = (UINT64) buf[0] << 0U | (UINT64) buf[1] << 8U | (UINT64) buf[2] << 16U |
- (UINT64) buf[3] << 24U | (UINT64) buf[4] << 32U | (UINT64) buf[5] << 40U |
- (UINT64) buf[6] << 48U | (UINT64) buf[7] << 56U;
+ *ret = (uint64_t) buf[0] << 0U | (uint64_t) buf[1] << 8U | (uint64_t) buf[2] << 16U |
+ (uint64_t) buf[3] << 24U | (uint64_t) buf[4] << 32U | (uint64_t) buf[5] << 40U |
+ (uint64_t) buf[6] << 48U | (uint64_t) buf[7] << 56U;
}
return err;
@@ -225,7 +225,7 @@ EFI_STATUS efivar_get_boolean_u8(const EFI_GUID *vendor, const CHAR16 *name, BOO
return err;
}
-void efivar_set_time_usec(const EFI_GUID *vendor, const CHAR16 *name, UINT64 usec) {
+void efivar_set_time_usec(const EFI_GUID *vendor, const CHAR16 *name, uint64_t usec) {
CHAR16 str[32];
assert(vendor);
@@ -416,7 +416,7 @@ void log_error_stall(const CHAR16 *fmt, ...) {
assert(fmt);
- INT32 attr = ST->ConOut->Mode->Attribute;
+ int32_t attr = ST->ConOut->Mode->Attribute;
ST->ConOut->SetAttribute(ST->ConOut, EFI_LIGHTRED|EFI_BACKGROUND_BLACK);
if (ST->ConOut->Mode->CursorColumn > 0)
@@ -606,8 +606,8 @@ EFI_STATUS open_directory(
return EFI_SUCCESS;
}
-UINT64 get_os_indications_supported(void) {
- UINT64 osind;
+uint64_t get_os_indications_supported(void) {
+ uint64_t osind;
EFI_STATUS err;
/* Returns the supported OS indications. If we can't acquire it, returns a zeroed out mask, i.e. no
@@ -638,13 +638,13 @@ __attribute__((noinline)) void debug_break(void) {
#endif
#if defined(__i386__) || defined(__x86_64__)
-static inline UINT8 inb(UINT16 port) {
- UINT8 value;
+static inline uint8_t inb(uint16_t port) {
+ uint8_t value;
asm volatile("inb %1, %0" : "=a"(value) : "Nd"(port));
return value;
}
-static inline void outb(UINT16 port, UINT8 value) {
+static inline void outb(uint16_t port, uint8_t value) {
asm volatile("outb %0, %1" : : "a"(value), "Nd"(port));
}
@@ -663,12 +663,12 @@ void beep(UINTN beep_count) {
};
/* Set frequency. */
- UINT32 counter = PIT_FREQUENCY / PITCH;
+ uint32_t counter = PIT_FREQUENCY / PITCH;
outb(TIMER_CONTROL_PORT, TIMER_PORT_MAGIC);
outb(TIMER_CONTROL2_PORT, counter & 0xFF);
outb(TIMER_CONTROL2_PORT, (counter >> 8) & 0xFF);
- UINT8 value = inb(SPEAKER_CONTROL_PORT);
+ uint8_t value = inb(SPEAKER_CONTROL_PORT);
while (beep_count > 0) {
/* Turn speaker on. */
diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h
index b75589f53d..8196db78e8 100644
--- a/src/boot/efi/util.h
+++ b/src/boot/efi/util.h
@@ -9,17 +9,11 @@
#define UINTN_MAX (~(UINTN)0)
#define INTN_MAX ((INTN)(UINTN_MAX>>1))
-#ifndef UINT32_MAX
-#define UINT32_MAX ((UINT32) -1)
-#endif
-#ifndef UINT64_MAX
-#define UINT64_MAX ((UINT64) -1)
-#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));
+assert_cc(sizeof(int) == sizeof(uint32_t));
#if __SIZEOF_POINTER__ == 4
# define PRIuN L"u"
# define PRIiN L"d"
@@ -77,18 +71,18 @@ static inline void *xrealloc(void *p, size_t old_size, size_t new_size) {
EFI_STATUS parse_boolean(const CHAR8 *v, BOOLEAN *b);
-EFI_STATUS efivar_set(const EFI_GUID *vendor, const CHAR16 *name, const CHAR16 *value, UINT32 flags);
-EFI_STATUS efivar_set_raw(const EFI_GUID *vendor, const CHAR16 *name, const void *buf, UINTN size, UINT32 flags);
-EFI_STATUS efivar_set_uint_string(const EFI_GUID *vendor, const CHAR16 *name, UINTN i, UINT32 flags);
-EFI_STATUS efivar_set_uint32_le(const EFI_GUID *vendor, const CHAR16 *NAME, UINT32 value, UINT32 flags);
-EFI_STATUS efivar_set_uint64_le(const EFI_GUID *vendor, const CHAR16 *name, UINT64 value, UINT32 flags);
-void efivar_set_time_usec(const EFI_GUID *vendor, const CHAR16 *name, UINT64 usec);
+EFI_STATUS efivar_set(const EFI_GUID *vendor, const CHAR16 *name, const CHAR16 *value, uint32_t flags);
+EFI_STATUS efivar_set_raw(const EFI_GUID *vendor, const CHAR16 *name, const void *buf, UINTN size, uint32_t flags);
+EFI_STATUS efivar_set_uint_string(const EFI_GUID *vendor, const CHAR16 *name, UINTN i, uint32_t flags);
+EFI_STATUS efivar_set_uint32_le(const EFI_GUID *vendor, const CHAR16 *NAME, uint32_t value, uint32_t flags);
+EFI_STATUS efivar_set_uint64_le(const EFI_GUID *vendor, const CHAR16 *name, uint64_t value, uint32_t flags);
+void efivar_set_time_usec(const EFI_GUID *vendor, const CHAR16 *name, uint64_t usec);
EFI_STATUS efivar_get(const EFI_GUID *vendor, const CHAR16 *name, CHAR16 **value);
EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, const CHAR16 *name, CHAR8 **buffer, UINTN *size);
EFI_STATUS efivar_get_uint_string(const EFI_GUID *vendor, const CHAR16 *name, UINTN *i);
-EFI_STATUS efivar_get_uint32_le(const EFI_GUID *vendor, const CHAR16 *name, UINT32 *ret);
-EFI_STATUS efivar_get_uint64_le(const EFI_GUID *vendor, const CHAR16 *name, UINT64 *ret);
+EFI_STATUS efivar_get_uint32_le(const EFI_GUID *vendor, const CHAR16 *name, uint32_t *ret);
+EFI_STATUS efivar_get_uint64_le(const EFI_GUID *vendor, const CHAR16 *name, uint64_t *ret);
EFI_STATUS efivar_get_boolean_u8(const EFI_GUID *vendor, const CHAR16 *name, BOOLEAN *ret);
CHAR16 *xstra_to_path(const CHAR8 *stra);
@@ -168,11 +162,11 @@ static inline void *PHYSICAL_ADDRESS_TO_POINTER(EFI_PHYSICAL_ADDRESS addr) {
return (void*) (UINTN) addr;
}
-UINT64 get_os_indications_supported(void);
+uint64_t get_os_indications_supported(void);
#ifdef EFI_DEBUG
void debug_break(void);
-extern UINT8 _text, _data;
+extern uint8_t _text, _data;
/* 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. */
# define debug_hook(identity) Print(identity L"@0x%lx,0x%lx\n", POINTER_TO_PHYSICAL_ADDRESS(&_text), POINTER_TO_PHYSICAL_ADDRESS(&_data))
diff --git a/src/boot/efi/xbootldr.c b/src/boot/efi/xbootldr.c
index 1e73b4a653..b6ad3a426a 100644
--- a/src/boot/efi/xbootldr.c
+++ b/src/boot/efi/xbootldr.c
@@ -16,11 +16,11 @@ static EFI_DEVICE_PATH *path_chop(EFI_DEVICE_PATH *path, EFI_DEVICE_PATH *node)
assert(path);
assert(node);
- UINTN len = (UINT8 *) node - (UINT8 *) path;
+ UINTN len = (uint8_t *) node - (uint8_t *) path;
EFI_DEVICE_PATH *chopped = xmalloc(len + END_DEVICE_PATH_LENGTH);
memcpy(chopped, path, len);
- SetDevicePathEndNode((EFI_DEVICE_PATH *) ((UINT8 *) chopped + len));
+ SetDevicePathEndNode((EFI_DEVICE_PATH *) ((uint8_t *) chopped + len));
return chopped;
}
@@ -43,7 +43,7 @@ static EFI_DEVICE_PATH *path_dup(const EFI_DEVICE_PATH *dp) {
static BOOLEAN verify_gpt(union GptHeaderBuffer *gpt_header_buffer, EFI_LBA lba_expected) {
EFI_PARTITION_TABLE_HEADER *h;
- UINT32 crc32, crc32_saved;
+ uint32_t crc32, crc32_saved;
EFI_STATUS err;
assert(gpt_header_buffer);
@@ -93,7 +93,7 @@ static EFI_STATUS try_gpt(
_cleanup_freepool_ EFI_PARTITION_ENTRY *entries = NULL;
union GptHeaderBuffer gpt;
EFI_STATUS err;
- UINT32 crc32;
+ uint32_t crc32;
UINTN size;
assert(block_io);
@@ -137,7 +137,7 @@ static EFI_STATUS try_gpt(
EFI_PARTITION_ENTRY *entry;
EFI_LBA start, end;
- entry = (EFI_PARTITION_ENTRY*) ((UINT8*) entries + gpt.gpt_header.SizeOfPartitionEntry * i);
+ entry = (EFI_PARTITION_ENTRY*) ((uint8_t*) entries + gpt.gpt_header.SizeOfPartitionEntry * i);
if (memcmp(&entry->PartitionTypeGUID, XBOOTLDR_GUID, sizeof(entry->PartitionTypeGUID)) != 0)
continue;
@@ -244,7 +244,7 @@ static EFI_STATUS find_device(EFI_HANDLE *device, EFI_DEVICE_PATH **ret_device_p
/* Patch in the data we found */
EFI_DEVICE_PATH *xboot_path = path_dup(partition_path);
- memcpy((UINT8 *) xboot_path + ((UINT8 *) part_node - (UINT8 *) partition_path), &hd, sizeof(hd));
+ memcpy((uint8_t *) xboot_path + ((uint8_t *) part_node - (uint8_t *) partition_path), &hd, sizeof(hd));
*ret_device_path = xboot_path;
return EFI_SUCCESS;
}