From patchwork Wed May 6 19:12:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 245216 List-Id: U-Boot discussion From: ilias.apalodimas at linaro.org (Ilias Apalodimas) Date: Wed, 6 May 2020 22:12:42 +0300 Subject: [PATCH 2/6] efi_loader: Add headers for EDK2 StandAloneMM communication In-Reply-To: <20200506191246.237790-1-ilias.apalodimas@linaro.org> References: <20200506191246.237790-1-ilias.apalodimas@linaro.org> Message-ID: <20200506191246.237790-3-ilias.apalodimas@linaro.org> From: Sughosh Ganu In Arm devices OP-TEE has the ability to run StandAloneMM (from EDK2) in a separate partition and handle UEFI variables. A following patch introduces this functionality. Add the headers needed for OP-TEE <--> StandAloneMM communication Signed-off-by: Sughosh Ganu Signed-off-by: Ilias Apalodimas --- include/mm_communication.h | 28 ++++++++++++++ include/mm_variable.h | 78 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 include/mm_communication.h create mode 100644 include/mm_variable.h diff --git a/include/mm_communication.h b/include/mm_communication.h new file mode 100644 index 000000000000..fb4c91103400 --- /dev/null +++ b/include/mm_communication.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Headers for EFI variable service via StandAloneMM, EDK2 application running + * in OP-TEE + * + * Copyright (C) 2020 Linaro Ltd. + * Copyright (C) 2020 Linaro Ltd. + */ + +#if !defined _MM_COMMUNICATION_H_ +#define _MM_COMMUNICATION_H_ + +/* defined in EDK2 MmCommunication.h */ +struct mm_communicate_header { + efi_guid_t header_guid; + size_t message_len; + u8 data[1]; +}; + +#define MM_COMMUNICATE_HEADER_SIZE \ + (offsetof(struct mm_communicate_header, data)) + +#define MM_RET_SUCCESS 0 +#define MM_RET_INVALID_PARAMS -2 +#define MM_RET_DENIED -3 +#define MM_RET_NO_MEMORY -4 + +#endif /* _MM_COMMUNICATION_H_*/ diff --git a/include/mm_variable.h b/include/mm_variable.h new file mode 100644 index 000000000000..f56c52597629 --- /dev/null +++ b/include/mm_variable.h @@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Headers for EFI variable service via StandAloneMM, EDK2 application running + * in OP-TEE + * + * Copyright (C) 2020 Linaro Ltd. + * Copyright (C) 2020 Linaro Ltd. + */ + +#if !defined _MM_VARIABLE_H_ +#define _MM_VARIABLE_H_ + +#include + +/* defined in EDK2 SmmVariableCommon.h */ +struct mm_variable_communicate_header { + efi_uintn_t function; + efi_status_t ret_status; + u8 data[1]; +}; + +#define MM_VARIABLE_COMMUNICATE_SIZE \ + (offsetof(struct mm_variable_communicate_header, data)) + +#define MM_VARIABLE_FUNCTION_GET_VARIABLE 1 + +#define MM_VARIABLE_FUNCTION_GET_NEXT_VARIABLE_NAME 2 + +#define MM_VARIABLE_FUNCTION_SET_VARIABLE 3 + +#define MM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO 4 + +#define MM_VARIABLE_FUNCTION_READY_TO_BOOT 5 + +#define MM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE 6 + +#define MM_VARIABLE_FUNCTION_GET_STATISTICS 7 + +#define MM_VARIABLE_FUNCTION_LOCK_VARIABLE 8 + +#define MM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_SET 9 + +#define MM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_GET 10 + +#define MM_VARIABLE_FUNCTION_GET_PAYLOAD_SIZE 11 + +struct mm_variable_access { + efi_guid_t guid; + efi_uintn_t data_size; + efi_uintn_t name_size; + u32 attr; + u16 name[1]; +}; + +#define MM_VARIABLE_ACCESS_HEADER_SIZE \ + (offsetof(struct mm_variable_access, name)) + +struct mm_variable_payload_size { + efi_uintn_t size; +}; + +struct mm_variable_getnext { + efi_guid_t guid; + efi_uintn_t name_size; + u16 name[1]; +}; + +#define MM_VARIABLE_GET_NEXT_HEADER_SIZE \ + (offsetof(struct mm_variable_getnext, name)) + +struct mm_variable_query_info { + u64 max_variable_storage; + u64 remaining_variable_storage; + u64 max_variable_size; + u32 attr; +}; + +#endif /* _MM_VARIABLE_H_ */