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 #if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT)
20 /* MM service UUID string (big-endian format). This UUID is common across all MM SPs */
21 #define MM_SP_UUID "33d532ed-e699-0942-c09c-a798d9cd722d"
25 * Interface to the pseudo Trusted Application (TA), which provides a
26 * communication channel with the Standalone MM (Management Mode)
27 * Secure Partition running at Secure-EL0
30 #define PTA_STMM_CMDID_COMMUNICATE 0
32 /* OP-TEE is using big endian GUIDs while UEFI uses little endian ones */
33 #define PTA_STMM_UUID { 0xed32d533, 0x99e6, 0x4209, {\
34 0x9c, 0xc0, 0x2d, 0x72, 0xcd, 0xd9, 0x98, 0xa7 } }
36 #define EFI_MM_VARIABLE_GUID \
37 EFI_GUID(0xed32d533, 0x99e6, 0x4209, \
38 0x9c, 0xc0, 0x2d, 0x72, 0xcd, 0xd9, 0x98, 0xa7)
40 /* Defined in EDK2 MdePkg/Include/Protocol/MmCommunication.h */
43 * struct efi_mm_communicate_header - Header used for SMM variable communication
45 * @header_guid: header use for disambiguation of content
46 * @message_len: length of the message. Does not include the size of the
48 * @data: payload of the message
50 * Defined in EDK2 as EFI_MM_COMMUNICATE_HEADER.
51 * To avoid confusion in interpreting frames, the communication buffer should
52 * always begin with efi_mm_communicate_header.
54 struct __packed efi_mm_communicate_header {
55 efi_guid_t header_guid;
60 #define MM_COMMUNICATE_HEADER_SIZE \
61 (sizeof(struct efi_mm_communicate_header))
63 /* Defined in EDK2 ArmPkg/Include/IndustryStandard/ArmMmSvc.h */
65 /* SPM return error codes */
66 #define ARM_SVC_SPM_RET_SUCCESS 0
67 #define ARM_SVC_SPM_RET_NOT_SUPPORTED -1
68 #define ARM_SVC_SPM_RET_INVALID_PARAMS -2
69 #define ARM_SVC_SPM_RET_DENIED -3
70 #define ARM_SVC_SPM_RET_NO_MEMORY -5
72 /* Defined in EDK2 MdeModulePkg/Include/Guid/SmmVariableCommon.h */
74 #define SMM_VARIABLE_FUNCTION_GET_VARIABLE 1
76 * The payload for this function is
77 * SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME.
79 #define SMM_VARIABLE_FUNCTION_GET_NEXT_VARIABLE_NAME 2
81 * The payload for this function is SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE.
83 #define SMM_VARIABLE_FUNCTION_SET_VARIABLE 3
85 * The payload for this function is
86 * SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO.
88 #define SMM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO 4
90 * It is a notify event, no extra payload for this function.
92 #define SMM_VARIABLE_FUNCTION_READY_TO_BOOT 5
94 * It is a notify event, no extra payload for this function.
96 #define SMM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE 6
98 * The payload for this function is VARIABLE_INFO_ENTRY.
99 * The GUID in EFI_SMM_COMMUNICATE_HEADER is gEfiSmmVariableProtocolGuid.
101 #define SMM_VARIABLE_FUNCTION_GET_STATISTICS 7
103 * The payload for this function is SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE
105 #define SMM_VARIABLE_FUNCTION_LOCK_VARIABLE 8
107 #define SMM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_SET 9
109 #define SMM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_GET 10
111 #define SMM_VARIABLE_FUNCTION_GET_PAYLOAD_SIZE 11
113 * The payload for this function is
114 * SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT
116 #define SMM_VARIABLE_FUNCTION_INIT_RUNTIME_VARIABLE_CACHE_CONTEXT 12
118 #define SMM_VARIABLE_FUNCTION_SYNC_RUNTIME_CACHE 13
120 * The payload for this function is
121 * SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO
123 #define SMM_VARIABLE_FUNCTION_GET_RUNTIME_CACHE_INFO 14
126 * struct smm_variable_communicate_header - Used for SMM variable communication
128 * @function: function to call in Smm.
129 * @ret_status: return status
132 * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_HEADER.
134 struct smm_variable_communicate_header {
135 efi_uintn_t function;
136 efi_status_t ret_status;
140 #define MM_VARIABLE_COMMUNICATE_SIZE \
141 (sizeof(struct smm_variable_communicate_header))
144 * struct smm_variable_access - Used to communicate with StMM by
145 * SetVariable and GetVariable.
148 * @data_size: size of EFI variable data
149 * @name_size: size of EFI name
151 * @name: variable name
153 * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE.
156 struct smm_variable_access {
158 efi_uintn_t data_size;
159 efi_uintn_t name_size;
164 #define MM_VARIABLE_ACCESS_HEADER_SIZE \
165 (sizeof(struct smm_variable_access))
167 * struct smm_variable_payload_size - Used to get the max allowed
168 * payload used in StMM.
170 * @size: size to fill in
172 * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE.
175 struct smm_variable_payload_size {
180 * struct smm_variable_getnext - Used to communicate with StMM for
181 * GetNextVariableName.
184 * @name_size: size of the name of the variable
185 * @name: variable name
187 * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME.
189 struct smm_variable_getnext {
191 efi_uintn_t name_size;
195 #define MM_VARIABLE_GET_NEXT_HEADER_SIZE \
196 (sizeof(struct smm_variable_getnext))
199 * struct smm_variable_query_info - Used to communicate with StMM for
202 * @max_variable_storage: max available storage
203 * @remaining_variable_storage: remaining available storage
204 * @max_variable_size: max variable supported size
205 * @attr: attributes to query storage for
207 * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO.
209 struct smm_variable_query_info {
210 u64 max_variable_storage;
211 u64 remaining_variable_storage;
212 u64 max_variable_size;
216 #define VAR_CHECK_VARIABLE_PROPERTY_REVISION 0x0001
217 #define VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY BIT(0)
219 * struct var_check_property - Used to store variable properties in StMM
221 * @revision: magic revision number for variable property checking
222 * @property: properties mask for the variable used in StMM.
223 * Currently RO flag is supported
224 * @attributes: variable attributes used in StMM checking when properties
225 * for a variable are enabled
226 * @minsize: minimum allowed size for variable payload checked against
227 * smm_variable_access->datasize in StMM
228 * @maxsize: maximum allowed size for variable payload checked against
229 * smm_variable_access->datasize in StMM
231 * Defined in EDK2 as VAR_CHECK_VARIABLE_PROPERTY.
233 struct var_check_property {
242 * struct smm_variable_var_check_property - Used to communicate variable
243 * properties with StMM
246 * @name_size: size of EFI name
247 * @property: variable properties struct
248 * @name: variable name
250 * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_VAR_CHECK_VARIABLE_PROPERTY.
252 struct smm_variable_var_check_property {
254 efi_uintn_t name_size;
255 struct var_check_property property;
259 #if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT)
260 /* supported MM transports */
261 enum mm_comms_select {
268 #endif /* _MM_COMMUNICATION_H_ */