Pull request for efi-2021-10-rc3

Documentation:
 
 * Rename Freescale to NXP
 * Document structures used for the UEFI TCG2 protocol
 
 UEFI:
 
 * Device paths must use EfiBootServicesData
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEK7wKXt3/btL6/yA+hO4vgnE3U0sFAmEf+AgACgkQhO4vgnE3
 U0skxhAAjjv6yMYLYlj2YNTtYDS2zVsnsY8i/vmWNmGYvwfrlcUC/e3J00ftBIjI
 DEwImrzefvQwr4NOZgIlyxR81NwboWULxvHSF5avwctxQVoTElkSfE2Ji+nFYa23
 P/L7E/Zf+NwTHBlE1wfkNJPZ/zya73DTOe+MGWvLnvOX56JZqEJOgmTtcQntRUll
 9zkB76j6sCk8B3ydFZmzGqhB4aslJBypG+bQB72XXGVBZoHb9pEPv90hBl616AN/
 5H8WewxTE2s6z3IfexxPAc7ssMQuW3RWw0WsJvBVviw8tSPj4SZjg5HNHAM3mz/i
 EXHUqAEySP1oT6P4hVef7Xc9gC67N+dVZGAA1QcZBkAnH+BQQ2GmIWX5+3mZJflq
 3eHWhMUHWc4q76MbN9QqReAo3wJ3GsBqdA1oORR5FgIPwEVl0jwQMYv6frC/vB6/
 6VX8WcbAWsixjf8QeQlibfMqBO9xZI1Iue5rN6DcwMey6dZrDnXGMdk7Woj6F4ga
 tERYBt+UBawTf2ww24wMXc7Hw2dZ6kj44ls2doRFKqHOpaY9Mk2QPTaVPrFkj33J
 3xlH2BYdB3ALriS1jN6Qcq6xEwyaMdkj5MzVyitunaCLiAKKORwGf0chkqiRiA+k
 zEET0uDBtO7beraiUJU9jeMPcVj3mYpiFR/CZBD/HWOVB/KwhGU=
 =gMKg
 -----END PGP SIGNATURE-----

Merge tag 'efi-2021-10-rc3' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2021-10-rc3

Documentation:

* Rename Freescale to NXP
* Document structures used for the UEFI TCG2 protocol

UEFI:

* Device paths must use EfiBootServicesData
This commit is contained in:
Tom Rini 2021-08-23 12:44:12 -04:00
commit 4865db0716
27 changed files with 100 additions and 53 deletions

View file

@ -91,7 +91,7 @@ struct hob_mem_alloc {
* Type EFI_MEMORY_TYPE is defined in AllocatePages() in the UEFI 2.0 * Type EFI_MEMORY_TYPE is defined in AllocatePages() in the UEFI 2.0
* specification. * specification.
*/ */
enum efi_mem_type mem_type; enum efi_memory_type mem_type;
/* padding */ /* padding */
u8 reserved[4]; u8 reserved[4];
}; };

View file

@ -14,11 +14,11 @@ Board-specific doc
congatec/index congatec/index
coreboot/index coreboot/index
emulation/index emulation/index
freescale/index
google/index google/index
intel/index intel/index
kontron/index kontron/index
microchip/index microchip/index
nxp/index
openpiton/index openpiton/index
qualcomm/index qualcomm/index
rockchip/index rockchip/index

View file

@ -1,7 +1,7 @@
.. SPDX-License-Identifier: GPL-2.0+ .. SPDX-License-Identifier: GPL-2.0+
Freescale NXP Semiconductors
========= ==================
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 2
@ -17,3 +17,4 @@ Freescale
mx6sabresd mx6sabresd
mx6ul_14x14_evk mx6ul_14x14_evk
mx6ullevk mx6ullevk
psb

View file

@ -6,5 +6,5 @@ STMicroelectronics
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 2
st st-dt
stm32mp1 stm32mp1

View file

@ -1,9 +0,0 @@
.. SPDX-License-Identifier: GPL-2.0+
NXP i.MX Machine-specific doc
=============================
.. toctree::
:maxdepth: 2
misc/index

View file

@ -1,9 +0,0 @@
.. SPDX-License-Identifier: GPL-2.0+
Miscellaneous
=============
.. toctree::
:maxdepth: 2
psb

View file

@ -64,17 +64,6 @@ implementation.
arch/index arch/index
Machine-specific doc
--------------------
These books provide programming details about machine-specific
implementation.
.. toctree::
:maxdepth: 2
imx/index
Board-specific doc Board-specific doc
------------------ ------------------

View file

@ -125,8 +125,36 @@ struct efi_table_hdr {
u32 reserved; u32 reserved;
}; };
/* Allocation types for calls to boottime->allocate_pages*/
/**
* enum efi_allocate_type - address restriction for memory allocation
*/
enum efi_allocate_type {
/**
* @EFI_ALLOCATE_ANY_PAGES:
* Allocate any block of sufficient size. Ignore memory address.
*/
EFI_ALLOCATE_ANY_PAGES,
/**
* @EFI_ALLOCATE_MAX_ADDRESS:
* Allocate a memory block with an uppermost address less or equal
* to the indicated address.
*/
EFI_ALLOCATE_MAX_ADDRESS,
/**
* @EFI_ALLOCATE_ADDRESS:
* Allocate a memory block starting at the indicatged adress.
*/
EFI_ALLOCATE_ADDRESS,
/**
* @EFI_MAX_ALLOCATE_TYPE:
* Value use for range checking.
*/
EFI_MAX_ALLOCATE_TYPE,
};
/* Enumeration of memory types introduced in UEFI */ /* Enumeration of memory types introduced in UEFI */
enum efi_mem_type { enum efi_memory_type {
EFI_RESERVED_MEMORY_TYPE, EFI_RESERVED_MEMORY_TYPE,
/* /*
* The code portions of a loaded application. * The code portions of a loaded application.
@ -224,12 +252,6 @@ struct efi_mem_desc {
#define EFI_MEMORY_DESCRIPTOR_VERSION 1 #define EFI_MEMORY_DESCRIPTOR_VERSION 1
/* Allocation types for calls to boottime->allocate_pages*/
#define EFI_ALLOCATE_ANY_PAGES 0
#define EFI_ALLOCATE_MAX_ADDRESS 1
#define EFI_ALLOCATE_ADDRESS 2
#define EFI_MAX_ALLOCATE_TYPE 3
/* Types and defines for Time Services */ /* Types and defines for Time Services */
#define EFI_TIME_ADJUST_DAYLIGHT 0x1 #define EFI_TIME_ADJUST_DAYLIGHT 0x1
#define EFI_TIME_IN_DAYLIGHT 0x2 #define EFI_TIME_IN_DAYLIGHT 0x2

View file

@ -249,7 +249,7 @@ struct efi_memory_range {
struct efi_memory_range_capsule { struct efi_memory_range_capsule {
struct efi_capsule_header *header; struct efi_capsule_header *header;
/* EFI_MEMORY_TYPE: 0x80000000-0xFFFFFFFF */ /* EFI_MEMORY_TYPE: 0x80000000-0xFFFFFFFF */
enum efi_mem_type os_requested_memory_type; enum efi_memory_type os_requested_memory_type;
u64 number_of_memory_ranges; u64 number_of_memory_ranges;
struct efi_memory_range memory_ranges[]; struct efi_memory_range memory_ranges[];
} __packed; } __packed;

View file

@ -676,13 +676,14 @@ struct efi_device_path *efi_get_dp_from_boot(const efi_guid_t guid);
/* Generic EFI memory allocator, call this to get memory */ /* Generic EFI memory allocator, call this to get memory */
void *efi_alloc(uint64_t len, int memory_type); void *efi_alloc(uint64_t len, int memory_type);
/* More specific EFI memory allocator, called by EFI payloads */ /* More specific EFI memory allocator, called by EFI payloads */
efi_status_t efi_allocate_pages(int type, int memory_type, efi_uintn_t pages, efi_status_t efi_allocate_pages(enum efi_allocate_type type,
uint64_t *memory); enum efi_memory_type memory_type,
efi_uintn_t pages, uint64_t *memory);
/* EFI memory free function. */ /* EFI memory free function. */
efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages); efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages);
/* EFI memory allocator for small allocations */ /* EFI memory allocator for small allocations */
efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, efi_status_t efi_allocate_pool(enum efi_memory_type pool_type,
void **buffer); efi_uintn_t size, void **buffer);
/* EFI pool memory free function. */ /* EFI pool memory free function. */
efi_status_t efi_free_pool(void *buffer); efi_status_t efi_free_pool(void *buffer);
/* Returns the EFI memory map */ /* Returns the EFI memory map */

View file

@ -3,6 +3,13 @@
* Defines data structures and APIs that allow an OS to interact with UEFI * Defines data structures and APIs that allow an OS to interact with UEFI
* firmware to query information about the device * firmware to query information about the device
* *
* This file refers the following TCG specification.
* - TCG PC Client Platform Firmware Profile Specification
* https://trustedcomputinggroup.org/resource/pc-client-specific-platform-firmware-profile-specification/
*
* - TCG EFI Protocol Specification
* https://trustedcomputinggroup.org/resource/tcg-efi-protocol-specification/
*
* Copyright (c) 2020, Linaro Limited * Copyright (c) 2020, Linaro Limited
*/ */
@ -36,11 +43,23 @@ typedef u32 efi_tcg_event_log_bitmap;
typedef u32 efi_tcg_event_log_format; typedef u32 efi_tcg_event_log_format;
typedef u32 efi_tcg_event_algorithm_bitmap; typedef u32 efi_tcg_event_algorithm_bitmap;
/**
* struct tdEFI_TCG2_VERSION - structure of EFI TCG2 version
* @major: major version
* @minor: minor version
*/
struct efi_tcg2_version { struct efi_tcg2_version {
u8 major; u8 major;
u8 minor; u8 minor;
}; };
/**
* struct tdEFI_TCG2_EVENT_HEADER - structure of EFI TCG2 event header
* @header_size: size of the event header
* @header_version: header version
* @pcr_index: index of the PCR that is extended
* @event_type: type of the event that is extended
*/
struct efi_tcg2_event_header { struct efi_tcg2_event_header {
u32 header_size; u32 header_size;
u16 header_version; u16 header_version;
@ -48,12 +67,27 @@ struct efi_tcg2_event_header {
u32 event_type; u32 event_type;
} __packed; } __packed;
/**
* struct tdEFI_TCG2_EVENT - structure of EFI TCG2 event
* @size: total size of the event including the size component, the header
* and the event data
* @header: event header
* @event: event to add
*/
struct efi_tcg2_event { struct efi_tcg2_event {
u32 size; u32 size;
struct efi_tcg2_event_header header; struct efi_tcg2_event_header header;
u8 event[]; u8 event[];
} __packed; } __packed;
/**
* struct tdUEFI_IMAGE_LOAD_EVENT - structure of PE/COFF image measurement
* @image_location_in_memory: image address
* @image_length_in_memory: image size
* @image_link_time_address: image link time address
* @length_of_device_path: devive path size
* @device_path: device path
*/
struct uefi_image_load_event { struct uefi_image_load_event {
efi_physical_addr_t image_location_in_memory; efi_physical_addr_t image_location_in_memory;
u64 image_length_in_memory; u64 image_length_in_memory;
@ -62,6 +96,23 @@ struct uefi_image_load_event {
struct efi_device_path device_path[]; struct efi_device_path device_path[];
}; };
/**
* struct tdEFI_TCG2_BOOT_SERVICE_CAPABILITY - protocol capability information
* @size: allocated size of the structure
* @structure_version: version of this structure
* @protocol_version: version of the EFI TCG2 protocol.
* @hash_algorithm_bitmap: supported hash algorithms
* @supported_event_logs: bitmap of supported event log formats
* @tpm_present_flag: false = TPM not present
* @max_command_size: max size (in bytes) of a command
* that can be sent to the TPM
* @max_response_size: max size (in bytes) of a response that
* can be provided by the TPM
* @manufacturer_id: 4-byte Vendor ID
* @number_of_pcr_banks: maximum number of PCR banks
* @active_pcr_banks: bitmap of currently active
* PCR banks (hashing algorithms).
*/
struct efi_tcg2_boot_service_capability { struct efi_tcg2_boot_service_capability {
u8 size; u8 size;
struct efi_tcg2_version structure_version; struct efi_tcg2_version structure_version;
@ -86,7 +137,7 @@ struct efi_tcg2_boot_service_capability {
#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_ERRATA_TPM2 2 #define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_ERRATA_TPM2 2
/** /**
* struct TCG_EfiSpecIdEventAlgorithmSize * struct TCG_EfiSpecIdEventAlgorithmSize - hashing algorithm information
* *
* @algorithm_id: algorithm defined in enum tpm2_algorithms * @algorithm_id: algorithm defined in enum tpm2_algorithms
* @digest_size: size of the algorithm * @digest_size: size of the algorithm
@ -97,7 +148,7 @@ struct tcg_efi_spec_id_event_algorithm_size {
} __packed; } __packed;
/** /**
* struct TCG_EfiSpecIDEventStruct * struct TCG_EfiSpecIDEventStruct - content of the event log header
* *
* @signature: signature, set to Spec ID Event03 * @signature: signature, set to Spec ID Event03
* @platform_class: class defined in TCG ACPI Specification * @platform_class: class defined in TCG ACPI Specification
@ -130,7 +181,7 @@ struct tcg_efi_spec_id_event {
} __packed; } __packed;
/** /**
* struct tdEFI_TCG2_FINAL_EVENTS_TABLE * struct tdEFI_TCG2_FINAL_EVENTS_TABLE - log entries after Get Event Log
* @version: version number for this structure * @version: version number for this structure
* @number_of_events: number of events recorded after invocation of * @number_of_events: number of events recorded after invocation of
* GetEventLog() * GetEventLog()

View file

@ -68,7 +68,7 @@ static void *dp_alloc(size_t sz)
{ {
void *buf; void *buf;
if (efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, sz, &buf) != if (efi_allocate_pool(EFI_BOOT_SERVICES_DATA, sz, &buf) !=
EFI_SUCCESS) { EFI_SUCCESS) {
debug("EFI: ERROR: out of memory in %s\n", __func__); debug("EFI: ERROR: out of memory in %s\n", __func__);
return NULL; return NULL;

View file

@ -34,7 +34,7 @@ static u16 *efi_str_to_u16(char *str)
efi_status_t ret; efi_status_t ret;
len = sizeof(u16) * (utf8_utf16_strlen(str) + 1); len = sizeof(u16) * (utf8_utf16_strlen(str) + 1);
ret = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, len, (void **)&out); ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, len, (void **)&out);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
return NULL; return NULL;
dst = out; dst = out;

View file

@ -454,7 +454,8 @@ static uint64_t efi_find_free_memory(uint64_t len, uint64_t max_addr)
* @memory allocated memory * @memory allocated memory
* @return status code * @return status code
*/ */
efi_status_t efi_allocate_pages(int type, int memory_type, efi_status_t efi_allocate_pages(enum efi_allocate_type type,
enum efi_memory_type memory_type,
efi_uintn_t pages, uint64_t *memory) efi_uintn_t pages, uint64_t *memory)
{ {
u64 len = pages << EFI_PAGE_SHIFT; u64 len = pages << EFI_PAGE_SHIFT;
@ -556,7 +557,7 @@ efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages)
* @buffer: allocated memory * @buffer: allocated memory
* Return: status code * Return: status code
*/ */
efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, void **buffer) efi_status_t efi_allocate_pool(enum efi_memory_type pool_type, efi_uintn_t size, void **buffer)
{ {
efi_status_t r; efi_status_t r;
u64 addr; u64 addr;