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