1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Headers for EFI variable service via StandAloneMM, EDK2 application running
6 * Copyright (c) 2017, Intel Corporation. All rights reserved.
7 * Copyright (C) 2020 Linaro Ltd. <sughosh.ganu@linaro.org>
8 * Copyright (C) 2020 Linaro Ltd. <ilias.apalodimas@linaro.org>
9 * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
11 * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
14 #ifndef _MM_COMMUNICATION_H_
15 #define _MM_COMMUNICATION_H_
19 /* MM service UUID string (big-endian format). This UUID is common across all MM SPs */
20 #define MM_SP_UUID "33d532ed-e699-0942-c09c-a798d9cd722d"
23 * Interface to the pseudo Trusted Application (TA), which provides a
24 * communication channel with the Standalone MM (Management Mode)
25 * Secure Partition running at Secure-EL0
28 #define PTA_STMM_CMDID_COMMUNICATE 0
30 /* OP-TEE is using big endian GUIDs while UEFI uses little endian ones */
31 #define PTA_STMM_UUID { 0xed32d533, 0x99e6, 0x4209, {\
32 0x9c, 0xc0, 0x2d, 0x72, 0xcd, 0xd9, 0x98, 0xa7 } }
34 #define EFI_MM_VARIABLE_GUID \
35 EFI_GUID(0xed32d533, 0x99e6, 0x4209, \
36 0x9c, 0xc0, 0x2d, 0x72, 0xcd, 0xd9, 0x98, 0xa7)
38 /* Defined in EDK2 MdePkg/Include/Protocol/MmCommunication.h */
41 * struct efi_mm_communicate_header - Header used for SMM variable communication
43 * @header_guid: header use for disambiguation of content
44 * @message_len: length of the message. Does not include the size of the
46 * @data: payload of the message
48 * Defined in EDK2 as EFI_MM_COMMUNICATE_HEADER.
49 * To avoid confusion in interpreting frames, the communication buffer should
50 * always begin with efi_mm_communicate_header.
52 struct __packed efi_mm_communicate_header {
53 efi_guid_t header_guid;
58 #define MM_COMMUNICATE_HEADER_SIZE \
59 (sizeof(struct efi_mm_communicate_header))
61 /* Defined in EDK2 ArmPkg/Include/IndustryStandard/ArmMmSvc.h */
63 /* SPM return error codes */
64 #define ARM_SVC_SPM_RET_SUCCESS 0
65 #define ARM_SVC_SPM_RET_NOT_SUPPORTED -1
66 #define ARM_SVC_SPM_RET_INVALID_PARAMS -2
67 #define ARM_SVC_SPM_RET_DENIED -3
68 #define ARM_SVC_SPM_RET_NO_MEMORY -5
70 /* Defined in EDK2 MdeModulePkg/Include/Guid/SmmVariableCommon.h */
72 #define SMM_VARIABLE_FUNCTION_GET_VARIABLE 1
74 * The payload for this function is
75 * SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME.
77 #define SMM_VARIABLE_FUNCTION_GET_NEXT_VARIABLE_NAME 2
79 * The payload for this function is SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE.
81 #define SMM_VARIABLE_FUNCTION_SET_VARIABLE 3
83 * The payload for this function is
84 * SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO.
86 #define SMM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO 4
88 * It is a notify event, no extra payload for this function.
90 #define SMM_VARIABLE_FUNCTION_READY_TO_BOOT 5
92 * It is a notify event, no extra payload for this function.
94 #define SMM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE 6
96 * The payload for this function is VARIABLE_INFO_ENTRY.
97 * The GUID in EFI_SMM_COMMUNICATE_HEADER is gEfiSmmVariableProtocolGuid.
99 #define SMM_VARIABLE_FUNCTION_GET_STATISTICS 7
101 * The payload for this function is SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE
103 #define SMM_VARIABLE_FUNCTION_LOCK_VARIABLE 8
105 #define SMM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_SET 9
107 #define SMM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_GET 10
109 #define SMM_VARIABLE_FUNCTION_GET_PAYLOAD_SIZE 11
111 * The payload for this function is
112 * SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT
114 #define SMM_VARIABLE_FUNCTION_INIT_RUNTIME_VARIABLE_CACHE_CONTEXT 12
116 #define SMM_VARIABLE_FUNCTION_SYNC_RUNTIME_CACHE 13
118 * The payload for this function is
119 * SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO
121 #define SMM_VARIABLE_FUNCTION_GET_RUNTIME_CACHE_INFO 14
124 * struct smm_variable_communicate_header - Used for SMM variable communication
126 * @function: function to call in Smm.
127 * @ret_status: return status
130 * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_HEADER.
132 struct smm_variable_communicate_header {
133 efi_uintn_t function;
134 efi_status_t ret_status;
138 #define MM_VARIABLE_COMMUNICATE_SIZE \
139 (sizeof(struct smm_variable_communicate_header))
142 * struct smm_variable_access - Used to communicate with StMM by
143 * SetVariable and GetVariable.
146 * @data_size: size of EFI variable data
147 * @name_size: size of EFI name
149 * @name: variable name
151 * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE.
154 struct smm_variable_access {
156 efi_uintn_t data_size;
157 efi_uintn_t name_size;
162 #define MM_VARIABLE_ACCESS_HEADER_SIZE \
163 (sizeof(struct smm_variable_access))
165 * struct smm_variable_payload_size - Used to get the max allowed
166 * payload used in StMM.
168 * @size: size to fill in
170 * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE.
173 struct smm_variable_payload_size {
178 * struct smm_variable_getnext - Used to communicate with StMM for
179 * GetNextVariableName.
182 * @name_size: size of the name of the variable
183 * @name: variable name
185 * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME.
187 struct smm_variable_getnext {
189 efi_uintn_t name_size;
193 #define MM_VARIABLE_GET_NEXT_HEADER_SIZE \
194 (sizeof(struct smm_variable_getnext))
197 * struct smm_variable_query_info - Used to communicate with StMM for
200 * @max_variable_storage: max available storage
201 * @remaining_variable_storage: remaining available storage
202 * @max_variable_size: max variable supported size
203 * @attr: attributes to query storage for
205 * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO.
207 struct smm_variable_query_info {
208 u64 max_variable_storage;
209 u64 remaining_variable_storage;
210 u64 max_variable_size;
214 #define VAR_CHECK_VARIABLE_PROPERTY_REVISION 0x0001
215 #define VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY BIT(0)
217 * struct var_check_property - Used to store variable properties in StMM
219 * @revision: magic revision number for variable property checking
220 * @property: properties mask for the variable used in StMM.
221 * Currently RO flag is supported
222 * @attributes: variable attributes used in StMM checking when properties
223 * for a variable are enabled
224 * @minsize: minimum allowed size for variable payload checked against
225 * smm_variable_access->datasize in StMM
226 * @maxsize: maximum allowed size for variable payload checked against
227 * smm_variable_access->datasize in StMM
229 * Defined in EDK2 as VAR_CHECK_VARIABLE_PROPERTY.
231 struct var_check_property {
240 * struct smm_variable_var_check_property - Used to communicate variable
241 * properties with StMM
244 * @name_size: size of EFI name
245 * @property: variable properties struct
246 * @name: variable name
248 * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_VAR_CHECK_VARIABLE_PROPERTY.
250 struct smm_variable_var_check_property {
252 efi_uintn_t name_size;
253 struct var_check_property property;
257 /* supported MM transports */
258 enum mm_comms_select {
264 #endif /* _MM_COMMUNICATION_H_ */