2 Header file to define EFI SMM Base2 Protocol in the PI 1.2 specification.
4 The thunk implementation for SmmScriptLib will ultilize the SmmSaveState Protocol to save SMM
5 runtime s3 boot Script. This header file is to definied PI SMM related definition to locate
8 Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
10 This program and the accompanying materials
11 are licensed and made available under the terms and conditions
12 of the BSD License which accompanies this distribution. The
13 full text of the license may be found at
14 http://opensource.org/licenses/bsd-license.php
16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
17 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 #ifndef _PI_SMM_DEFINITION_H_
22 #define _PI_SMM_DEFINITION_H_
24 typedef struct _EFI_SMM_CPU_IO2_PROTOCOL EFI_SMM_CPU_IO2_PROTOCOL
;
27 /// Width of the SMM CPU I/O operations
37 Provides the basic memory and I/O interfaces used toabstract accesses to devices.
39 The I/O operations are carried out exactly as requested. The caller is responsible for any alignment
40 and I/O width issues that the bus, device, platform, or type of I/O might require.
42 @param[in] This The EFI_SMM_CPU_IO2_PROTOCOL instance.
43 @param[in] Width Signifies the width of the I/O operations.
44 @param[in] Address The base address of the I/O operations.
45 The caller is responsible for aligning the Address if required.
46 @param[in] Count The number of I/O operations to perform.
47 @param[in,out] Buffer For read operations, the destination buffer to store the results.
48 For write operations, the source buffer from which to write data.
50 @retval EFI_SUCCESS The data was read from or written to the device.
51 @retval EFI_UNSUPPORTED The Address is not valid for this system.
52 @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
53 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
57 (EFIAPI
*EFI_SMM_CPU_IO2
)(
58 IN CONST EFI_SMM_CPU_IO2_PROTOCOL
*This
,
59 IN EFI_SMM_IO_WIDTH Width
,
67 /// This service provides the various modalities of memory and I/O read.
71 /// This service provides the various modalities of memory and I/O write.
73 EFI_SMM_CPU_IO2 Write
;
77 /// SMM CPU I/O 2 Protocol provides CPU I/O and memory access within SMM.
79 struct _EFI_SMM_CPU_IO2_PROTOCOL
{
80 EFI_SMM_IO_ACCESS2 Mem
; ///< Allows reads and writes to memory-mapped I/O space.
81 EFI_SMM_IO_ACCESS2 Io
; ///< Allows reads and writes to I/O space.
83 typedef struct _EFI_SMM_SYSTEM_TABLE2 EFI_SMM_SYSTEM_TABLE2
;
85 Adds, updates, or removes a configuration table entry from the System Management System Table.
87 The SmmInstallConfigurationTable() function is used to maintain the list
88 of configuration tables that are stored in the System Management System
89 Table. The list is stored as an array of (GUID, Pointer) pairs. The list
90 must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.
92 @param[in] SystemTable A pointer to the SMM System Table (SMST).
93 @param[in] Guid A pointer to the GUID for the entry to add, update, or remove.
94 @param[in] Table A pointer to the buffer of the table to add.
95 @param[in] TableSize The size of the table to install.
97 @retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed.
98 @retval EFI_INVALID_PARAMETER Guid is not valid.
99 @retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry.
100 @retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation.
104 (EFIAPI
*EFI_SMM_INSTALL_CONFIGURATION_TABLE2
)(
105 IN CONST EFI_SMM_SYSTEM_TABLE2
*SystemTable
,
106 IN CONST EFI_GUID
*Guid
,
111 Function prototype for invoking a function on an Application Processor.
113 This definition is used by the UEFI MP Serices Protocol, and the
116 @param[in,out] Buffer Pointer to private data buffer.
120 (EFIAPI
*EFI_AP_PROCEDURE
)(
124 The SmmStartupThisAp() lets the caller to get one distinct application processor
125 (AP) in the enabled processor pool to execute a caller-provided code stream
126 while in SMM. It runs the given code on this processor and reports the status.
127 It must be noted that the supplied code stream will be run only on an enabled
128 processor which has also entered SMM.
130 @param[in] Procedure A pointer to the code stream to be run on the designated AP of the system.
131 @param[in] CpuNumber The zero-based index of the processor number of the AP on which the code stream is supposed to run.
132 @param[in,out] ProcArguments Allow the caller to pass a list of parameters to the code that is run by the AP.
134 @retval EFI_SUCCESS The call was successful and the return parameters are valid.
135 @retval EFI_INVALID_PARAMETER The input arguments are out of range.
136 @retval EFI_INVALID_PARAMETER The CPU requested is not available on this SMI invocation.
137 @retval EFI_INVALID_PARAMETER The CPU cannot support an additional service invocation.
141 (EFIAPI
*EFI_SMM_STARTUP_THIS_AP
)(
142 IN EFI_AP_PROCEDURE Procedure
,
144 IN OUT VOID
*ProcArguments OPTIONAL
148 Function prototype for protocol install notification.
150 @param[in] Protocol Points to the protocol's unique identifier.
151 @param[in] Interface Points to the interface instance.
152 @param[in] Handle The handle on which the interface was installed.
158 (EFIAPI
*EFI_SMM_NOTIFY_FN
)(
159 IN CONST EFI_GUID
*Protocol
,
165 Register a callback function be called when a particular protocol interface is installed.
167 The SmmRegisterProtocolNotify() function creates a registration Function that is to be
168 called whenever a protocol interface is installed for Protocol by
169 SmmInstallProtocolInterface().
171 @param[in] Protocol The unique ID of the protocol for which the event is to be registered.
172 @param[in] Function Points to the notification function.
173 @param[out] Registration A pointer to a memory location to receive the registration value.
175 @retval EFI_SUCCESS Successfully returned the registration record that has been added.
176 @retval EFI_INVALID_PARAMETER One or more of Protocol, Function and Registration is NULL.
177 @retval EFI_OUT_OF_RESOURCES Not enough memory resource to finish the request.
181 (EFIAPI
*EFI_SMM_REGISTER_PROTOCOL_NOTIFY
)(
182 IN CONST EFI_GUID
*Protocol
,
183 IN EFI_SMM_NOTIFY_FN Function
,
184 OUT VOID
**Registration
188 Manage SMI of a particular type.
190 @param[in] HandlerType Points to the handler type or NULL for root SMI handlers.
191 @param[in] Context Points to an optional context buffer.
192 @param[in,out] CommBuffer Points to the optional communication buffer.
193 @param[in,out] CommBufferSize Points to the size of the optional communication buffer.
195 @retval EFI_SUCCESS Interrupt source was processed successfully but not quiesced.
196 @retval EFI_INTERRUPT_PENDING One or more SMI sources could not be quiesced.
197 @retval EFI_WARN_INTERRUPT_SOURCE_PENDING Interrupt source was not handled or quiesced.
198 @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED Interrupt source was handled and quiesced.
202 (EFIAPI
*EFI_SMM_INTERRUPT_MANAGE
)(
203 IN CONST EFI_GUID
*HandlerType
,
204 IN CONST VOID
*Context OPTIONAL
,
205 IN OUT VOID
*CommBuffer OPTIONAL
,
206 IN OUT UINTN
*CommBufferSize OPTIONAL
210 Main entry point for an SMM handler dispatch or communicate-based callback.
212 @param[in] DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
213 @param[in] Context Points to an optional handler context which was specified when the
214 handler was registered.
215 @param[in,out] CommBuffer A pointer to a collection of data in memory that will
216 be conveyed from a non-SMM environment into an SMM environment.
217 @param[in,out] CommBufferSize The size of the CommBuffer.
219 @retval EFI_SUCCESS The interrupt was handled and quiesced. No other handlers
220 should still be called.
221 @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED The interrupt has been quiesced but other handlers should
223 @retval EFI_WARN_INTERRUPT_SOURCE_PENDING The interrupt is still pending and other handlers should still
225 @retval EFI_INTERRUPT_PENDING The interrupt could not be quiesced.
229 (EFIAPI
*EFI_SMM_HANDLER_ENTRY_POINT2
)(
230 IN EFI_HANDLE DispatchHandle
,
231 IN CONST VOID
*Context OPTIONAL
,
232 IN OUT VOID
*CommBuffer OPTIONAL
,
233 IN OUT UINTN
*CommBufferSize OPTIONAL
237 Registers a handler to execute within SMM.
239 @param[in] Handler Handler service funtion pointer.
240 @param[in] HandlerType Points to the handler type or NULL for root SMI handlers.
241 @param[out] DispatchHandle On return, contains a unique handle which can be used to later
242 unregister the handler function.
244 @retval EFI_SUCCESS SMI handler added successfully.
245 @retval EFI_INVALID_PARAMETER Handler is NULL or DispatchHandle is NULL.
249 (EFIAPI
*EFI_SMM_INTERRUPT_REGISTER
)(
250 IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler
,
251 IN CONST EFI_GUID
*HandlerType OPTIONAL
,
252 OUT EFI_HANDLE
*DispatchHandle
256 Unregister a handler in SMM.
258 @param[in] DispatchHandle The handle that was specified when the handler was registered.
260 @retval EFI_SUCCESS Handler function was successfully unregistered.
261 @retval EFI_INVALID_PARAMETER DispatchHandle does not refer to a valid handle.
265 (EFIAPI
*EFI_SMM_INTERRUPT_UNREGISTER
)(
266 IN EFI_HANDLE DispatchHandle
270 /// Processor information and functionality needed by SMM Foundation.
272 typedef struct _EFI_SMM_ENTRY_CONTEXT
{
273 EFI_SMM_STARTUP_THIS_AP SmmStartupThisAp
;
275 /// A number between zero and the NumberOfCpus field. This field designates which
276 /// processor is executing the SMM Foundation.
278 UINTN CurrentlyExecutingCpu
;
280 /// The number of current operational processors in the platform. This is a 1 based
281 /// counter. This does not indicate the number of processors that entered SMM.
285 /// Points to an array, where each element describes the number of bytes in the
286 /// corresponding save state specified by CpuSaveState. There are always
287 /// NumberOfCpus entries in the array.
289 UINTN
*CpuSaveStateSize
;
291 /// Points to an array, where each element is a pointer to a CPU save state. The
292 /// corresponding element in CpuSaveStateSize specifies the number of bytes in the
293 /// save state area. There are always NumberOfCpus entries in the array.
296 } EFI_SMM_ENTRY_CONTEXT
;
299 This function is the main entry point to the SMM Foundation.
301 @param[in] SmmEntryContext Processor information and functionality needed by SMM Foundation.
305 (EFIAPI
*EFI_SMM_ENTRY_POINT
)(
306 IN CONST EFI_SMM_ENTRY_CONTEXT
*SmmEntryContext
310 /// System Management System Table (SMST)
312 /// The System Management System Table (SMST) is a table that contains a collection of common
313 /// services for managing SMRAM allocation and providing basic I/O services. These services are
314 /// intended for both preboot and runtime usage.
316 struct _EFI_SMM_SYSTEM_TABLE2
{
318 /// The table header for the SMST.
320 EFI_TABLE_HEADER Hdr
;
322 /// A pointer to a NULL-terminated Unicode string containing the vendor name.
323 /// It is permissible for this pointer to be NULL.
325 CHAR16
*SmmFirmwareVendor
;
327 /// The particular revision of the firmware.
329 UINT32 SmmFirmwareRevision
;
331 EFI_SMM_INSTALL_CONFIGURATION_TABLE2 SmmInstallConfigurationTable
;
336 EFI_SMM_CPU_IO2_PROTOCOL SmmIo
;
339 /// Runtime memory services
341 EFI_ALLOCATE_POOL SmmAllocatePool
;
342 EFI_FREE_POOL SmmFreePool
;
343 EFI_ALLOCATE_PAGES SmmAllocatePages
;
344 EFI_FREE_PAGES SmmFreePages
;
349 EFI_SMM_STARTUP_THIS_AP SmmStartupThisAp
;
352 /// CPU information records
356 /// A number between zero and and the NumberOfCpus field. This field designates
357 /// which processor is executing the SMM infrastructure.
359 UINTN CurrentlyExecutingCpu
;
361 /// The number of current operational processors in the platform. This is a 1 based counter.
365 /// Points to an array, where each element describes the number of bytes in the
366 /// corresponding save state specified by CpuSaveState. There are always
367 /// NumberOfCpus entries in the array.
369 UINTN
*CpuSaveStateSize
;
371 /// Points to an array, where each element is a pointer to a CPU save state. The
372 /// corresponding element in CpuSaveStateSize specifies the number of bytes in the
373 /// save state area. There are always NumberOfCpus entries in the array.
378 /// Extensibility table
382 /// The number of UEFI Configuration Tables in the buffer SmmConfigurationTable.
384 UINTN NumberOfTableEntries
;
386 /// A pointer to the UEFI Configuration Tables. The number of entries in the table is
387 /// NumberOfTableEntries.
389 EFI_CONFIGURATION_TABLE
*SmmConfigurationTable
;
392 /// Protocol services
394 EFI_INSTALL_PROTOCOL_INTERFACE SmmInstallProtocolInterface
;
395 EFI_UNINSTALL_PROTOCOL_INTERFACE SmmUninstallProtocolInterface
;
396 EFI_HANDLE_PROTOCOL SmmHandleProtocol
;
397 EFI_SMM_REGISTER_PROTOCOL_NOTIFY SmmRegisterProtocolNotify
;
398 EFI_LOCATE_HANDLE SmmLocateHandle
;
399 EFI_LOCATE_PROTOCOL SmmLocateProtocol
;
402 /// SMI Management functions
404 EFI_SMM_INTERRUPT_MANAGE SmiManage
;
405 EFI_SMM_INTERRUPT_REGISTER SmiHandlerRegister
;
406 EFI_SMM_INTERRUPT_UNREGISTER SmiHandlerUnRegister
;
409 #define EFI_SMM_BASE2_PROTOCOL_GUID \
411 0xf4ccbfb7, 0xf6e0, 0x47fd, {0x9d, 0xd4, 0x10, 0xa8, 0xf1, 0x50, 0xc1, 0x91 } \
414 typedef struct _EFI_SMM_BASE2_PROTOCOL EFI_SMM_BASE2_PROTOCOL
;
417 Service to indicate whether the driver is currently executing in the SMM Initialization phase.
419 This service is used to indicate whether the driver is currently executing in the SMM Initialization
420 phase. For SMM drivers, this will return TRUE in InSmram while inside the driver's entry point and
421 otherwise FALSE. For combination SMM/DXE drivers, this will return FALSE in the DXE launch. For the
422 SMM launch, it behaves as an SMM driver.
424 @param[in] This The EFI_SMM_BASE2_PROTOCOL instance.
425 @param[out] InSmram Pointer to a Boolean which, on return, indicates that the driver is
426 currently executing inside of SMRAM (TRUE) or outside of SMRAM (FALSE).
428 @retval EFI_SUCCESS The call returned successfully.
429 @retval EFI_INVALID_PARAMETER InSmram was NULL.
433 (EFIAPI
*EFI_SMM_INSIDE_OUT2
)(
434 IN CONST EFI_SMM_BASE2_PROTOCOL
*This
,
440 Returns the location of the System Management Service Table (SMST).
442 This function returns the location of the System Management Service Table (SMST). The use of the
443 API is such that a driver can discover the location of the SMST in its entry point and then cache it in
444 some driver global variable so that the SMST can be invoked in subsequent handlers.
446 @param[in] This The EFI_SMM_BASE2_PROTOCOL instance.
447 @param[in,out] Smst On return, points to a pointer to the System Management Service Table (SMST).
449 @retval EFI_SUCCESS The operation was successful.
450 @retval EFI_INVALID_PARAMETER Smst was invalid.
451 @retval EFI_UNSUPPORTED Not in SMM.
455 (EFIAPI
*EFI_SMM_GET_SMST_LOCATION2
)(
456 IN CONST EFI_SMM_BASE2_PROTOCOL
*This
,
457 IN OUT EFI_SMM_SYSTEM_TABLE2
**Smst
462 /// EFI SMM Base2 Protocol is utilized by all SMM drivers to locate the SMM infrastructure
463 /// services and determine whether the driver is being invoked inside SMRAM or outside of SMRAM.
465 struct _EFI_SMM_BASE2_PROTOCOL
{
466 EFI_SMM_INSIDE_OUT2 InSmm
;
467 EFI_SMM_GET_SMST_LOCATION2 GetSmstLocation
;