No changes in behavior.
typedef struct {
ConfigEntry **entries;
- UINTN entry_count;
- UINTN idx_default;
- UINTN idx_default_efivar;
+ size_t entry_count;
+ size_t idx_default;
+ size_t idx_default_efivar;
uint32_t timeout_sec; /* Actual timeout used (efi_main() override > efivar > config). */
uint32_t timeout_sec_config;
uint32_t timeout_sec_efivar;
IDX_INVALID,
};
-static void cursor_left(UINTN *cursor, UINTN *first) {
+static void cursor_left(size_t *cursor, size_t *first) {
assert(cursor);
assert(first);
(*first)--;
}
-static void cursor_right(
- UINTN *cursor,
- UINTN *first,
- UINTN x_max,
- UINTN len) {
-
+static void cursor_right(size_t *cursor, size_t *first, size_t x_max, size_t len) {
assert(cursor);
assert(first);
(*first)++;
}
-static bool line_edit(
- char16_t **line_in,
- UINTN x_max,
- UINTN y_pos) {
-
+static bool line_edit(char16_t **line_in, size_t x_max, size_t y_pos) {
_cleanup_free_ char16_t *line = NULL, *print = NULL;
- UINTN size, len, first = 0, cursor = 0, clear = 0;
+ size_t size, len, first = 0, cursor = 0, clear = 0;
assert(line_in);
for (;;) {
EFI_STATUS err;
uint64_t key;
- UINTN j;
- UINTN cursor_color = TEXT_ATTR_SWAP(COLOR_EDIT);
+ size_t j, cursor_color = TEXT_ATTR_SWAP(COLOR_EDIT);
j = MIN(len - first, x_max);
memcpy(print, line + first, j * sizeof(char16_t));
/* kill-word */
clear = 0;
- UINTN k;
+ size_t k;
for (k = first + cursor; k < len && line[k] == ' '; k++)
clear++;
for (; k < len && line[k] != ' '; k++)
clear++;
- for (UINTN i = first + cursor; i + clear < len; i++)
+ for (size_t i = first + cursor; i + clear < len; i++)
line[i] = line[i + clear];
len -= clear;
line[len] = '\0';
clear++;
}
- for (UINTN i = first + cursor; i + clear < len; i++)
+ for (size_t i = first + cursor; i + clear < len; i++)
line[i] = line[i + clear];
len -= clear;
line[len] = '\0';
continue;
if (first + cursor == len)
continue;
- for (UINTN i = first + cursor; i < len; i++)
+ for (size_t i = first + cursor; i < len; i++)
line[i] = line[i+1];
clear = 1;
len--;
continue;
if (first == 0 && cursor == 0)
continue;
- for (UINTN i = first + cursor-1; i < len; i++)
+ for (size_t i = first + cursor-1; i < len; i++)
line[i] = line[i+1];
clear = 1;
len--;
case KEYPRESS(0, 0, 0x80) ... KEYPRESS(0, 0, 0xffff):
if (len+1 == size)
continue;
- for (UINTN i = len; i > first + cursor; i--)
+ for (size_t i = len; i > first + cursor; i--)
line[i] = line[i-1];
line[first + cursor] = KEYCHAR(key);
len++;
}
}
-static UINTN entry_lookup_key(Config *config, UINTN start, char16_t key) {
+static size_t entry_lookup_key(Config *config, size_t start, char16_t key) {
assert(config);
if (key == 0)
/* select entry by number key */
if (key >= '1' && key <= '9') {
- UINTN i = key - '0';
+ size_t i = key - '0';
if (i > config->entry_count)
i = config->entry_count;
return i-1;
}
/* find matching key in config entries */
- for (UINTN i = start; i < config->entry_count; i++)
+ for (size_t i = start; i < config->entry_count; i++)
if (config->entries[i]->key == key)
return i;
- for (UINTN i = 0; i < start; i++)
+ for (size_t i = 0; i < start; i++)
if (config->entries[i]->key == key)
return i;
}
static void print_status(Config *config, char16_t *loaded_image_path) {
- UINTN x_max, y_max;
+ size_t x_max, y_max;
uint32_t screen_width = 0, screen_height = 0;
SecureBootMode secure;
_cleanup_free_ char16_t *device_part_uuid = NULL;
if (!ps_continue())
return;
- for (UINTN i = 0; i < config->entry_count; i++) {
+ for (size_t i = 0; i < config->entry_count; i++) {
ConfigEntry *entry = config->entries[i];
EFI_DEVICE_PATH *dp = NULL;
_cleanup_free_ char16_t *dp_str = NULL;
assert(chosen_entry);
EFI_STATUS err;
- UINTN visible_max = 0;
- UINTN idx_highlight = config->idx_default;
- UINTN idx_highlight_prev = 0;
- UINTN idx, idx_first = 0, idx_last = 0;
+ size_t visible_max = 0;
+ size_t idx_highlight = config->idx_default, idx_highlight_prev = 0;
+ size_t idx, idx_first = 0, idx_last = 0;
bool new_mode = true, clear = true;
bool refresh = true, highlight = false;
- UINTN x_start = 0, y_start = 0, y_status = 0;
- UINTN x_max, y_max;
+ size_t x_start = 0, y_start = 0, y_status = 0, x_max, y_max;
_cleanup_(strv_freep) char16_t **lines = NULL;
_cleanup_free_ char16_t *clearline = NULL, *separator = NULL, *status = NULL;
uint32_t timeout_efivar_saved = config->timeout_sec_efivar;
uint32_t timeout_remain = config->timeout_sec == TIMEOUT_MENU_FORCE ? 0 : config->timeout_sec;
bool exit = false, run = true, firmware_setup = false;
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;
+ size_t default_efivar_saved = config->idx_default_efivar;
graphics_mode(false);
ST->ConIn->Reset(ST->ConIn, false);
log_error_status(err, "Error switching console mode: %m");
}
- UINTN line_width = 0, entry_padding = 3;
+ size_t line_width = 0, entry_padding = 3;
while (!exit) {
uint64_t key;
/* length of the longest entry */
line_width = 0;
- for (UINTN i = 0; i < config->entry_count; i++)
+ for (size_t i = 0; i < config->entry_count; i++)
line_width = MAX(line_width, strlen16(config->entries[i]->title_show));
line_width = MIN(line_width + 2 * entry_padding, x_max);
/* menu entries title lines */
lines = xnew(char16_t *, config->entry_count + 1);
- for (UINTN i = 0; i < config->entry_count; i++) {
- UINTN j, padding;
+ for (size_t i = 0; i < config->entry_count; i++) {
+ size_t j, padding;
lines[i] = xnew(char16_t, line_width + 1);
padding = (line_width - MIN(strlen16(config->entries[i]->title_show), line_width)) / 2;
for (j = 0; j < padding; j++)
lines[i][j] = ' ';
- for (UINTN k = 0; config->entries[i]->title_show[k] != '\0' && j < line_width; j++, k++)
+ for (size_t k = 0; config->entries[i]->title_show[k] != '\0' && j < line_width; j++, k++)
lines[i][j] = config->entries[i]->title_show[k];
for (; j < line_width; j++)
clearline = xnew(char16_t, x_max + 1);
separator = xnew(char16_t, x_max + 1);
- for (UINTN i = 0; i < x_max; i++) {
+ for (size_t i = 0; i < x_max; i++) {
clearline[i] = ' ';
separator[i] = unicode_supported() ? L'─' : L'-';
}
}
if (refresh) {
- for (UINTN i = idx_first; i <= idx_last && i < config->entry_count; i++) {
+ for (size_t i = idx_first; i <= idx_last && i < config->entry_count; i++) {
print_at(x_start, y_start + i - idx_first,
i == idx_highlight ? COLOR_HIGHLIGHT : COLOR_ENTRY,
lines[i]);
* input. Therefore, draw one less character then we could for the status message.
* Note that the same does not apply for the separator line as it will never be drawn
* on the last line. */
- UINTN len = strnlen16(status, x_max - 1);
- UINTN x = (x_max - len) / 2;
+ size_t len = strnlen16(status, x_max - 1);
+ size_t x = (x_max - len) / 2;
status[len] = '\0';
print_at(0, y_status, COLOR_NORMAL, clearline + x_max - x);
ST->ConOut->OutputString(ST->ConOut, status);
static char *line_get_key_value(
char *content,
const char *sep,
- UINTN *pos,
+ size_t *pos,
char **key_ret,
char **value_ret) {
char *line, *value;
- UINTN linelen;
+ size_t linelen;
assert(content);
assert(sep);
static void config_defaults_load_from_file(Config *config, char *content) {
char *line;
- UINTN pos = 0;
+ size_t pos = 0;
char *key, *value;
EFI_STATUS err;
_cleanup_free_ char16_t* old_path = NULL, *new_path = NULL;
_cleanup_(file_closep) EFI_FILE *handle = NULL;
_cleanup_free_ EFI_FILE_INFO *file_info = NULL;
- UINTN file_info_size;
+ size_t file_info_size;
EFI_STATUS err;
assert(entry);
_cleanup_(config_entry_freep) ConfigEntry *entry = NULL;
char *line;
- UINTN pos = 0, n_initrd = 0;
+ size_t pos = 0, n_initrd = 0;
char *key, *value;
EFI_STATUS err;
static void config_load_defaults(Config *config, EFI_FILE *root_dir) {
_cleanup_free_ char *content = NULL;
- UINTN value = 0; /* avoid false maybe-uninitialized warning */
+ size_t value = 0; /* avoid false maybe-uninitialized warning */
EFI_STATUS err;
assert(root_dir);
_cleanup_(file_closep) EFI_FILE *entries_dir = NULL;
_cleanup_free_ EFI_FILE_INFO *f = NULL;
- UINTN f_size = 0;
+ size_t f_size = 0;
EFI_STATUS err;
assert(config);
return CMP(a->tries_done, b->tries_done);
}
-static UINTN config_entry_find(Config *config, const char16_t *pattern) {
+static size_t config_entry_find(Config *config, const char16_t *pattern) {
assert(config);
/* We expect pattern and entry IDs to be already case folded. */
if (!pattern)
return IDX_INVALID;
- for (UINTN i = 0; i < config->entry_count; i++)
+ for (size_t i = 0; i < config->entry_count; i++)
if (efi_fnmatch(pattern, config->entries[i]->id))
return i;
}
static void config_default_entry_select(Config *config) {
- UINTN i;
+ size_t i;
assert(config);
config->timeout_sec = 10;
}
-static bool entries_unique(ConfigEntry **entries, bool *unique, UINTN entry_count) {
+static bool entries_unique(ConfigEntry **entries, bool *unique, size_t entry_count) {
bool is_unique = true;
assert(entries);
assert(unique);
- for (UINTN i = 0; i < entry_count; i++)
- for (UINTN k = i + 1; k < entry_count; k++) {
+ for (size_t i = 0; i < entry_count; i++)
+ for (size_t k = i + 1; k < entry_count; k++) {
if (!streq16(entries[i]->title_show, entries[k]->title_show))
continue;
bool unique[config->entry_count];
/* set title */
- for (UINTN i = 0; i < config->entry_count; i++) {
+ for (size_t i = 0; i < config->entry_count; i++) {
assert(!config->entries[i]->title_show);
unique[i] = true;
config->entries[i]->title_show = xstrdup16(config->entries[i]->title ?: config->entries[i]->id);
return;
/* add version to non-unique titles */
- for (UINTN i = 0; i < config->entry_count; i++) {
+ for (size_t i = 0; i < config->entry_count; i++) {
if (unique[i])
continue;
return;
/* add machine-id to non-unique titles */
- for (UINTN i = 0; i < config->entry_count; i++) {
+ for (size_t i = 0; i < config->entry_count; i++) {
if (unique[i])
continue;
return;
/* add file name to non-unique titles */
- for (UINTN i = 0; i < config->entry_count; i++) {
+ for (size_t i = 0; i < config->entry_count; i++) {
if (unique[i])
continue;
".sdmagic",
NULL
};
- UINTN offset = 0, size = 0, read;
+ size_t offset = 0, size = 0, read;
_cleanup_free_ char *content = NULL;
assert(root_dir);
static void config_entry_add_osx(Config *config) {
EFI_STATUS err;
- UINTN n_handles = 0;
+ size_t n_handles = 0;
_cleanup_free_ EFI_HANDLE *handles = NULL;
assert(config);
if (err != EFI_SUCCESS)
return;
- for (UINTN i = 0; i < n_handles; i++) {
+ for (size_t i = 0; i < n_handles; i++) {
_cleanup_(file_closep) EFI_FILE *root = NULL;
if (open_volume(handles[i], &root) != EFI_SUCCESS)
static EFI_STATUS boot_windows_bitlocker(void) {
_cleanup_free_ EFI_HANDLE *handles = NULL;
- UINTN n_handles;
+ size_t n_handles;
EFI_STATUS err;
// FIXME: Experimental for now. Should be generalized, and become a per-entry option that can be
/* Look for BitLocker magic string on all block drives. */
bool found = false;
- for (UINTN i = 0; i < n_handles; i++) {
+ for (size_t i = 0; i < n_handles; i++) {
EFI_BLOCK_IO_PROTOCOL *block_io;
err = BS->HandleProtocol(handles[i], MAKE_GUID_PTR(EFI_BLOCK_IO_PROTOCOL), (void **) &block_io);
if (err != EFI_SUCCESS || block_io->Media->BlockSize < 512 || block_io->Media->BlockSize > 4096)
return EFI_NOT_FOUND;
_cleanup_free_ uint16_t *boot_order = NULL;
- UINTN boot_order_size;
+ size_t boot_order_size;
/* There can be gaps in Boot#### entries. Instead of iterating over the full
* EFI var list or uint16_t namespace, just look for "Windows Boot Manager" in BootOrder. */
if (err != EFI_SUCCESS || boot_order_size % sizeof(uint16_t) != 0)
return err;
- for (UINTN i = 0; i < boot_order_size / sizeof(uint16_t); i++) {
+ for (size_t i = 0; i < boot_order_size / sizeof(uint16_t); i++) {
_cleanup_free_ char *buf = NULL;
- UINTN buf_size;
+ size_t buf_size;
_cleanup_free_ char16_t *name = xasprintf("Boot%04x", boot_order[i]);
err = efivar_get_raw(MAKE_GUID_PTR(EFI_GLOBAL_VARIABLE), name, &buf, &buf_size);
/* Boot#### are EFI_LOAD_OPTION. But we really are only interested
* for the description, which is at this offset. */
- UINTN offset = sizeof(uint32_t) + sizeof(uint16_t);
+ size_t offset = sizeof(uint32_t) + sizeof(uint16_t);
if (buf_size < offset + sizeof(char16_t))
continue;
_cleanup_free_ char *bcd = NULL;
char16_t *title = NULL;
EFI_STATUS err;
- UINTN len;
+ size_t len;
assert(config);
assert(device);
_cleanup_(file_closep) EFI_FILE *linux_dir = NULL;
_cleanup_free_ EFI_FILE_INFO *f = NULL;
- UINTN f_size = 0;
+ size_t f_size = 0;
EFI_STATUS err;
/* Adds Boot Loader Type #2 entries (i.e. /EFI/Linux/….efi) */
*os_image_version = NULL, *os_version = NULL, *os_version_id = NULL, *os_build_id = NULL;
const char16_t *good_name, *good_version, *good_sort_key;
_cleanup_free_ char *content = NULL;
- UINTN offs[_SECTION_MAX] = {};
- UINTN szs[_SECTION_MAX] = {};
- char *line;
- UINTN pos = 0;
- char *key, *value;
+ size_t offs[_SECTION_MAX] = {}, szs[_SECTION_MAX] = {}, pos = 0;
+ char *line, *key, *value;
err = readdir_harder(linux_dir, &f, &f_size);
if (err != EFI_SUCCESS || !f)
const ConfigEntry *entry,
char16_t **ret_options,
void **ret_initrd,
- UINTN *ret_initrd_size) {
+ size_t *ret_initrd_size) {
assert(root);
assert(entry);
_cleanup_free_ char16_t *options = NULL;
EFI_STATUS err;
- UINTN size = 0;
+ size_t size = 0;
_cleanup_free_ uint8_t *initrd = NULL;
STRV_FOREACH(i, entry->initrd) {
if (info->FileSize == 0) /* Automatically skip over empty files */
continue;
- UINTN new_size, read_size = info->FileSize;
+ size_t new_size, read_size = info->FileSize;
if (__builtin_add_overflow(size, read_size, &new_size))
return EFI_OUT_OF_RESOURCES;
initrd = xrealloc(initrd, size, new_size);
if (err != EFI_SUCCESS)
return log_error_status(err, "Error making file device path: %m");
- UINTN initrd_size = 0;
+ size_t initrd_size = 0;
_cleanup_free_ void *initrd = NULL;
_cleanup_free_ char16_t *options_initrd = NULL;
err = initrd_prepare(image_root, entry, &options_initrd, &initrd, &initrd_size);
static void config_free(Config *config) {
assert(config);
- for (UINTN i = 0; i < config->entry_count; i++)
+ for (size_t i = 0; i < config->entry_count; i++)
config_entry_free(config->entries[i]);
free(config->entries);
free(config->entry_default_config);
static void config_write_entries_to_variable(Config *config) {
_cleanup_free_ char *buffer = NULL;
- UINTN sz = 0;
+ size_t sz = 0;
char *p;
assert(config);
- for (UINTN i = 0; i < config->entry_count; i++)
+ for (size_t i = 0; i < config->entry_count; i++)
sz += strsize16(config->entries[i]->id);
p = buffer = xmalloc(sz);
- for (UINTN i = 0; i < config->entry_count; i++)
+ for (size_t i = 0; i < config->entry_count; i++)
p = mempcpy(p, config->entries[i]->id, strsize16(config->entries[i]->id));
assert(p == buffer + sz);
err = console_key_read(&key, 100 * 1000);
if (err == EFI_SUCCESS) {
/* find matching key in config entries */
- UINTN idx = entry_lookup_key(&config, config.idx_default, KEYCHAR(key));
+ size_t idx = entry_lookup_key(&config, config.idx_default, KEYCHAR(key));
if (idx != IDX_INVALID)
config.idx_default = idx;
else
EFI_STATUS console_key_read(uint64_t *key, uint64_t timeout_usec) {
static EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *conInEx = NULL, *extraInEx = NULL;
static bool checked = false;
- UINTN index;
+ size_t index;
EFI_STATUS err;
_cleanup_(event_closep) EFI_EVENT timer = NULL;
conInEx ? conInEx->WaitForKeyEx : ST->ConIn->WaitForKey,
extraInEx ? extraInEx->WaitForKeyEx : NULL,
};
- UINTN n_events = extraInEx ? 3 : 2;
+ size_t n_events = extraInEx ? 3 : 2;
/* Watchdog rearming loop in case the user never provides us with input or some
* broken firmware never returns from WaitForEvent. */
EFI_STATUS err;
int32_t old_mode;
- /* SetMode expects a UINTN, so make sure these values are sane. */
+ /* SetMode expects a size_t, so make sure these values are sane. */
mode = CLAMP(mode, CONSOLE_MODE_RANGE_MIN, CONSOLE_MODE_RANGE_MAX);
old_mode = MAX(CONSOLE_MODE_RANGE_MIN, ST->ConOut->Mode->Mode);
* then assume the text is readable and keep the text mode. */
else {
uint64_t text_area;
- UINTN x_max, y_max;
+ size_t x_max, y_max;
uint64_t screen_area = (uint64_t)screen_width * (uint64_t)screen_height;
console_query_mode(&x_max, &y_max);
}
}
-EFI_STATUS console_query_mode(UINTN *x_max, UINTN *y_max) {
+EFI_STATUS console_query_mode(size_t *x_max, size_t *y_max) {
EFI_STATUS err;
assert(x_max);
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 console_query_mode(size_t *x_max, size_t *y_max);
EFI_STATUS query_screen_resolution(uint32_t *ret_width, uint32_t *ret_height);
/* Writes a CPIO header 8 character hex value */
- for (UINTN i = 0; i < 8; i++)
+ for (size_t i = 0; i < 8; i++)
p[7-i] = hex[(v >> (4 * i)) & 0xF];
return p + 8;
static EFI_STATUS pack_cpio_one(
const char16_t *fname,
const void *contents,
- UINTN contents_size,
+ size_t contents_size,
const char *target_dir_prefix,
uint32_t access_mode,
uint32_t *inode_counter,
void **cpio_buffer,
- UINTN *cpio_buffer_size) {
+ size_t *cpio_buffer_size) {
- UINTN l, target_dir_prefix_size, fname_size, q;
+ size_t l, target_dir_prefix_size, fname_size, q;
char *a;
assert(fname);
l = 6 + 13*8 + 1 + 1; /* Fixed CPIO header size, slash separator, and NUL byte after the file name*/
target_dir_prefix_size = strlen8(target_dir_prefix);
- if (l > UINTN_MAX - target_dir_prefix_size)
+ if (l > SIZE_MAX - target_dir_prefix_size)
return EFI_OUT_OF_RESOURCES;
l += target_dir_prefix_size;
fname_size = strlen16(fname);
- if (l > UINTN_MAX - fname_size)
+ if (l > SIZE_MAX - fname_size)
return EFI_OUT_OF_RESOURCES;
l += fname_size; /* append space for file name */
/* Align the whole header to 4 byte size */
l = ALIGN4(l);
- if (l == UINTN_MAX) /* overflow check */
+ if (l == SIZE_MAX) /* overflow check */
return EFI_OUT_OF_RESOURCES;
/* Align the contents to 4 byte size */
q = ALIGN4(contents_size);
- if (q == UINTN_MAX) /* overflow check */
+ if (q == SIZE_MAX) /* overflow check */
return EFI_OUT_OF_RESOURCES;
- if (l > UINTN_MAX - q) /* overflow check */
+ if (l > SIZE_MAX - q) /* overflow check */
return EFI_OUT_OF_RESOURCES;
l += q; /* Add contents to header */
- if (*cpio_buffer_size > UINTN_MAX - l) /* overflow check */
+ if (*cpio_buffer_size > SIZE_MAX - l) /* overflow check */
return EFI_OUT_OF_RESOURCES;
a = xrealloc(*cpio_buffer, *cpio_buffer_size, *cpio_buffer_size + l);
uint32_t access_mode,
uint32_t *inode_counter,
void **cpio_buffer,
- UINTN *cpio_buffer_size) {
+ size_t *cpio_buffer_size) {
- UINTN l, path_size;
+ size_t l, path_size;
char *a;
assert(path);
l = 6 + 13*8 + 1; /* Fixed CPIO header size, and NUL byte after the file name*/
path_size = strlen8(path);
- if (l > UINTN_MAX - path_size)
+ if (l > SIZE_MAX - path_size)
return EFI_OUT_OF_RESOURCES;
l += path_size;
/* Align the whole header to 4 byte size */
l = ALIGN4(l);
- if (l == UINTN_MAX) /* overflow check */
+ if (l == SIZE_MAX) /* overflow check */
return EFI_OUT_OF_RESOURCES;
- if (*cpio_buffer_size > UINTN_MAX - l) /* overflow check */
+ if (*cpio_buffer_size > SIZE_MAX - l) /* overflow check */
return EFI_OUT_OF_RESOURCES;
*cpio_buffer = a = xrealloc(*cpio_buffer, *cpio_buffer_size, *cpio_buffer_size + l);
uint32_t dir_mode,
uint32_t *inode_counter,
void **cpio_buffer,
- UINTN *cpio_buffer_size) {
+ size_t *cpio_buffer_size) {
EFI_STATUS err;
static EFI_STATUS pack_cpio_trailer(
void **cpio_buffer,
- UINTN *cpio_buffer_size) {
+ size_t *cpio_buffer_size) {
static const char trailer[] =
"070701"
uint32_t tpm_pcr,
const char16_t *tpm_description,
void **ret_buffer,
- UINTN *ret_buffer_size,
+ size_t *ret_buffer_size,
bool *ret_measured) {
_cleanup_(file_closep) EFI_FILE *root = NULL, *extra_dir = NULL;
- UINTN dirent_size = 0, buffer_size = 0, n_items = 0, n_allocated = 0;
+ size_t dirent_size = 0, buffer_size = 0, n_items = 0, n_allocated = 0;
_cleanup_free_ char16_t *rel_dropin_dir = NULL;
_cleanup_free_ EFI_FILE_INFO *dirent = NULL;
_cleanup_(strv_freep) char16_t **items = NULL;
d = xstrdup16(dirent->FileName);
if (n_items+2 > n_allocated) {
- UINTN m;
-
/* We allocate 16 entries at a time, as a matter of optimization */
- if (n_items > (UINTN_MAX / sizeof(uint16_t)) - 16) /* Overflow check, just in case */
+ if (n_items > (SIZE_MAX / sizeof(uint16_t)) - 16) /* Overflow check, just in case */
return log_oom();
- m = n_items + 16;
+ size_t m = n_items + 16;
items = xrealloc(items, n_allocated * sizeof(uint16_t *), m * sizeof(uint16_t *));
n_allocated = m;
}
if (err != EFI_SUCCESS)
return log_error_status(err, "Failed to pack cpio prefix: %m");
- for (UINTN i = 0; i < n_items; i++) {
+ for (size_t i = 0; i < n_items; i++) {
_cleanup_free_ char *content = NULL;
- UINTN contentsize = 0; /* avoid false maybe-uninitialized warning */
+ size_t contentsize = 0; /* avoid false maybe-uninitialized warning */
err = file_read(extra_dir, items[i], 0, 0, &content, &contentsize);
if (err != EFI_SUCCESS) {
uint32_t tpm_pcr,
const char16_t *tpm_description,
void **ret_buffer,
- UINTN *ret_buffer_size,
+ size_t *ret_buffer_size,
bool *ret_measured) {
uint32_t inode = 1; /* inode counter, so that each item gets a new inode */
_cleanup_free_ void *buffer = NULL;
- UINTN buffer_size = 0;
+ size_t buffer_size = 0;
EFI_STATUS err;
assert(data || data_size == 0);
uint32_t tpm_pcr,
const char16_t *tpm_description,
void **ret_buffer,
- UINTN *ret_buffer_size,
+ size_t *ret_buffer_size,
bool *ret_measured);
EFI_STATUS pack_cpio_literal(
uint32_t tpm_pcr,
const char16_t *tpm_description,
void **ret_buffer,
- UINTN *ret_buffer_size,
+ size_t *ret_buffer_size,
bool *ret_measured);
#define FDT_V1_SIZE (7*4)
-static EFI_STATUS devicetree_allocate(struct devicetree_state *state, UINTN size) {
- UINTN pages = DIV_ROUND_UP(size, EFI_PAGE_SIZE);
+static EFI_STATUS devicetree_allocate(struct devicetree_state *state, size_t size) {
+ size_t pages = DIV_ROUND_UP(size, EFI_PAGE_SIZE);
EFI_STATUS err;
assert(state);
return err;
}
-static UINTN devicetree_allocated(const struct devicetree_state *state) {
+static size_t devicetree_allocated(const struct devicetree_state *state) {
assert(state);
return state->pages * EFI_PAGE_SIZE;
}
-static EFI_STATUS devicetree_fixup(struct devicetree_state *state, UINTN len) {
+static EFI_STATUS devicetree_fixup(struct devicetree_state *state, size_t len) {
EFI_DT_FIXUP_PROTOCOL *fixup;
- UINTN size;
+ size_t size;
EFI_STATUS err;
assert(state);
EFI_DT_APPLY_FIXUPS | EFI_DT_RESERVE_MEMORY);
if (err == EFI_BUFFER_TOO_SMALL) {
EFI_PHYSICAL_ADDRESS oldaddr = state->addr;
- UINTN oldpages = state->pages;
+ size_t oldpages = state->pages;
void *oldptr = PHYSICAL_ADDRESS_TO_POINTER(state->addr);
err = devicetree_allocate(state, size);
EFI_STATUS devicetree_install(struct devicetree_state *state, EFI_FILE *root_dir, char16_t *name) {
_cleanup_(file_closep) EFI_FILE *handle = NULL;
_cleanup_free_ EFI_FILE_INFO *info = NULL;
- UINTN len;
+ size_t len;
EFI_STATUS err;
assert(state);
MAKE_GUID_PTR(EFI_DTB_TABLE), PHYSICAL_ADDRESS_TO_POINTER(state->addr));
}
-EFI_STATUS devicetree_install_from_memory(struct devicetree_state *state,
- const void *dtb_buffer, UINTN dtb_length) {
+EFI_STATUS devicetree_install_from_memory(
+ struct devicetree_state *state, const void *dtb_buffer, size_t dtb_length) {
EFI_STATUS err;
struct devicetree_state {
EFI_PHYSICAL_ADDRESS addr;
- UINTN pages;
+ size_t pages;
void *orig;
};
EFI_STATUS devicetree_install(struct devicetree_state *state, EFI_FILE *root_dir, char16_t *name);
EFI_STATUS devicetree_install_from_memory(
- struct devicetree_state *state, const VOID *dtb_buffer, UINTN dtb_length);
+ struct devicetree_state *state, const void *dtb_buffer, size_t dtb_length);
void devicetree_cleanup(struct devicetree_state *state);
_cleanup_(file_closep) EFI_FILE *drivers_dir = NULL;
_cleanup_free_ EFI_FILE_INFO *dirent = NULL;
- UINTN dirent_size = 0, n_succeeded = 0;
+ size_t dirent_size = 0, n_succeeded = 0;
EFI_STATUS err;
err = open_directory(
struct initrd_loader {
EFI_LOAD_FILE_PROTOCOL load_file;
const void *address;
- UINTN length;
+ size_t length;
};
/* static structure for LINUX_INITRD_MEDIA device path
EFI_LOAD_FILE_PROTOCOL *this,
EFI_DEVICE_PATH *file_path,
BOOLEAN boot_policy,
- UINTN *buffer_size,
+ size_t *buffer_size,
void *buffer) {
struct initrd_loader *loader;
EFI_STATUS initrd_register(
const void *initrd_address,
- UINTN initrd_length,
+ size_t initrd_length,
EFI_HANDLE *ret_initrd_handle) {
EFI_STATUS err;
#pragma once
#include <efi.h>
+#include <stddef.h>
EFI_STATUS initrd_register(
const void *initrd_address,
- UINTN initrd_length,
+ size_t initrd_length,
EFI_HANDLE *ret_initrd_handle);
EFI_STATUS initrd_unregister(EFI_HANDLE initrd_handle);
const EFI_TCG *tcg,
uint32_t pcrindex,
EFI_PHYSICAL_ADDRESS buffer,
- UINTN buffer_size,
+ size_t buffer_size,
const char16_t *description) {
_cleanup_free_ TCG_PCR_EVENT *tcg_event = NULL;
EFI_PHYSICAL_ADDRESS event_log_last;
uint32_t event_number = 1;
- UINTN desc_len;
+ size_t desc_len;
assert(tcg);
assert(description);
const char16_t *description) {
_cleanup_free_ EFI_TCG2_EVENT *tcg_event = NULL;
- UINTN desc_len;
+ size_t desc_len;
assert(tcg);
assert(description);
return tcg2_interface_check() || tcg1_interface_check();
}
-EFI_STATUS tpm_log_event(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const char16_t *description, bool *ret_measured) {
+EFI_STATUS tpm_log_event(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, size_t buffer_size, const char16_t *description, bool *ret_measured) {
EFI_TCG2 *tpm2;
EFI_STATUS err;
return err;
}
-EFI_STATUS tpm_log_event_ascii(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const char *description, bool *ret_measured) {
+EFI_STATUS tpm_log_event_ascii(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, size_t buffer_size, const char *description, bool *ret_measured) {
_cleanup_free_ char16_t *c = NULL;
if (description)
#if ENABLE_TPM
bool tpm_present(void);
-EFI_STATUS tpm_log_event(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const char16_t *description, bool *ret_measured);
-EFI_STATUS tpm_log_event_ascii(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const char *description, bool *ret_measured);
+EFI_STATUS tpm_log_event(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, size_t buffer_size, const char16_t *description, bool *ret_measured);
+EFI_STATUS tpm_log_event_ascii(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, size_t buffer_size, const char *description, bool *ret_measured);
EFI_STATUS tpm_log_load_options(const char16_t *cmdline, bool *ret_measured);
#else
return false;
}
-static inline EFI_STATUS tpm_log_event(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const char16_t *description, bool *ret_measured) {
+static inline EFI_STATUS tpm_log_event(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, size_t buffer_size, const char16_t *description, bool *ret_measured) {
if (ret_measured)
*ret_measured = false;
return EFI_SUCCESS;
}
-static inline EFI_STATUS tpm_log_event_ascii(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const char *description, bool *ret_measured) {
+static inline EFI_STATUS tpm_log_event_ascii(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, size_t buffer_size, const char *description, bool *ret_measured) {
if (ret_measured)
*ret_measured = false;
return EFI_SUCCESS;
return false;
/* overflow check */
- if (h->SizeOfPartitionEntry > UINTN_MAX / h->NumberOfPartitionEntries)
+ if (h->SizeOfPartitionEntry > SIZE_MAX / h->NumberOfPartitionEntries)
return false;
return true;
union GptHeaderBuffer gpt;
EFI_STATUS err;
uint32_t crc32;
- UINTN size;
+ size_t size;
assert(block_io);
assert(ret_hd);
return EFI_NOT_FOUND;
/* Now load the GPT entry table */
- size = ALIGN_TO((UINTN) gpt.gpt_header.SizeOfPartitionEntry * (UINTN) gpt.gpt_header.NumberOfPartitionEntries, 512);
+ size = ALIGN_TO((size_t) gpt.gpt_header.SizeOfPartitionEntry * (size_t) gpt.gpt_header.NumberOfPartitionEntries, 512);
entries = xmalloc(size);
err = block_io->ReadBlocks(
return EFI_CRC_ERROR;
/* Now we can finally look for xbootloader partitions. */
- for (UINTN i = 0; i < gpt.gpt_header.NumberOfPartitionEntries; i++) {
+ for (size_t i = 0; i < gpt.gpt_header.NumberOfPartitionEntries; i++) {
EFI_PARTITION_ENTRY *entry =
(EFI_PARTITION_ENTRY *) ((uint8_t *) entries + gpt.gpt_header.SizeOfPartitionEntry * i);
/* Try several copies of the GPT header, in case one is corrupted */
EFI_LBA backup_lba = 0;
- for (UINTN nr = 0; nr < 3; nr++) {
+ for (size_t nr = 0; nr < 3; nr++) {
EFI_LBA lba;
/* Read the first copy at LBA 1 and then try the backup GPT header pointed
IN_SET(pe->OptionalHeader.Magic, OPTHDR32_MAGIC, OPTHDR64_MAGIC);
}
-static inline UINTN section_table_offset(const DosFileHeader *dos, const PeFileHeader *pe) {
+static inline size_t section_table_offset(const DosFileHeader *dos, const PeFileHeader *pe) {
assert(dos);
assert(pe);
return dos->ExeHeader + offsetof(PeFileHeader, OptionalHeader) + pe->FileHeader.SizeOfOptionalHeader;
static void locate_sections(
const PeSectionHeader section_table[],
- UINTN n_table,
+ size_t n_table,
const char * const sections[],
- UINTN *offsets,
- UINTN *sizes,
+ size_t *offsets,
+ size_t *sizes,
bool in_memory) {
assert(section_table);
size_t prev_section_addr = 0;
- for (UINTN i = 0; i < n_table; i++) {
+ for (size_t i = 0; i < n_table; i++) {
const PeSectionHeader *sect = section_table + i;
if (in_memory) {
prev_section_addr = sect->VirtualAddress + sect->VirtualSize;
}
- for (UINTN j = 0; sections[j]; j++) {
+ for (size_t j = 0; sections[j]; j++) {
if (memcmp(sect->Name, sections[j], strlen8(sections[j])) != 0)
continue;
}
static uint32_t get_compatibility_entry_address(const DosFileHeader *dos, const PeFileHeader *pe) {
- UINTN addr = 0, size = 0;
+ size_t addr = 0, size = 0;
static const char *sections[] = { ".compat", NULL };
/* The kernel may provide alternative PE entry points for different PE architectures. This allows
return EFI_SUCCESS;
}
-EFI_STATUS pe_memory_locate_sections(const void *base, const char * const sections[], UINTN *addrs, UINTN *sizes) {
+EFI_STATUS pe_memory_locate_sections(const void *base, const char * const sections[], size_t *addrs, size_t *sizes) {
const DosFileHeader *dos;
const PeFileHeader *pe;
- UINTN offset;
+ size_t offset;
assert(base);
assert(sections);
EFI_FILE *dir,
const char16_t *path,
const char * const sections[],
- UINTN *offsets,
- UINTN *sizes) {
+ size_t *offsets,
+ size_t *sizes) {
_cleanup_free_ PeSectionHeader *section_table = NULL;
_cleanup_(file_closep) EFI_FILE *handle = NULL;
DosFileHeader dos;
PeFileHeader pe;
- UINTN len, section_table_len;
+ size_t len, section_table_len;
EFI_STATUS err;
assert(dir);
EFI_STATUS pe_memory_locate_sections(
const void *base,
const char * const sections[],
- UINTN *addrs,
- UINTN *sizes);
+ size_t *addrs,
+ size_t *sizes);
EFI_STATUS pe_file_locate_sections(
EFI_FILE *dir,
const char16_t *path,
const char * const sections[],
- UINTN *offsets,
- UINTN *sizes);
+ size_t *offsets,
+ size_t *sizes);
EFI_STATUS pe_kernel_info(const void *base, uint32_t *ret_compat_address);
/* Some basic domain separation in case somebody uses this data elsewhere */
#define HASH_LABEL "systemd-boot random seed label v1"
-static EFI_STATUS acquire_rng(void *ret, UINTN size) {
+static EFI_STATUS acquire_rng(void *ret, size_t size) {
EFI_RNG_PROTOCOL *rng;
EFI_STATUS err;
return EFI_SUCCESS;
}
-static EFI_STATUS acquire_system_token(void **ret, UINTN *ret_size) {
+static EFI_STATUS acquire_system_token(void **ret, size_t *ret_size) {
_cleanup_free_ char *data = NULL;
EFI_STATUS err;
- UINTN size;
+ size_t size;
assert(ret);
assert(ret_size);
0xaf, 0xac, 0x45, 0x03, 0x7a, 0xfe, 0xe9, 0xd1 }},
};
- for (UINTN i = 0; i < ELEMENTSOF(array); i++)
+ for (size_t i = 0; i < ELEMENTSOF(array); i++)
assert(memcmp(SHA256_DIRECT(array[i].string, strlen8(array[i].string)), array[i].hash, HASH_VALUE_SIZE) == 0);
#endif
}
#pragma once
#include <efi.h>
+#include <stddef.h>
-EFI_STATUS graphics_splash(const uint8_t *content, UINTN len);
+EFI_STATUS graphics_splash(const uint8_t *content, size_t len);
_used_ _section_(".sdmagic") static const char magic[] = "#### LoaderInfo: systemd-stub " GIT_VERSION " ####";
static EFI_STATUS combine_initrd(
- EFI_PHYSICAL_ADDRESS initrd_base, UINTN initrd_size,
+ EFI_PHYSICAL_ADDRESS initrd_base, size_t initrd_size,
const void * const extra_initrds[], const size_t extra_initrd_sizes[], size_t n_extra_initrds,
- Pages *ret_initr_pages, UINTN *ret_initrd_size) {
+ Pages *ret_initr_pages, size_t *ret_initrd_size) {
- UINTN n;
+ size_t n;
assert(ret_initr_pages);
assert(ret_initrd_size);
if (!extra_initrds[i])
continue;
- if (n > UINTN_MAX - extra_initrd_sizes[i])
+ if (n > SIZE_MAX - extra_initrd_sizes[i])
return EFI_OUT_OF_RESOURCES;
n += extra_initrd_sizes[i];
UINT32_MAX /* Below 4G boundary. */);
uint8_t *p = PHYSICAL_ADDRESS_TO_POINTER(pages.addr);
if (initrd_base != 0) {
- UINTN pad;
+ size_t pad;
/* Order matters, the real initrd must come first, since it might include microcode updates
* which the kernel only looks for in the first cpio archive */
return EFI_INVALID_PARAMETER;
}
-EFI_STATUS efivar_set_raw(const EFI_GUID *vendor, const char16_t *name, const void *buf, UINTN size, uint32_t flags) {
+EFI_STATUS efivar_set_raw(const EFI_GUID *vendor, const char16_t *name, const void *buf, size_t size, uint32_t flags) {
assert(vendor);
assert(name);
assert(buf || size == 0);
return efivar_set_raw(vendor, name, value, value ? strsize16(value) : 0, flags);
}
-EFI_STATUS efivar_set_uint_string(const EFI_GUID *vendor, const char16_t *name, UINTN i, uint32_t flags) {
+EFI_STATUS efivar_set_uint_string(const EFI_GUID *vendor, const char16_t *name, size_t i, uint32_t flags) {
assert(vendor);
assert(name);
_cleanup_free_ char16_t *buf = NULL;
EFI_STATUS err;
char16_t *val;
- UINTN size;
+ size_t size;
assert(vendor);
assert(name);
return EFI_SUCCESS;
}
-EFI_STATUS efivar_get_uint_string(const EFI_GUID *vendor, const char16_t *name, UINTN *ret) {
+EFI_STATUS efivar_get_uint_string(const EFI_GUID *vendor, const char16_t *name, size_t *ret) {
_cleanup_free_ char16_t *val = NULL;
EFI_STATUS err;
uint64_t u;
if (err != EFI_SUCCESS)
return err;
- if (!parse_number16(val, &u, NULL) || u > UINTN_MAX)
+ if (!parse_number16(val, &u, NULL) || u > SIZE_MAX)
return EFI_INVALID_PARAMETER;
if (ret)
EFI_STATUS efivar_get_uint32_le(const EFI_GUID *vendor, const char16_t *name, uint32_t *ret) {
_cleanup_free_ char *buf = NULL;
- UINTN size;
+ size_t size;
EFI_STATUS err;
assert(vendor);
EFI_STATUS efivar_get_uint64_le(const EFI_GUID *vendor, const char16_t *name, uint64_t *ret) {
_cleanup_free_ char *buf = NULL;
- UINTN size;
+ size_t size;
EFI_STATUS err;
assert(vendor);
return EFI_SUCCESS;
}
-EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, const char16_t *name, char **ret, UINTN *ret_size) {
+EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, const char16_t *name, char **ret, size_t *ret_size) {
_cleanup_free_ char *buf = NULL;
- UINTN l;
+ size_t l;
EFI_STATUS err;
assert(vendor);
EFI_STATUS efivar_get_boolean_u8(const EFI_GUID *vendor, const char16_t *name, bool *ret) {
_cleanup_free_ char *b = NULL;
- UINTN size;
+ size_t size;
EFI_STATUS err;
assert(vendor);
}
}
-EFI_STATUS file_read(EFI_FILE *dir, const char16_t *name, UINTN off, UINTN size, char **ret, UINTN *ret_size) {
+EFI_STATUS file_read(EFI_FILE *dir, const char16_t *name, size_t off, size_t size, char **ret, size_t *ret_size) {
_cleanup_(file_closep) EFI_FILE *handle = NULL;
_cleanup_free_ char *buf = NULL;
EFI_STATUS err;
}
/* Allocate some extra bytes to guarantee the result is NUL-terminated for char and char16_t strings. */
- UINTN extra = size % sizeof(char16_t) + sizeof(char16_t);
+ size_t extra = size % sizeof(char16_t) + sizeof(char16_t);
buf = xmalloc(size + extra);
if (size > 0) {
return err;
}
-void print_at(UINTN x, UINTN y, UINTN attr, const char16_t *str) {
+void print_at(size_t x, size_t y, size_t attr, const char16_t *str) {
assert(str);
ST->ConOut->SetCursorPosition(ST->ConOut, x, y);
ST->ConOut->SetAttribute(ST->ConOut, attr);
ST->ConOut->OutputString(ST->ConOut, (char16_t *) str);
}
-void clear_screen(UINTN attr) {
+void clear_screen(size_t attr) {
log_wait();
ST->ConOut->SetAttribute(ST->ConOut, attr);
ST->ConOut->ClearScreen(ST->ConOut);
void sort_pointer_array(
void **array,
- UINTN n_members,
+ size_t n_members,
compare_pointer_func_t compare) {
assert(array || n_members == 0);
if (n_members <= 1)
return;
- for (UINTN i = 1; i < n_members; i++) {
- UINTN k;
+ for (size_t i = 1; i < n_members; i++) {
+ size_t k;
void *entry = array[i];
for (k = i; k > 0; k--) {
EFI_STATUS get_file_info_harder(
EFI_FILE *handle,
EFI_FILE_INFO **ret,
- UINTN *ret_size) {
+ size_t *ret_size) {
- UINTN size = offsetof(EFI_FILE_INFO, FileName) + 256;
+ size_t size = offsetof(EFI_FILE_INFO, FileName) + 256;
_cleanup_free_ EFI_FILE_INFO *fi = NULL;
EFI_STATUS err;
EFI_STATUS readdir_harder(
EFI_FILE *handle,
EFI_FILE_INFO **buffer,
- UINTN *buffer_size) {
+ size_t *buffer_size) {
EFI_STATUS err;
- UINTN sz;
+ size_t sz;
assert(handle);
assert(buffer);
#endif
#ifdef EFI_DEBUG
-void hexdump(const char16_t *prefix, const void *data, UINTN size) {
+void hexdump(const char16_t *prefix, const void *data, size_t size) {
static const char hex[16] = "0123456789abcdef";
_cleanup_free_ char16_t *buf = NULL;
const uint8_t *d = data;
buf = xnew(char16_t, size*2+1);
- for (UINTN i = 0; i < size; i++) {
+ for (size_t i = 0; i < size; i++) {
buf[i*2] = hex[d[i] >> 4];
buf[i*2+1] = hex[d[i] & 0x0F];
}
}
void *find_configuration_table(const EFI_GUID *guid) {
- for (UINTN i = 0; i < ST->NumberOfTableEntries; i++)
+ for (size_t i = 0; i < ST->NumberOfTableEntries; i++)
if (efi_guid_equal(&ST->ConfigurationTable[i].VendorGuid, guid))
return ST->ConfigurationTable[i].VendorTable;
#include "log.h"
#include "string-util-fundamental.h"
-#define UINTN_MAX (~(UINTN)0)
-#define INTN_MAX ((INTN)(UINTN_MAX>>1))
-
static inline void free(void *p) {
if (!p)
return;
EFI_STATUS parse_boolean(const char *v, bool *b);
EFI_STATUS efivar_set(const EFI_GUID *vendor, const char16_t *name, const char16_t *value, uint32_t flags);
-EFI_STATUS efivar_set_raw(const EFI_GUID *vendor, const char16_t *name, const void *buf, UINTN size, uint32_t flags);
-EFI_STATUS efivar_set_uint_string(const EFI_GUID *vendor, const char16_t *name, UINTN i, uint32_t flags);
+EFI_STATUS efivar_set_raw(const EFI_GUID *vendor, const char16_t *name, const void *buf, size_t size, uint32_t flags);
+EFI_STATUS efivar_set_uint_string(const EFI_GUID *vendor, const char16_t *name, size_t i, uint32_t flags);
EFI_STATUS efivar_set_uint32_le(const EFI_GUID *vendor, const char16_t *NAME, uint32_t value, uint32_t flags);
EFI_STATUS efivar_set_uint64_le(const EFI_GUID *vendor, const char16_t *name, uint64_t value, uint32_t flags);
void efivar_set_time_usec(const EFI_GUID *vendor, const char16_t *name, uint64_t usec);
EFI_STATUS efivar_get(const EFI_GUID *vendor, const char16_t *name, char16_t **ret);
-EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, const char16_t *name, char **ret, UINTN *ret_size);
-EFI_STATUS efivar_get_uint_string(const EFI_GUID *vendor, const char16_t *name, UINTN *ret);
+EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, const char16_t *name, char **ret, size_t *ret_size);
+EFI_STATUS efivar_get_uint_string(const EFI_GUID *vendor, const char16_t *name, size_t *ret);
EFI_STATUS efivar_get_uint32_le(const EFI_GUID *vendor, const char16_t *name, uint32_t *ret);
EFI_STATUS efivar_get_uint64_le(const EFI_GUID *vendor, const char16_t *name, uint64_t *ret);
EFI_STATUS efivar_get_boolean_u8(const EFI_GUID *vendor, const char16_t *name, bool *ret);
char16_t *xstr8_to_path(const char *stra);
void mangle_stub_cmdline(char16_t *cmdline);
-EFI_STATUS file_read(EFI_FILE *dir, const char16_t *name, UINTN off, UINTN size, char **content, UINTN *content_size);
+EFI_STATUS file_read(EFI_FILE *dir, const char16_t *name, size_t off, size_t size, char **content, size_t *content_size);
static inline void file_closep(EFI_FILE **handle) {
if (!*handle)
#define LOADER_GUID \
{ 0x4a67b082, 0x0a4c, 0x41cf, { 0xb6, 0xc7, 0x44, 0x0b, 0x29, 0xbb, 0x8c, 0x4f } }
-void print_at(UINTN x, UINTN y, UINTN attr, const char16_t *str);
-void clear_screen(UINTN attr);
+void print_at(size_t x, size_t y, size_t attr, const char16_t *str);
+void clear_screen(size_t attr);
typedef int (*compare_pointer_func_t)(const void *a, const void *b);
-void sort_pointer_array(void **array, UINTN n_members, compare_pointer_func_t compare);
+void sort_pointer_array(void **array, size_t n_members, compare_pointer_func_t compare);
-EFI_STATUS get_file_info_harder(EFI_FILE *handle, EFI_FILE_INFO **ret, UINTN *ret_size);
+EFI_STATUS get_file_info_harder(EFI_FILE *handle, EFI_FILE_INFO **ret, size_t *ret_size);
-EFI_STATUS readdir_harder(EFI_FILE *handle, EFI_FILE_INFO **buffer, UINTN *buffer_size);
+EFI_STATUS readdir_harder(EFI_FILE *handle, EFI_FILE_INFO **buffer, size_t *buffer_size);
bool is_ascii(const char16_t *f);