Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / firmware / efi / stmm / mm_communication.h
blob52a1f32cd1eb8d75198892a09a7faab72acbd90f
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3 * Headers for EFI variable service via StandAloneMM, EDK2 application running
4 * in OP-TEE. Most of the structs and defines resemble the EDK2 naming.
6 * Copyright (c) 2017, Intel Corporation. All rights reserved.
7 * Copyright (C) 2020 Linaro Ltd.
8 */
10 #ifndef _MM_COMMUNICATION_H_
11 #define _MM_COMMUNICATION_H_
14 * Interface to the pseudo Trusted Application (TA), which provides a
15 * communication channel with the Standalone MM (Management Mode)
16 * Secure Partition running at Secure-EL0
19 #define PTA_STMM_CMD_COMMUNICATE 0
22 * Defined in OP-TEE, this UUID is used to identify the pseudo-TA.
23 * OP-TEE is using big endian GUIDs while UEFI uses little endian ones
25 #define PTA_STMM_UUID \
26 UUID_INIT(0xed32d533, 0x99e6, 0x4209, \
27 0x9c, 0xc0, 0x2d, 0x72, 0xcd, 0xd9, 0x98, 0xa7)
29 #define EFI_MM_VARIABLE_GUID \
30 EFI_GUID(0xed32d533, 0x99e6, 0x4209, \
31 0x9c, 0xc0, 0x2d, 0x72, 0xcd, 0xd9, 0x98, 0xa7)
33 /**
34 * struct efi_mm_communicate_header - Header used for SMM variable communication
36 * @header_guid: header use for disambiguation of content
37 * @message_len: length of the message. Does not include the size of the
38 * header
39 * @data: payload of the message
41 * Defined in the PI spec as EFI_MM_COMMUNICATE_HEADER.
42 * To avoid confusion in interpreting frames, the communication buffer should
43 * always begin with efi_mm_communicate_header.
45 struct efi_mm_communicate_header {
46 efi_guid_t header_guid;
47 size_t message_len;
48 u8 data[];
49 } __packed;
51 #define MM_COMMUNICATE_HEADER_SIZE \
52 (sizeof(struct efi_mm_communicate_header))
54 /* SPM return error codes */
55 #define ARM_SVC_SPM_RET_SUCCESS 0
56 #define ARM_SVC_SPM_RET_NOT_SUPPORTED -1
57 #define ARM_SVC_SPM_RET_INVALID_PARAMS -2
58 #define ARM_SVC_SPM_RET_DENIED -3
59 #define ARM_SVC_SPM_RET_NO_MEMORY -5
61 #define SMM_VARIABLE_FUNCTION_GET_VARIABLE 1
63 * The payload for this function is
64 * SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME.
66 #define SMM_VARIABLE_FUNCTION_GET_NEXT_VARIABLE_NAME 2
68 * The payload for this function is SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE.
70 #define SMM_VARIABLE_FUNCTION_SET_VARIABLE 3
72 * The payload for this function is
73 * SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO.
75 #define SMM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO 4
77 * It is a notify event, no extra payload for this function.
79 #define SMM_VARIABLE_FUNCTION_READY_TO_BOOT 5
81 * It is a notify event, no extra payload for this function.
83 #define SMM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE 6
85 * The payload for this function is VARIABLE_INFO_ENTRY.
86 * The GUID in EFI_SMM_COMMUNICATE_HEADER is gEfiSmmVariableProtocolGuid.
88 #define SMM_VARIABLE_FUNCTION_GET_STATISTICS 7
90 * The payload for this function is SMM_VARIABLE_COMMUNICATE_LOCK_VARIABLE
92 #define SMM_VARIABLE_FUNCTION_LOCK_VARIABLE 8
94 #define SMM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_SET 9
96 #define SMM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_GET 10
98 #define SMM_VARIABLE_FUNCTION_GET_PAYLOAD_SIZE 11
100 * The payload for this function is
101 * SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT
103 #define SMM_VARIABLE_FUNCTION_INIT_RUNTIME_VARIABLE_CACHE_CONTEXT 12
105 #define SMM_VARIABLE_FUNCTION_SYNC_RUNTIME_CACHE 13
107 * The payload for this function is
108 * SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO
110 #define SMM_VARIABLE_FUNCTION_GET_RUNTIME_CACHE_INFO 14
113 * struct smm_variable_communicate_header - Used for SMM variable communication
115 * @function: function to call in Smm.
116 * @ret_status: return status
117 * @data: payload
119 struct smm_variable_communicate_header {
120 size_t function;
121 efi_status_t ret_status;
122 u8 data[];
125 #define MM_VARIABLE_COMMUNICATE_SIZE \
126 (sizeof(struct smm_variable_communicate_header))
129 * struct smm_variable_access - Used to communicate with StMM by
130 * SetVariable and GetVariable.
132 * @guid: vendor GUID
133 * @data_size: size of EFI variable data
134 * @name_size: size of EFI name
135 * @attr: attributes
136 * @name: variable name
139 struct smm_variable_access {
140 efi_guid_t guid;
141 size_t data_size;
142 size_t name_size;
143 u32 attr;
144 u16 name[];
147 #define MM_VARIABLE_ACCESS_HEADER_SIZE \
148 (sizeof(struct smm_variable_access))
150 * struct smm_variable_payload_size - Used to get the max allowed
151 * payload used in StMM.
153 * @size: size to fill in
156 struct smm_variable_payload_size {
157 size_t size;
161 * struct smm_variable_getnext - Used to communicate with StMM for
162 * GetNextVariableName.
164 * @guid: vendor GUID
165 * @name_size: size of the name of the variable
166 * @name: variable name
169 struct smm_variable_getnext {
170 efi_guid_t guid;
171 size_t name_size;
172 u16 name[];
175 #define MM_VARIABLE_GET_NEXT_HEADER_SIZE \
176 (sizeof(struct smm_variable_getnext))
179 * struct smm_variable_query_info - Used to communicate with StMM for
180 * QueryVariableInfo.
182 * @max_variable_storage: max available storage
183 * @remaining_variable_storage: remaining available storage
184 * @max_variable_size: max variable supported size
185 * @attr: attributes to query storage for
188 struct smm_variable_query_info {
189 u64 max_variable_storage;
190 u64 remaining_variable_storage;
191 u64 max_variable_size;
192 u32 attr;
195 #define VAR_CHECK_VARIABLE_PROPERTY_REVISION 0x0001
196 #define VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY BIT(0)
198 * struct var_check_property - Used to store variable properties in StMM
200 * @revision: magic revision number for variable property checking
201 * @property: properties mask for the variable used in StMM.
202 * Currently RO flag is supported
203 * @attributes: variable attributes used in StMM checking when properties
204 * for a variable are enabled
205 * @minsize: minimum allowed size for variable payload checked against
206 * smm_variable_access->datasize in StMM
207 * @maxsize: maximum allowed size for variable payload checked against
208 * smm_variable_access->datasize in StMM
211 struct var_check_property {
212 u16 revision;
213 u16 property;
214 u32 attributes;
215 size_t minsize;
216 size_t maxsize;
220 * struct smm_variable_var_check_property - Used to communicate variable
221 * properties with StMM
223 * @guid: vendor GUID
224 * @name_size: size of EFI name
225 * @property: variable properties struct
226 * @name: variable name
229 struct smm_variable_var_check_property {
230 efi_guid_t guid;
231 size_t name_size;
232 struct var_check_property property;
233 u16 name[];
236 #endif /* _MM_COMMUNICATION_H_ */