[PATCH 2/6] efi_loader: Add headers for EDK2 StandAloneMM communication

Ilias Apalodimas ilias.apalodimas at linaro.org
Wed May 6 21:12:42 CEST 2020


From: Sughosh Ganu <sughosh.ganu at linaro.org>

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 <sughosh.ganu at linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
---
 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. <sughosh.ganu at linaro.org>
+ *  Copyright (C) 2020 Linaro Ltd. <ilias.apalodimas at linaro.org>
+ */
+
+#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. <sughosh.ganu at linaro.org>
+ *  Copyright (C) 2020 Linaro Ltd. <ilias.apalodimas at linaro.org>
+ */
+
+#if !defined _MM_VARIABLE_H_
+#define _MM_VARIABLE_H_
+
+#include <part_efi.h>
+
+/* 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_ */
-- 
2.26.2



More information about the U-Boot mailing list