static struct efi_config *efi_early;
+#define efi_call_early(f, ...) \
+ efi_early->call(efi_early->f, __VA_ARGS__);
+
#define BOOT_SERVICES(bits) \
static void setup_boot_services##bits(struct efi_config *c) \
{ \
}
grow:
- status = efi_early->call(efi_early->allocate_pool, EFI_LOADER_DATA,
- info_sz, (void **)&info);
+ status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
+ info_sz, (void **)&info);
if (status != EFI_SUCCESS) {
efi_printk(sys_table, "Failed to alloc mem for file info\n");
return status;
status = efi_early->call((unsigned long)h->get_info, h, &info_guid,
&info_sz, info);
if (status == EFI_BUFFER_TOO_SMALL) {
- efi_early->call(efi_early->free_pool, info);
+ efi_call_early(free_pool, info);
goto grow;
}
*file_sz = info->file_size;
- efi_early->call(efi_early->free_pool, info);
+ efi_call_early(free_pool, info);
if (status != EFI_SUCCESS)
efi_printk(sys_table, "Failed to get initrd info\n");
}
grow:
- status = efi_early->call(efi_early->allocate_pool, EFI_LOADER_DATA,
- info_sz, (void **)&info);
+ status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
+ info_sz, (void **)&info);
if (status != EFI_SUCCESS) {
efi_printk(sys_table, "Failed to alloc mem for file info\n");
return status;
status = efi_early->call((unsigned long)h->get_info, h, &info_guid,
&info_sz, info);
if (status == EFI_BUFFER_TOO_SMALL) {
- efi_early->call(efi_early->free_pool, info);
+ efi_call_early(free_pool, info);
goto grow;
}
*file_sz = info->file_size;
- efi_early->call(efi_early->free_pool, info);
+ efi_call_early(free_pool, info);
if (status != EFI_SUCCESS)
efi_printk(sys_table, "Failed to get initrd info\n");
void *handle = (void *)(unsigned long)image->device_handle;
unsigned long func;
- status = efi_early->call(efi_early->handle_protocol, handle,
- &fs_proto, (void **)&io);
+ status = efi_call_early(handle_protocol, handle,
+ &fs_proto, (void **)&io);
if (status != EFI_SUCCESS) {
efi_printk(sys_table, "Failed to handle fs_proto\n");
return status;
void *handle = (void *)(unsigned long)image->device_handle;
unsigned long func;
- status = efi_early->call(efi_early->handle_protocol, handle,
- &fs_proto, (void **)&io);
+ status = efi_call_early(handle_protocol, handle,
+ &fs_proto, (void **)&io);
if (status != EFI_SUCCESS) {
efi_printk(sys_table, "Failed to handle fs_proto\n");
return status;
size = pci->romsize + sizeof(*rom);
- status = efi_early->call(efi_early->allocate_pool,
- EFI_LOADER_DATA, size, &rom);
-
+ status = efi_call_early(allocate_pool, EFI_LOADER_DATA, size, &rom);
if (status != EFI_SUCCESS)
return status;
return status;
free_struct:
- efi_early->call(efi_early->free_pool, rom);
+ efi_call_early(free_pool, rom);
return status;
}
struct pci_setup_rom *rom = NULL;
u32 h = handles[i];
- status = efi_early->call(efi_early->handle_protocol, h,
- &pci_proto, (void **)&pci);
+ status = efi_call_early(handle_protocol, h,
+ &pci_proto, (void **)&pci);
if (status != EFI_SUCCESS)
continue;
size = pci->romsize + sizeof(*rom);
- status = efi_early->call(efi_early->allocate_pool,
- EFI_LOADER_DATA, size, &rom);
-
+ status = efi_call_early(allocate_pool, EFI_LOADER_DATA, size, &rom);
if (status != EFI_SUCCESS)
return status;
return status;
free_struct:
- efi_early->call(efi_early->free_pool, rom);
+ efi_call_early(free_pool, rom);
return status;
}
struct pci_setup_rom *rom = NULL;
u64 h = handles[i];
- status = efi_early->call(efi_early->handle_protocol, h,
- &pci_proto, (void **)&pci);
+ status = efi_call_early(handle_protocol, h,
+ &pci_proto, (void **)&pci);
if (status != EFI_SUCCESS)
continue;
efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID;
unsigned long size = 0;
- status = efi_early->call(efi_early->locate_handle,
- EFI_LOCATE_BY_PROTOCOL,
- &pci_proto, NULL, &size, pci_handle);
+ status = efi_call_early(locate_handle,
+ EFI_LOCATE_BY_PROTOCOL,
+ &pci_proto, NULL, &size, pci_handle);
if (status == EFI_BUFFER_TOO_SMALL) {
- status = efi_early->call(efi_early->allocate_pool,
- EFI_LOADER_DATA,
- size, (void **)&pci_handle);
+ status = efi_call_early(allocate_pool,
+ EFI_LOADER_DATA,
+ size, (void **)&pci_handle);
if (status != EFI_SUCCESS)
return status;
- status = efi_early->call(efi_early->locate_handle,
- EFI_LOCATE_BY_PROTOCOL, &pci_proto,
- NULL, &size, pci_handle);
+ status = efi_call_early(locate_handle,
+ EFI_LOCATE_BY_PROTOCOL, &pci_proto,
+ NULL, &size, pci_handle);
}
if (status != EFI_SUCCESS)
status = setup_efi_pci32(params, pci_handle, size);
free_handle:
- efi_early->call(efi_early->free_pool, pci_handle);
+ efi_call_early(free_pool, pci_handle);
return status;
}
void *dummy = NULL;
u32 h = handles[i];
- status = efi_early->call(efi_early->handle_protocol, h,
- proto, (void **)&gop32);
+ status = efi_call_early(handle_protocol, h,
+ proto, (void **)&gop32);
if (status != EFI_SUCCESS)
continue;
- status = efi_early->call(efi_early->handle_protocol, h,
- &conout_proto, &dummy);
+ status = efi_call_early(handle_protocol, h,
+ &conout_proto, &dummy);
if (status == EFI_SUCCESS)
conout_found = true;
void *dummy = NULL;
u64 h = handles[i];
- status = efi_early->call(efi_early->handle_protocol, h,
- proto, (void **)&gop64);
+ status = efi_call_early(handle_protocol, h,
+ proto, (void **)&gop64);
if (status != EFI_SUCCESS)
continue;
- status = efi_early->call(efi_early->handle_protocol, h,
- &conout_proto, &dummy);
+ status = efi_call_early(handle_protocol, h,
+ &conout_proto, &dummy);
if (status == EFI_SUCCESS)
conout_found = true;
efi_status_t status;
void **gop_handle = NULL;
- status = efi_early->call(efi_early->allocate_pool, EFI_LOADER_DATA,
- size, (void **)&gop_handle);
+ status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
+ size, (void **)&gop_handle);
if (status != EFI_SUCCESS)
return status;
- status = efi_early->call(efi_early->locate_handle,
- EFI_LOCATE_BY_PROTOCOL,
- proto, NULL, &size, gop_handle);
+ status = efi_call_early(locate_handle,
+ EFI_LOCATE_BY_PROTOCOL,
+ proto, NULL, &size, gop_handle);
if (status != EFI_SUCCESS)
goto free_handle;
status = setup_gop32(si, proto, size, gop_handle);
free_handle:
- efi_early->call(efi_early->free_pool, gop_handle);
+ efi_call_early(free_pool, gop_handle);
return status;
}
void *pciio;
u32 handle = handles[i];
- status = efi_early->call(efi_early->handle_protocol, handle,
- &uga_proto, (void **)&uga);
+ status = efi_call_early(handle_protocol, handle,
+ &uga_proto, (void **)&uga);
if (status != EFI_SUCCESS)
continue;
- efi_early->call(efi_early->handle_protocol, handle,
- &pciio_proto, &pciio);
+ efi_call_early(handle_protocol, handle, &pciio_proto, &pciio);
status = efi_early->call((unsigned long)uga->get_mode, uga,
&w, &h, &depth, &refresh);
void *pciio;
u64 handle = handles[i];
- status = efi_early->call(efi_early->handle_protocol, handle,
- &uga_proto, (void **)&uga);
+ status = efi_call_early(handle_protocol, handle,
+ &uga_proto, (void **)&uga);
if (status != EFI_SUCCESS)
continue;
- efi_early->call(efi_early->handle_protocol, handle,
- &pciio_proto, &pciio);
+ efi_call_early(handle_protocol, handle, &pciio_proto, &pciio);
status = efi_early->call((unsigned long)uga->get_mode, uga,
&w, &h, &depth, &refresh);
u32 width, height;
void **uga_handle = NULL;
- status = efi_early->call(efi_early->allocate_pool, EFI_LOADER_DATA,
- size, (void **)&uga_handle);
+ status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
+ size, (void **)&uga_handle);
if (status != EFI_SUCCESS)
return status;
- status = efi_early->call(efi_early->locate_handle,
- EFI_LOCATE_BY_PROTOCOL,
- uga_proto, NULL, &size, uga_handle);
+ status = efi_call_early(locate_handle,
+ EFI_LOCATE_BY_PROTOCOL,
+ uga_proto, NULL, &size, uga_handle);
if (status != EFI_SUCCESS)
goto free_handle;
si->rsvd_pos = 24;
free_handle:
- efi_early->call(efi_early->free_pool, uga_handle);
+ efi_call_early(free_pool, uga_handle);
return status;
}
memset(si, 0, sizeof(*si));
size = 0;
- status = efi_early->call(efi_early->locate_handle,
- EFI_LOCATE_BY_PROTOCOL,
- &graphics_proto, NULL, &size, gop_handle);
+ status = efi_call_early(locate_handle,
+ EFI_LOCATE_BY_PROTOCOL,
+ &graphics_proto, NULL, &size, gop_handle);
if (status == EFI_BUFFER_TOO_SMALL)
status = setup_gop(si, &graphics_proto, size);
if (status != EFI_SUCCESS) {
size = 0;
- status = efi_early->call(efi_early->locate_handle,
- EFI_LOCATE_BY_PROTOCOL,
- &uga_proto, NULL, &size, uga_handle);
+ status = efi_call_early(locate_handle,
+ EFI_LOCATE_BY_PROTOCOL,
+ &uga_proto, NULL, &size, uga_handle);
if (status == EFI_BUFFER_TOO_SMALL)
setup_uga(si, &uga_proto, size);
}
else
setup_boot_services32(efi_early);
- status = efi_early->call(efi_early->handle_protocol, handle,
- &proto, (void *)&image);
+ status = efi_call_early(handle_protocol, handle,
+ &proto, (void *)&image);
if (status != EFI_SUCCESS) {
efi_printk(sys_table, "Failed to get handle for LOADED_IMAGE_PROTOCOL\n");
return NULL;
sizeof(struct e820entry) * nr_desc;
if (*e820ext) {
- efi_early->call(efi_early->free_pool, *e820ext);
+ efi_call_early(free_pool, *e820ext);
*e820ext = NULL;
*e820ext_size = 0;
}
- status = efi_early->call(efi_early->allocate_pool, EFI_LOADER_DATA,
- size, (void **)e820ext);
+ status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
+ size, (void **)e820ext);
if (status == EFI_SUCCESS)
*e820ext_size = size;
if (status != EFI_SUCCESS)
goto free_mem_map;
- efi_early->call(efi_early->free_pool, mem_map);
+ efi_call_early(free_pool, mem_map);
goto get_map; /* Allocated memory, get map again */
}
#endif
/* Might as well exit boot services now */
- status = efi_early->call(efi_early->exit_boot_services, handle, key);
+ status = efi_call_early(exit_boot_services, handle, key);
if (status != EFI_SUCCESS) {
/*
* ExitBootServices() will fail if any of the event
goto free_mem_map;
called_exit = true;
- efi_early->call(efi_early->free_pool, mem_map);
+ efi_call_early(free_pool, mem_map);
goto get_map;
}
return EFI_SUCCESS;
free_mem_map:
- efi_early->call(efi_early->free_pool, mem_map);
+ efi_call_early(free_pool, mem_map);
return status;
}
setup_efi_pci(boot_params);
- status = efi_early->call(efi_early->allocate_pool, EFI_LOADER_DATA,
- sizeof(*gdt), (void **)&gdt);
+ status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
+ sizeof(*gdt), (void **)&gdt);
if (status != EFI_SUCCESS) {
efi_printk(sys_table, "Failed to alloc mem for gdt structure\n");
goto fail;
* allocation which may be in a new descriptor region.
*/
*map_size += sizeof(*m);
- status = efi_early->call(efi_early->allocate_pool, EFI_LOADER_DATA,
- *map_size, (void **)&m);
+ status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
+ *map_size, (void **)&m);
if (status != EFI_SUCCESS)
goto fail;
*desc_size = 0;
key = 0;
- status = efi_early->call(efi_early->get_memory_map, map_size, m,
- &key, desc_size, &desc_version);
+ status = efi_call_early(get_memory_map, map_size, m,
+ &key, desc_size, &desc_version);
if (status == EFI_BUFFER_TOO_SMALL) {
- efi_early->call(efi_early->free_pool, m);
+ efi_call_early(free_pool, m);
goto again;
}
if (status != EFI_SUCCESS)
- efi_early->call(efi_early->free_pool, m);
+ efi_call_early(free_pool, m);
if (key_ptr && status == EFI_SUCCESS)
*key_ptr = key;
if (!max_addr)
status = EFI_NOT_FOUND;
else {
- status = efi_early->call(efi_early->allocate_pages,
- EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA,
- nr_pages, &max_addr);
+ status = efi_call_early(allocate_pages,
+ EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA,
+ nr_pages, &max_addr);
if (status != EFI_SUCCESS) {
max = max_addr;
max_addr = 0;
*addr = max_addr;
}
- efi_early->call(efi_early->free_pool, map);
+ efi_call_early(free_pool, map);
fail:
return status;
}
if ((start + size) > end)
continue;
- status = efi_early->call(efi_early->allocate_pages,
- EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA,
- nr_pages, &start);
+ status = efi_call_early(allocate_pages,
+ EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA,
+ nr_pages, &start);
if (status == EFI_SUCCESS) {
*addr = start;
break;
if (i == map_size / desc_size)
status = EFI_NOT_FOUND;
- efi_early->call(efi_early->free_pool, map);
+ efi_call_early(free_pool, map);
fail:
return status;
}
return;
nr_pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE;
- efi_early->call(efi_early->free_pages, addr, nr_pages);
+ efi_call_early(free_pages, addr, nr_pages);
}
if (!nr_files)
return EFI_SUCCESS;
- status = efi_early->call(efi_early->allocate_pool, EFI_LOADER_DATA,
- nr_files * sizeof(*files), (void **)&files);
+ status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
+ nr_files * sizeof(*files), (void **)&files);
if (status != EFI_SUCCESS) {
efi_printk(sys_table_arg, "Failed to alloc mem for file handle list\n");
goto fail;
}
- efi_early->call(efi_early->free_pool, files);
+ efi_call_early(free_pool, files);
*load_addr = file_addr;
*load_size = file_size_total;
for (k = j; k < i; k++)
efi_file_close(fh, files[k].handle);
free_files:
- efi_early->call(efi_early->free_pool, files);
+ efi_call_early(free_pool, files);
fail:
*load_addr = 0;
*load_size = 0;
* as possible while respecting the required alignment.
*/
nr_pages = round_up(alloc_size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE;
- status = efi_early->call(efi_early->allocate_pages,
- EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA,
- nr_pages, &efi_addr);
+ status = efi_call_early(allocate_pages,
+ EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA,
+ nr_pages, &efi_addr);
new_addr = efi_addr;
/*
* If preferred address allocation failed allocate as low as