Pull request for UEFI sub-system for efi-2020-04-rc4 (4)

This series fixes several bugs:
 
 * consider the /reserved-memory node in the device tree
 * consider memory reservations created in ft_board_setup()
 * correct output of 'efidebug memmap' on the sandbox
 * correct the definition of efi_capsule_header()
 
 Furthermore some definitions needed for future patches are added to
 header files.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEbcT5xx8ppvoGt20zxIHbvCwFGsQFAl5x6bIACgkQxIHbvCwF
 GsSTYQ//fyixmgA7x6uD3222BAq000Y5bQ2jkt5Pd4dlg4Nv3FdNvElfSTOt9whT
 CCAGKMKafB7jkqXRohlPAmO4JG9bZmpJD26Wd1J+XWwax5q5ngFYFbWYZyymb4OQ
 xD8pxHkwwrF6D0VrVCbk3CMn+7sGIaGxm+0zZXDPQ1ZS2zbEkJlWGn6dGXy00yJY
 DWc+9P4e+bPGCKLU2xzADpY9seCg52OQ+C66aCj/f2qeMhOykgWG1B/GhvryljMl
 rbueOClQEbPdB6mAm7xyvOEDQ1K5Iy1JNf/4v5kL07jDiO/7rWP6ptXflaPIJP9y
 qhQ7Ozige/VpTUHauv9BE2oREPaSArJNhetyV4tWcNtS2+9vk+JLHoGWNK/8LtrE
 fTwL8tUyvTDA2YPQKy0TTJ0swLV3Y+Iwv7n51SxbAR7uMeRT9acs9ljciQtF5CQh
 S3i5ZN5+45utS6Gv8kVAwYsbFAs1CIuRAVleCu9OcnfWj61X5gvtkgNlbG5P1gGS
 WHsteTxB4gCQIyS+n0H9MhJFLzYFvj0WQWmJGULmEqgnWO06+gUsTLli9yt/ytoS
 a03VLMx/EZn2W48366OgH/dqrzVFT17IyrAehz08Uu7mk127OGggSJm5j2JRHqUf
 aBDn8K8+rf0zdaFtLDh8DagPX2fV97cPvmMQ/x2r+Ahqoc2rWhI=
 =zB6g
 -----END PGP SIGNATURE-----

Merge tag 'efi-2020-04-rc4-4' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi

Pull request for UEFI sub-system for efi-2020-04-rc4 (4)

This series fixes several bugs:

* consider the /reserved-memory node in the device tree
* consider memory reservations created in ft_board_setup()
* correct output of 'efidebug memmap' on the sandbox
* correct the definition of efi_capsule_header()

Furthermore some definitions needed for future patches are added to
header files.
This commit is contained in:
Tom Rini 2020-03-18 07:48:39 -04:00
commit 40e82bb97c
5 changed files with 102 additions and 24 deletions

View file

@ -149,6 +149,20 @@ done:
return ret;
}
static void efi_reserve_memory(u64 addr, u64 size)
{
u64 pages;
/* Convert from sandbox address space. */
addr = (uintptr_t)map_sysmem(addr, 0);
pages = efi_size_in_pages(size + (addr & EFI_PAGE_MASK));
addr &= ~EFI_PAGE_MASK;
if (efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE,
false) != EFI_SUCCESS)
printf("Reserved memory mapping failed addr %llx size %llx\n",
addr, size);
}
/**
* efi_carve_out_dt_rsv() - Carve out DT reserved memory ranges
*
@ -161,7 +175,8 @@ done:
static void efi_carve_out_dt_rsv(void *fdt)
{
int nr_rsv, i;
uint64_t addr, size, pages;
u64 addr, size;
int nodeoffset, subnode;
nr_rsv = fdt_num_mem_rsv(fdt);
@ -169,15 +184,25 @@ static void efi_carve_out_dt_rsv(void *fdt)
for (i = 0; i < nr_rsv; i++) {
if (fdt_get_mem_rsv(fdt, i, &addr, &size) != 0)
continue;
efi_reserve_memory(addr, size);
}
/* Convert from sandbox address space. */
addr = (uintptr_t)map_sysmem(addr, 0);
pages = efi_size_in_pages(size + (addr & EFI_PAGE_MASK));
addr &= ~EFI_PAGE_MASK;
if (efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE,
false) != EFI_SUCCESS)
printf("FDT memrsv map %d: Failed to add to map\n", i);
/* process reserved-memory */
nodeoffset = fdt_subnode_offset(fdt, 0, "reserved-memory");
if (nodeoffset >= 0) {
subnode = fdt_first_subnode(fdt, nodeoffset);
while (subnode >= 0) {
/* check if this subnode has a reg property */
addr = fdtdec_get_addr_size(fdt, subnode, "reg",
(fdt_size_t *)&size);
/*
* The /reserved-memory node may have children with
* a size instead of a reg property.
*/
if (addr != FDT_ADDR_T_NONE)
efi_reserve_memory(addr, size);
subnode = fdt_next_subnode(fdt, subnode);
}
}
}
@ -263,9 +288,6 @@ efi_status_t efi_install_fdt(void *fdt)
return EFI_LOAD_ERROR;
}
/* Create memory reservations as indicated by the device tree */
efi_carve_out_dt_rsv(fdt);
/* Prepare device tree for payload */
ret = copy_fdt(&fdt);
if (ret) {
@ -278,6 +300,9 @@ efi_status_t efi_install_fdt(void *fdt)
return EFI_LOAD_ERROR;
}
/* Create memory reservations as indicated by the device tree */
efi_carve_out_dt_rsv(fdt);
/* Install device tree as UEFI table */
ret = efi_install_configuration_table(&efi_guid_fdt, fdt);
if (ret != EFI_SUCCESS) {

View file

@ -12,6 +12,7 @@
#include <exports.h>
#include <hexdump.h>
#include <malloc.h>
#include <mapmem.h>
#include <search.h>
#include <linux/ctype.h>
@ -488,9 +489,10 @@ static int do_efi_show_memmap(cmd_tbl_t *cmdtp, int flag,
printf("%-16s %.*llx-%.*llx", type,
EFI_PHYS_ADDR_WIDTH,
map->physical_start,
(u64)map_to_sysmem((void *)map->physical_start),
EFI_PHYS_ADDR_WIDTH,
map->physical_start + map->num_pages * EFI_PAGE_SIZE);
(u64)map_to_sysmem((void *)map->physical_start +
map->num_pages * EFI_PAGE_SIZE));
print_memory_attributes(map->attribute);
putc('\n');

View file

@ -57,6 +57,16 @@ typedef u16 efi_form_id_t;
struct efi_event;
/* OsIndicationsSupported flags */
#define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001
#define EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION 0x0000000000000002
#define EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED 0x0000000000000004
#define EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED 0x0000000000000008
#define EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED 0x0000000000000010
#define EFI_OS_INDICATIONS_START_OS_RECOVERY 0x0000000000000020
#define EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY 0x0000000000000040
#define EFI_OS_INDICATIONS_JSON_CONFIG_DATA_REFRESH 0x0000000000000080
/* EFI Boot Services table */
#define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42
struct efi_boot_services {
@ -207,11 +217,11 @@ enum efi_reset_type {
#define CAPSULE_FLAGS_INITIATE_RESET 0x00040000
struct efi_capsule_header {
efi_guid_t *capsule_guid;
efi_guid_t capsule_guid;
u32 header_size;
u32 flags;
u32 capsule_image_size;
};
} __packed;
#define EFI_RT_SUPPORTED_GET_TIME 0x0001
#define EFI_RT_SUPPORTED_SET_TIME 0x0002
@ -1645,4 +1655,31 @@ struct efi_load_file_protocol {
#define LOAD_OPTION_CATEGORY_BOOT 0x00000000
#define LOAD_OPTION_CATEGORY_APP 0x00000100
/*
* System Resource Table
*/
/* Firmware Type Definitions */
#define ESRT_FW_TYPE_UNKNOWN 0x00000000
#define ESRT_FW_TYPE_SYSTEMFIRMWARE 0x00000001
#define ESRT_FW_TYPE_DEVICEFIRMWARE 0x00000002
#define ESRT_FW_TYPE_UEFIDRIVER 0x00000003
/* Last Attempt Status Values */
#define LAST_ATTEMPT_STATUS_SUCCESS 0x00000000
#define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL 0x00000001
#define LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES 0x00000002
#define LAST_ATTEMPT_STATUS_ERROR_INCORRECT_VERSION 0x00000003
#define LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT 0x00000004
#define LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR 0x00000005
#define LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_AC 0x00000006
#define LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_BATT 0x00000007
#define LAST_ATTEMPT_STATUS_ERROR_UNSATISFIED_DEPENDENCIES 0x00000008
/*
* The LastAttemptStatus values of 0x1000 - 0x4000 are reserved for vendor
* usage.
*/
#define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL_VENDOR_RANGE_MIN 0x00001000
#define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL_VENDOR_RANGE_MAX 0x00004000
#endif

View file

@ -457,6 +457,20 @@ efi_status_t efi_remove_all_protocols(const efi_handle_t handle);
/* Install multiple protocol interfaces */
efi_status_t EFIAPI efi_install_multiple_protocol_interfaces
(efi_handle_t *handle, ...);
/* Get handles that support a given protocol */
efi_status_t EFIAPI efi_locate_handle_buffer(
enum efi_locate_search_type search_type,
const efi_guid_t *protocol, void *search_key,
efi_uintn_t *no_handles, efi_handle_t **buffer);
/* Close an previously opened protocol interface */
efi_status_t EFIAPI efi_close_protocol(efi_handle_t handle,
const efi_guid_t *protocol,
efi_handle_t agent_handle,
efi_handle_t controller_handle);
/* Open a protocol interface */
efi_status_t EFIAPI efi_handle_protocol(efi_handle_t handle,
const efi_guid_t *protocol,
void **protocol_interface);
/* Call this to create an event */
efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl,
void (EFIAPI *notify_function) (

View file

@ -2106,10 +2106,10 @@ static efi_status_t EFIAPI efi_set_watchdog_timer(unsigned long timeout,
*
* Return: status code
*/
static efi_status_t EFIAPI efi_close_protocol(efi_handle_t handle,
const efi_guid_t *protocol,
efi_handle_t agent_handle,
efi_handle_t controller_handle)
efi_status_t EFIAPI efi_close_protocol(efi_handle_t handle,
const efi_guid_t *protocol,
efi_handle_t agent_handle,
efi_handle_t controller_handle)
{
struct efi_handler *handler;
struct efi_open_protocol_info_item *item;
@ -2282,7 +2282,7 @@ static efi_status_t EFIAPI efi_protocols_per_handle(
*
* Return: status code
*/
static efi_status_t EFIAPI efi_locate_handle_buffer(
efi_status_t EFIAPI efi_locate_handle_buffer(
enum efi_locate_search_type search_type,
const efi_guid_t *protocol, void *search_key,
efi_uintn_t *no_handles, efi_handle_t **buffer)
@ -3182,9 +3182,9 @@ out:
*
* Return: status code
*/
static efi_status_t EFIAPI efi_handle_protocol(efi_handle_t handle,
const efi_guid_t *protocol,
void **protocol_interface)
efi_status_t EFIAPI efi_handle_protocol(efi_handle_t handle,
const efi_guid_t *protocol,
void **protocol_interface)
{
return efi_open_protocol(handle, protocol, protocol_interface, efi_root,
NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);