]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Pi/PiMmCis.h
MdePkg: Add new definitions for Management Mode.
[mirror_edk2.git] / MdePkg / Include / Pi / PiMmCis.h
1 /** @file
2 Common definitions in the Platform Initialization Specification version 1.5
3 VOLUME 4 Management Mode Core Interface version.
4
5 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef _PI_MMCIS_H_
17 #define _PI_MMCIS_H_
18
19 #include <Protocol/MmCpuIo.h>
20
21 typedef struct _EFI_MM_SYSTEM_TABLE EFI_MM_SYSTEM_TABLE;
22
23 ///
24 /// The Management Mode System Table (MMST) signature
25 ///
26 #define MM_MMST_SIGNATURE SIGNATURE_32 ('S', 'M', 'S', 'T')
27 ///
28 /// The Management Mode System Table (MMST) revision is 1.6
29 ///
30 #define MM_SPECIFICATION_MAJOR_REVISION 1
31 #define MM_SPECIFICATION_MINOR_REVISION 60
32 #define EFI_MM_SYSTEM_TABLE_REVISION ((MM_SPECIFICATION_MAJOR_REVISION<<16) | (MM_SPECIFICATION_MINOR_REVISION))
33
34 /**
35 Adds, updates, or removes a configuration table entry from the Management Mode System Table.
36
37 The MmInstallConfigurationTable() function is used to maintain the list
38 of configuration tables that are stored in the Management Mode System
39 Table. The list is stored as an array of (GUID, Pointer) pairs. The list
40 must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.
41
42 @param[in] SystemTable A pointer to the MM System Table (MMST).
43 @param[in] Guid A pointer to the GUID for the entry to add, update, or remove.
44 @param[in] Table A pointer to the buffer of the table to add.
45 @param[in] TableSize The size of the table to install.
46
47 @retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed.
48 @retval EFI_INVALID_PARAMETER Guid is not valid.
49 @retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry.
50 @retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation.
51 **/
52 typedef
53 EFI_STATUS
54 (EFIAPI *EFI_MM_INSTALL_CONFIGURATION_TABLE)(
55 IN CONST EFI_MM_SYSTEM_TABLE *SystemTable,
56 IN CONST EFI_GUID *Guid,
57 IN VOID *Table,
58 IN UINTN TableSize
59 );
60
61 /**
62 This service lets the caller to get one distinct application processor (AP) to execute
63 a caller-provided code stream while in MM.
64
65 @param[in] Procedure A pointer to the code stream to be run on the designated
66 AP of the system.
67 @param[in] CpuNumber The zero-based index of the processor number of the AP
68 on which the code stream is supposed to run.
69 @param[in,out] ProcArguments Allows the caller to pass a list of parameters to the code
70 that is run by the AP.
71
72 @retval EFI_SUCCESS The call was successful and the return parameters are valid.
73 @retval EFI_INVALID_PARAMETER The input arguments are out of range.
74 @retval EFI_INVALID_PARAMETER The CPU requested is not available on this SMI invocation.
75 @retval EFI_INVALID_PARAMETER The CPU cannot support an additional service invocation.
76 **/
77 typedef
78 EFI_STATUS
79 (EFIAPI *EFI_MM_STARTUP_THIS_AP)(
80 IN EFI_AP_PROCEDURE Procedure,
81 IN UINTN CpuNumber,
82 IN OUT VOID *ProcArguments OPTIONAL
83 );
84
85 /**
86 Function prototype for protocol install notification.
87
88 @param[in] Protocol Points to the protocol's unique identifier.
89 @param[in] Interface Points to the interface instance.
90 @param[in] Handle The handle on which the interface was installed.
91
92 @return Status Code
93 **/
94 typedef
95 EFI_STATUS
96 (EFIAPI *EFI_MM_NOTIFY_FN)(
97 IN CONST EFI_GUID *Protocol,
98 IN VOID *Interface,
99 IN EFI_HANDLE Handle
100 );
101
102 /**
103 Register a callback function be called when a particular protocol interface is installed.
104
105 The MmRegisterProtocolNotify() function creates a registration Function that is to be
106 called whenever a protocol interface is installed for Protocol by
107 MmInstallProtocolInterface().
108 If Function == NULL and Registration is an existing registration, then the callback is unhooked.
109
110 @param[in] Protocol The unique ID of the protocol for which the event is to be registered.
111 @param[in] Function Points to the notification function.
112 @param[out] Registration A pointer to a memory location to receive the registration value.
113
114 @retval EFI_SUCCESS Successfully returned the registration record
115 that has been added or unhooked.
116 @retval EFI_INVALID_PARAMETER Protocol is NULL or Registration is NULL.
117 @retval EFI_OUT_OF_RESOURCES Not enough memory resource to finish the request.
118 @retval EFI_NOT_FOUND If the registration is not found when Function == NULL.
119 **/
120 typedef
121 EFI_STATUS
122 (EFIAPI *EFI_MM_REGISTER_PROTOCOL_NOTIFY)(
123 IN CONST EFI_GUID *Protocol,
124 IN EFI_MM_NOTIFY_FN Function,
125 OUT VOID **Registration
126 );
127
128 /**
129 Manage MMI of a particular type.
130
131 @param[in] HandlerType Points to the handler type or NULL for root MMI handlers.
132 @param[in] Context Points to an optional context buffer.
133 @param[in,out] CommBuffer Points to the optional communication buffer.
134 @param[in,out] CommBufferSize Points to the size of the optional communication buffer.
135
136 @retval EFI_WARN_INTERRUPT_SOURCE_PENDING Interrupt source was processed successfully but not quiesced.
137 @retval EFI_INTERRUPT_PENDING One or more SMI sources could not be quiesced.
138 @retval EFI_NOT_FOUND Interrupt source was not handled or quiesced.
139 @retval EFI_SUCCESS Interrupt source was handled and quiesced.
140 **/
141 typedef
142 EFI_STATUS
143 (EFIAPI *EFI_MM_INTERRUPT_MANAGE)(
144 IN CONST EFI_GUID *HandlerType,
145 IN CONST VOID *Context OPTIONAL,
146 IN OUT VOID *CommBuffer OPTIONAL,
147 IN OUT UINTN *CommBufferSize OPTIONAL
148 );
149
150 /**
151 Main entry point for an MM handler dispatch or communicate-based callback.
152
153 @param[in] DispatchHandle The unique handle assigned to this handler by MmiHandlerRegister().
154 @param[in] Context Points to an optional handler context which was specified when the
155 handler was registered.
156 @param[in,out] CommBuffer A pointer to a collection of data in memory that will
157 be conveyed from a non-MM environment into an MM environment.
158 @param[in,out] CommBufferSize The size of the CommBuffer.
159
160 @retval EFI_SUCCESS The interrupt was handled and quiesced. No other handlers
161 should still be called.
162 @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED The interrupt has been quiesced but other handlers should
163 still be called.
164 @retval EFI_WARN_INTERRUPT_SOURCE_PENDING The interrupt is still pending and other handlers should still
165 be called.
166 @retval EFI_INTERRUPT_PENDING The interrupt could not be quiesced.
167 **/
168 typedef
169 EFI_STATUS
170 (EFIAPI *EFI_MM_HANDLER_ENTRY_POINT)(
171 IN EFI_HANDLE DispatchHandle,
172 IN CONST VOID *Context OPTIONAL,
173 IN OUT VOID *CommBuffer OPTIONAL,
174 IN OUT UINTN *CommBufferSize OPTIONAL
175 );
176
177 /**
178 Registers a handler to execute within MM.
179
180 @param[in] Handler Handler service function pointer.
181 @param[in] HandlerType Points to the handler type or NULL for root MMI handlers.
182 @param[out] DispatchHandle On return, contains a unique handle which can be used to later
183 unregister the handler function.
184
185 @retval EFI_SUCCESS MMI handler added successfully.
186 @retval EFI_INVALID_PARAMETER Handler is NULL or DispatchHandle is NULL.
187 **/
188 typedef
189 EFI_STATUS
190 (EFIAPI *EFI_MM_INTERRUPT_REGISTER)(
191 IN EFI_MM_HANDLER_ENTRY_POINT Handler,
192 IN CONST EFI_GUID *HandlerType OPTIONAL,
193 OUT EFI_HANDLE *DispatchHandle
194 );
195
196 /**
197 Unregister a handler in MM.
198
199 @param[in] DispatchHandle The handle that was specified when the handler was registered.
200
201 @retval EFI_SUCCESS Handler function was successfully unregistered.
202 @retval EFI_INVALID_PARAMETER DispatchHandle does not refer to a valid handle.
203 **/
204 typedef
205 EFI_STATUS
206 (EFIAPI *EFI_MM_INTERRUPT_UNREGISTER)(
207 IN EFI_HANDLE DispatchHandle
208 );
209
210 ///
211 /// Processor information and functionality needed by MM Foundation.
212 ///
213 typedef struct _EFI_MM_ENTRY_CONTEXT {
214 EFI_MM_STARTUP_THIS_AP MmStartupThisAp;
215 ///
216 /// A number between zero and the NumberOfCpus field. This field designates which
217 /// processor is executing the MM Foundation.
218 ///
219 UINTN CurrentlyExecutingCpu;
220 ///
221 /// The number of possible processors in the platform. This is a 1 based
222 /// counter. This does not indicate the number of processors that entered MM.
223 ///
224 UINTN NumberOfCpus;
225 ///
226 /// Points to an array, where each element describes the number of bytes in the
227 /// corresponding save state specified by CpuSaveState. There are always
228 /// NumberOfCpus entries in the array.
229 ///
230 UINTN *CpuSaveStateSize;
231 ///
232 /// Points to an array, where each element is a pointer to a CPU save state. The
233 /// corresponding element in CpuSaveStateSize specifies the number of bytes in the
234 /// save state area. There are always NumberOfCpus entries in the array.
235 ///
236 VOID **CpuSaveState;
237 } EFI_MM_ENTRY_CONTEXT;
238
239 /**
240 This function is the main entry point to the MM Foundation.
241
242 @param[in] MmEntryContext Processor information and functionality needed by MM Foundation.
243 **/
244 typedef
245 VOID
246 (EFIAPI *EFI_MM_ENTRY_POINT)(
247 IN CONST EFI_MM_ENTRY_CONTEXT *MmEntryContext
248 );
249
250 ///
251 /// Management Mode System Table (MMST)
252 ///
253 /// The Management Mode System Table (MMST) is a table that contains a collection of common
254 /// services for managing MMRAM allocation and providing basic I/O services. These services are
255 /// intended for both preboot and runtime usage.
256 ///
257 struct _EFI_MM_SYSTEM_TABLE {
258 ///
259 /// The table header for the SMST.
260 ///
261 EFI_TABLE_HEADER Hdr;
262 ///
263 /// A pointer to a NULL-terminated Unicode string containing the vendor name.
264 /// It is permissible for this pointer to be NULL.
265 ///
266 CHAR16 *MmFirmwareVendor;
267 ///
268 /// The particular revision of the firmware.
269 ///
270 UINT32 MmFirmwareRevision;
271
272 EFI_MM_INSTALL_CONFIGURATION_TABLE MmInstallConfigurationTable;
273
274 ///
275 /// I/O Service
276 ///
277 EFI_MM_CPU_IO_PROTOCOL MmIo;
278
279 ///
280 /// Runtime memory services
281 ///
282 EFI_ALLOCATE_POOL MmAllocatePool;
283 EFI_FREE_POOL MmFreePool;
284 EFI_ALLOCATE_PAGES MmAllocatePages;
285 EFI_FREE_PAGES MmFreePages;
286
287 ///
288 /// MP service
289 ///
290 EFI_MM_STARTUP_THIS_AP MmStartupThisAp;
291
292 ///
293 /// CPU information records
294 ///
295
296 ///
297 /// A number between zero and and the NumberOfCpus field. This field designates
298 /// which processor is executing the MM infrastructure.
299 ///
300 UINTN CurrentlyExecutingCpu;
301 ///
302 /// The number of possible processors in the platform. This is a 1 based counter.
303 ///
304 UINTN NumberOfCpus;
305 ///
306 /// Points to an array, where each element describes the number of bytes in the
307 /// corresponding save state specified by CpuSaveState. There are always
308 /// NumberOfCpus entries in the array.
309 ///
310 UINTN *CpuSaveStateSize;
311 ///
312 /// Points to an array, where each element is a pointer to a CPU save state. The
313 /// corresponding element in CpuSaveStateSize specifies the number of bytes in the
314 /// save state area. There are always NumberOfCpus entries in the array.
315 ///
316 VOID **CpuSaveState;
317
318 ///
319 /// Extensibility table
320 ///
321
322 ///
323 /// The number of UEFI Configuration Tables in the buffer MmConfigurationTable.
324 ///
325 UINTN NumberOfTableEntries;
326 ///
327 /// A pointer to the UEFI Configuration Tables. The number of entries in the table is
328 /// NumberOfTableEntries.
329 ///
330 EFI_CONFIGURATION_TABLE *MmConfigurationTable;
331
332 ///
333 /// Protocol services
334 ///
335 EFI_INSTALL_PROTOCOL_INTERFACE MmInstallProtocolInterface;
336 EFI_UNINSTALL_PROTOCOL_INTERFACE MmUninstallProtocolInterface;
337 EFI_HANDLE_PROTOCOL MmHandleProtocol;
338 EFI_MM_REGISTER_PROTOCOL_NOTIFY MmRegisterProtocolNotify;
339 EFI_LOCATE_HANDLE MmLocateHandle;
340 EFI_LOCATE_PROTOCOL MmLocateProtocol;
341
342 ///
343 /// MMI Management functions
344 ///
345 EFI_MM_INTERRUPT_MANAGE MmiManage;
346 EFI_MM_INTERRUPT_REGISTER MmiHandlerRegister;
347 EFI_MM_INTERRUPT_UNREGISTER MmiHandlerUnRegister;
348 };
349
350 #endif