]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Pi/PiSmmCis.h
MdePkg: Move duplicate EFI_AP_PROCEDURE typedef to a common location
[mirror_edk2.git] / MdePkg / Include / Pi / PiSmmCis.h
1 /** @file
2 Common definitions in the Platform Initialization Specification version 1.2
3 VOLUME 4 System Management Mode Core Interface version.
4
5 Copyright (c) 2009, Intel Corporation
6 All rights reserved. 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_SMMCIS_H_
17 #define _PI_SMMCIS_H_
18
19 #include <Pi/PiMultiPhase.h>
20 #include <Protocol/SmmCpuIo.h>
21
22 ///
23 /// Note:
24 /// To avoid name conflict between PI and Framework SMM spec, the following names defined
25 /// in PI 1.2 SMM spec are renamed. These renamings are not yet in a public PI spec and errta.
26 ///
27 /// EFI_SMM_SYSTEM_TABLE -> EFI_SMM_SYSTEM_TABLE2
28 /// EFI_SMM_SYSTEM_TABLE_REVISION -> EFI_SMM_SYSTEM_TABLE2_REVISION
29 /// EFI_SMM_INSTALL_CONFIGURATION_TABLE -> EFI_SMM_INSTALL_CONFIGURATION_TABLE2
30 ///
31
32 typedef struct _EFI_SMM_SYSTEM_TABLE2 EFI_SMM_SYSTEM_TABLE2;
33
34 ///
35 /// The System Management System Table (SMST) signature
36 ///
37 #define SMM_SMST_SIGNATURE SIGNATURE_32 ('S', 'M', 'S', 'T')
38 ///
39 /// The System Management System Table (SMST) revision is 1.0
40 ///
41 #define EFI_SMM_SYSTEM_TABLE2_REVISION ((1 << 16) | (0x00))
42
43 /**
44 Adds, updates, or removes a configuration table entry from the System Management System Table.
45
46 The SmmInstallConfigurationTable() function is used to maintain the list
47 of configuration tables that are stored in the System Management System
48 Table. The list is stored as an array of (GUID, Pointer) pairs. The list
49 must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.
50
51 @param[in] SystemTable A pointer to the SMM System Table (SMST).
52 @param[in] Guid A pointer to the GUID for the entry to add, update, or remove.
53 @param[in] Table A pointer to the buffer of the table to add.
54 @param[in] TableSize The size of the table to install.
55
56 @retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed.
57 @retval EFI_INVALID_PARAMETER Guid is not valid.
58 @retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry.
59 @retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation.
60 **/
61 typedef
62 EFI_STATUS
63 (EFIAPI *EFI_SMM_INSTALL_CONFIGURATION_TABLE2)(
64 IN CONST EFI_SMM_SYSTEM_TABLE2 *SystemTable,
65 IN CONST EFI_GUID *Guid,
66 IN VOID *Table,
67 IN UINTN TableSize
68 );
69
70 /**
71 The SmmStartupThisAp() lets the caller to get one distinct application processor
72 (AP) in the enabled processor pool to execute a caller-provided code stream
73 while in SMM. It runs the given code on this processor and reports the status.
74 It must be noted that the supplied code stream will be run only on an enabled
75 processor which has also entered SMM.
76
77 @param[in] Procedure A pointer to the code stream to be run on the designated AP of the system.
78 @param[in] CpuNumber The zero-based index of the processor number of the AP on which the code stream is supposed to run.
79 @param[in,out] ProcArguments Allow the caller to pass a list of parameters to the code that is run by the AP.
80
81 @retval EFI_SUCCESS The call was successful and the return parameters are valid.
82 @retval EFI_INVALID_PARAMETER The input arguments are out of range.
83 @retval EFI_INVALID_PARAMETER The CPU requested is not available on this SMI invocation.
84 @retval EFI_INVALID_PARAMETER The CPU cannot support an additional service invocation.
85 **/
86 typedef
87 EFI_STATUS
88 (EFIAPI *EFI_SMM_STARTUP_THIS_AP)(
89 IN EFI_AP_PROCEDURE Procedure,
90 IN UINTN CpuNumber,
91 IN OUT VOID *ProcArguments OPTIONAL
92 );
93
94 /**
95 Function prototype for protocol install notification.
96
97 @param[in] Protocol Points to the protocol's unique identifier.
98 @param[in] Interface Points to the interface instance.
99 @param[in] Handle The handle on which the interface was installed.
100
101 @return Status Code
102 **/
103 typedef
104 EFI_STATUS
105 (EFIAPI *EFI_SMM_NOTIFY_FN)(
106 IN CONST EFI_GUID *Protocol,
107 IN VOID *Interface,
108 IN EFI_HANDLE Handle
109 );
110
111 /**
112 Register a callback function be called when a particular protocol interface is installed.
113
114 The SmmRegisterProtocolNotify() function creates a registration Function that is to be
115 called whenever a protocol interface is installed for Protocol by
116 SmmInstallProtocolInterface().
117
118 @param[in] Protocol The unique ID of the protocol for which the event is to be registered.
119 @param[in] Function Points to the notification function.
120 @param[out] Registration A pointer to a memory location to receive the registration value.
121
122 @retval EFI_SUCCESS Successfully returned the registration record that has been added.
123 @retval EFI_INVALID_PARAMETER One or more of Protocol, Function and Registration is NULL.
124 @retval EFI_OUT_OF_RESOURCES Not enough memory resource to finish the request.
125 **/
126 typedef
127 EFI_STATUS
128 (EFIAPI *EFI_SMM_REGISTER_PROTOCOL_NOTIFY)(
129 IN CONST EFI_GUID *Protocol,
130 IN EFI_SMM_NOTIFY_FN Function,
131 OUT VOID **Registration
132 );
133
134 /**
135 Manage SMI of a particular type.
136
137 @param[in] HandlerType Points to the handler type or NULL for root SMI handlers.
138 @param[in] Context Points to an optional context buffer.
139 @param[in,out] CommBuffer Points to the optional communication buffer.
140 @param[in,out] CommBufferSize Points to the size of the optional communication buffer.
141
142 @retval EFI_SUCCESS Interrupt source was processed successfully but not quiesced.
143 @retval EFI_INTERRUPT_PENDING One or more SMI sources could not be quiesced.
144 @retval EFI_WARN_INTERRUPT_SOURCE_PENDING Interrupt source was not handled or quiesced.
145 @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED Interrupt source was handled and quiesced.
146 **/
147 typedef
148 EFI_STATUS
149 (EFIAPI *EFI_SMM_INTERRUPT_MANAGE)(
150 IN CONST EFI_GUID *HandlerType,
151 IN CONST VOID *Context OPTIONAL,
152 IN OUT VOID *CommBuffer OPTIONAL,
153 IN OUT UINTN *CommBufferSize OPTIONAL
154 );
155
156 /**
157 Main entry point for an SMM handler dispatch or communicate-based callback.
158
159 @param[in] DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
160 @param[in] Context Points to an optional handler context which was specified when the
161 handler was registered.
162 @param[in,out] CommBuffer A pointer to a collection of data in memory that will
163 be conveyed from a non-SMM environment into an SMM environment.
164 @param[in,out] CommBufferSize The size of the CommBuffer.
165
166 @retval EFI_SUCCESS The interrupt was handled and quiesced. No other handlers
167 should still be called.
168 @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED The interrupt has been quiesced but other handlers should
169 still be called.
170 @retval EFI_WARN_INTERRUPT_SOURCE_PENDING The interrupt is still pending and other handlers should still
171 be called.
172 @retval EFI_INTERRUPT_PENDING The interrupt could not be quiesced.
173 **/
174 typedef
175 EFI_STATUS
176 (EFIAPI *EFI_SMM_HANDLER_ENTRY_POINT2)(
177 IN EFI_HANDLE DispatchHandle,
178 IN CONST VOID *Context OPTIONAL,
179 IN OUT VOID *CommBuffer OPTIONAL,
180 IN OUT UINTN *CommBufferSize OPTIONAL
181 );
182
183 /**
184 Registers a handler to execute within SMM.
185
186 @param[in] Handler Handler service funtion pointer.
187 @param[in] HandlerType Points to the handler type or NULL for root SMI handlers.
188 @param[out] DispatchHandle On return, contains a unique handle which can be used to later
189 unregister the handler function.
190
191 @retval EFI_SUCCESS SMI handler added successfully.
192 @retval EFI_INVALID_PARAMETER Handler is NULL or DispatchHandle is NULL.
193 **/
194 typedef
195 EFI_STATUS
196 (EFIAPI *EFI_SMM_INTERRUPT_REGISTER)(
197 IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
198 IN CONST EFI_GUID *HandlerType OPTIONAL,
199 OUT EFI_HANDLE *DispatchHandle
200 );
201
202 /**
203 Unregister a handler in SMM.
204
205 @param[in] DispatchHandle The handle that was specified when the handler was registered.
206
207 @retval EFI_SUCCESS Handler function was successfully unregistered.
208 @retval EFI_INVALID_PARAMETER DispatchHandle does not refer to a valid handle.
209 **/
210 typedef
211 EFI_STATUS
212 (EFIAPI *EFI_SMM_INTERRUPT_UNREGISTER)(
213 IN EFI_HANDLE DispatchHandle
214 );
215
216 ///
217 /// Processor information and functionality needed by SMM Foundation.
218 ///
219 typedef struct _EFI_SMM_ENTRY_CONTEXT {
220 EFI_SMM_STARTUP_THIS_AP SmmStartupThisAp;
221 ///
222 /// A number between zero and the NumberOfCpus field. This field designates which
223 /// processor is executing the SMM Foundation.
224 ///
225 UINTN CurrentlyExecutingCpu;
226 ///
227 /// The number of current operational processors in the platform. This is a 1 based
228 /// counter. This does not indicate the number of processors that entered SMM.
229 ///
230 UINTN NumberOfCpus;
231 ///
232 /// Points to an array, where each element describes the number of bytes in the
233 /// corresponding save state specified by CpuSaveState. There are always
234 /// NumberOfCpus entries in the array.
235 ///
236 UINTN *CpuSaveStateSize;
237 ///
238 /// Points to an array, where each element is a pointer to a CPU save state. The
239 /// corresponding element in CpuSaveStateSize specifies the number of bytes in the
240 /// save state area. There are always NumberOfCpus entries in the array.
241 ///
242 VOID **CpuSaveState;
243 } EFI_SMM_ENTRY_CONTEXT;
244
245 /**
246 This function is the main entry point to the SMM Foundation.
247
248 @param[in] SmmEntryContext Processor information and functionality needed by SMM Foundation.
249 **/
250 typedef
251 VOID
252 (EFIAPI *EFI_SMM_ENTRY_POINT)(
253 IN CONST EFI_SMM_ENTRY_CONTEXT *SmmEntryContext
254 );
255
256 ///
257 /// System Management System Table (SMST)
258 ///
259 /// The System Management System Table (SMST) is a table that contains a collection of common
260 /// services for managing SMRAM allocation and providing basic I/O services. These services are
261 /// intended for both preboot and runtime usage.
262 ///
263 struct _EFI_SMM_SYSTEM_TABLE2 {
264 ///
265 /// The table header for the SMST.
266 ///
267 EFI_TABLE_HEADER Hdr;
268 ///
269 /// A pointer to a NULL-terminated Unicode string containing the vendor name.
270 /// It is permissible for this pointer to be NULL.
271 ///
272 CHAR16 *SmmFirmwareVendor;
273 ///
274 /// The particular revision of the firmware.
275 ///
276 UINT32 SmmFirmwareRevision;
277
278 EFI_SMM_INSTALL_CONFIGURATION_TABLE2 SmmInstallConfigurationTable;
279
280 ///
281 /// I/O Service
282 ///
283 EFI_SMM_CPU_IO_PROTOCOL SmmIo;
284
285 ///
286 /// Runtime memory services
287 ///
288 EFI_ALLOCATE_POOL SmmAllocatePool;
289 EFI_FREE_POOL SmmFreePool;
290 EFI_ALLOCATE_PAGES SmmAllocatePages;
291 EFI_FREE_PAGES SmmFreePages;
292
293 ///
294 /// MP service
295 ///
296 EFI_SMM_STARTUP_THIS_AP SmmStartupThisAp;
297
298 ///
299 /// CPU information records
300 ///
301
302 ///
303 /// A number between zero and and the NumberOfCpus field. This field designates
304 /// which processor is executing the SMM infrastructure.
305 ///
306 UINTN CurrentlyExecutingCpu;
307 ///
308 /// The number of current operational processors in the platform. This is a 1 based counter.
309 ///
310 UINTN NumberOfCpus;
311 ///
312 /// Points to an array, where each element describes the number of bytes in the
313 /// corresponding save state specified by CpuSaveState. There are always
314 /// NumberOfCpus entries in the array.
315 ///
316 UINTN *CpuSaveStateSize;
317 ///
318 /// Points to an array, where each element is a pointer to a CPU save state. The
319 /// corresponding element in CpuSaveStateSize specifies the number of bytes in the
320 /// save state area. There are always NumberOfCpus entries in the array.
321 ///
322 VOID **CpuSaveState;
323
324 ///
325 /// Extensibility table
326 ///
327
328 ///
329 /// The number of UEFI Configuration Tables in the buffer SmmConfigurationTable.
330 ///
331 UINTN NumberOfTableEntries;
332 ///
333 /// A pointer to the UEFI Configuration Tables. The number of entries in the table is
334 /// NumberOfTableEntries.
335 ///
336 EFI_CONFIGURATION_TABLE *SmmConfigurationTable;
337
338 ///
339 /// Protocol services
340 ///
341 EFI_INSTALL_PROTOCOL_INTERFACE SmmInstallProtocolInterface;
342 EFI_UNINSTALL_PROTOCOL_INTERFACE SmmUninstallProtocolInterface;
343 EFI_HANDLE_PROTOCOL SmmHandleProtocol;
344 EFI_SMM_REGISTER_PROTOCOL_NOTIFY SmmRegisterProtocolNotify;
345 EFI_LOCATE_HANDLE SmmLocateHandle;
346 EFI_LOCATE_PROTOCOL SmmLocateProtocol;
347
348 ///
349 /// SMI Management functions
350 ///
351 EFI_SMM_INTERRUPT_MANAGE SmiManage;
352 EFI_SMM_INTERRUPT_REGISTER SmiHandlerRegister;
353 EFI_SMM_INTERRUPT_UNREGISTER SmiHandlerUnRegister;
354 };
355
356 #endif