2 This file declares SMM Base abstraction protocol.
3 This protocol is used to install SMM handlers for support of subsequent SMI/PMI activations. This
4 protocol is available on both IA-32 and Itanium-based systems.
6 The EFI_SMM_BASE_PROTOCOL is a set of services that is exported by a processor device. It is
7 a required protocol for the platform processor. This protocol can be used in both boot services and
8 runtime mode. However, only the following member functions need to exist during runtime:
11 This protocol is responsible for registering the handler services. The order in which the handlers are
12 executed is prescribed only with respect to the MakeLast flag in the RegisterCallback()
13 service. The driver exports these registration and unregistration services in boot services mode, but
14 the registered handlers will execute through the preboot and runtime. The only way to change the
15 behavior of a registered driver after ExitBootServices() has been invoked is to use some
16 private communication mechanism with the driver to order it to quiesce. This model permits typical
17 use cases, such as invoking the handler to enter ACPI mode, where the OS loader would make this
18 call before boot services are terminated. On the other hand, handlers for services such as chipset
19 workarounds for the century rollover in CMOS should provide commensurate services throughout
20 preboot and OS runtime.
22 Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
23 This program and the accompanying materials are licensed and made available under
24 the terms and conditions of the BSD License that accompanies this distribution.
25 The full text of the license may be found at
26 http://opensource.org/licenses/bsd-license.php.
28 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
29 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
31 @par Revision Reference:
32 This Protocol is defined in Framework of EFI SMM Core Interface Spec
41 // Share some common definitions with PI SMM
43 #include <Framework/SmmCis.h>
44 #include <Protocol/SmmCommunication.h>
47 /// Global ID for the EFI_SMM_BASE_PROTOCOL.
49 #define EFI_SMM_BASE_PROTOCOL_GUID \
51 0x1390954D, 0xda95, 0x4227, {0x93, 0x28, 0x72, 0x82, 0xc2, 0x17, 0xda, 0xa8 } \
55 /// Forward declaration for EFI_SMM_BASE_PROTOCOL.
57 typedef struct _EFI_SMM_BASE_PROTOCOL EFI_SMM_BASE_PROTOCOL
;
60 /// EFI SMM Handler return codes
63 #define EFI_HANDLER_SUCCESS 0x0000
64 #define EFI_HANDLER_CRITICAL_EXIT 0x0001
65 #define EFI_HANDLER_SOURCE_QUIESCED 0x0002
66 #define EFI_HANDLER_SOURCE_PENDING 0x0003
70 Entry Point to Callback service
72 @param[in] SmmImageHandle A handle allocated by the SMM infrastructure code
73 to uniquely designate a specific DXE SMM driver.
74 @param[in] CommunicationBuffer A pointer to a collection of data in memory
75 that will be conveyed from a non-SMM environment
76 into an SMM environment. The buffer must be
77 contiguous and physically mapped, and must be
79 @param[in] SourceSize The size of the CommunicationBuffer.
86 (EFIAPI
*EFI_SMM_CALLBACK_ENTRY_POINT
)(
87 IN EFI_HANDLE SmmImageHandle
,
88 IN OUT VOID
*CommunicationBuffer OPTIONAL
,
89 IN OUT UINTN
*SourceSize OPTIONAL
93 // SMM Base Protocol Definition
96 Register a given driver into SMRAM. This is the equivalent of performing
97 the LoadImage/StartImage into System Management Mode.
99 @param[in] This The protocol instance pointer.
100 @param[in] FilePath The location of the image to be installed as the handler.
101 @param[in] SourceBuffer An optional source buffer in case the image file
103 @param[in] SourceSize The size of the source image file, if in memory.
104 @param[out] ImageHandle The handle that the base driver uses to decode
105 the handler. Unique among SMM handlers only;
106 not unique across DXE/EFI.
107 @param[in] LegacyIA32Binary An optional parameter specifying that the associated
108 file is a real-mode IA-32 binary.
110 @retval EFI_SUCCESS The operation was successful.
111 @retval EFI_OUT_OF_RESOURCES There were no additional SMRAM resources to load the handler
112 @retval EFI_UNSUPPORTED This platform does not support 16-bit handlers.
113 @retval EFI_UNSUPPORTED The platform is in runtime.
114 @retval EFI_INVALID_PARAMETER The handlers were not the correct image type.
119 (EFIAPI
*EFI_SMM_REGISTER_HANDLER
)(
120 IN EFI_SMM_BASE_PROTOCOL
*This
,
121 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
122 IN VOID
*SourceBuffer OPTIONAL
,
124 OUT EFI_HANDLE
*ImageHandle
,
125 IN BOOLEAN LegacyIA32Binary OPTIONAL
129 Removes a handler from execution within SMRAM. This is the equivalent of performing
130 the UnloadImage in System Management Mode.
132 @param[in] This The protocol instance pointer.
133 @param[in] ImageHandle The handler to be removed.
135 @retval EFI_SUCCESS The operation was successful.
136 @retval EFI_INVALID_PARAMETER The handler did not exist.
137 @retval EFI_UNSUPPORTED The platform is in runtime.
142 (EFIAPI
*EFI_SMM_UNREGISTER_HANDLER
)(
143 IN EFI_SMM_BASE_PROTOCOL
*This
,
144 IN EFI_HANDLE ImageHandle
148 The SMM Inter-module Communicate Service Communicate() function
149 provides a service to send/receive messages from a registered
150 EFI service. The BASE protocol driver is responsible for doing
151 any of the copies such that the data lives in boot-service-accessible RAM.
153 @param[in] This The protocol instance pointer.
154 @param[in] ImageHandle The handle of the registered driver.
155 @param[in,out] CommunicationBuffer The pointer to the buffer to convey into SMRAM.
156 @param[in,out] SourceSize The size of the data buffer being passed in.
157 On exit, the size of data being returned.
158 Zero if the handler does not wish to reply with any data.
160 @retval EFI_SUCCESS The message was successfully posted.
161 @retval EFI_INVALID_PARAMETER The buffer was NULL.
166 (EFIAPI
*EFI_SMM_COMMUNICATE
)(
167 IN EFI_SMM_BASE_PROTOCOL
*This
,
168 IN EFI_HANDLE ImageHandle
,
169 IN OUT VOID
*CommunicationBuffer
,
170 IN OUT UINTN
*SourceSize
174 Register a callback to execute within SMM.
175 This allows receipt of messages created with EFI_SMM_BASE_PROTOCOL.Communicate().
177 @param[in] This Protocol instance pointer.
178 @param[in] SmmImageHandle Handle of the callback service.
179 @param[in] CallbackAddress Address of the callback service.
180 @param[in] MakeLast If present, will stipulate that the handler is posted to
181 be executed last in the dispatch table.
182 @param[in] FloatingPointSave An optional parameter that informs the
183 EFI_SMM_ACCESS_PROTOCOL Driver core if it needs to save
184 the floating point register state. If any handler
185 require this, the state will be saved for all handlers.
187 @retval EFI_SUCCESS The operation was successful.
188 @retval EFI_OUT_OF_RESOURCES Not enough space in the dispatch queue.
189 @retval EFI_UNSUPPORTED The platform is in runtime.
190 @retval EFI_UNSUPPORTED The caller is not in SMM.
195 (EFIAPI
*EFI_SMM_CALLBACK_SERVICE
)(
196 IN EFI_SMM_BASE_PROTOCOL
*This
,
197 IN EFI_HANDLE SmmImageHandle
,
198 IN EFI_SMM_CALLBACK_ENTRY_POINT CallbackAddress
,
199 IN BOOLEAN MakeLast OPTIONAL
,
200 IN BOOLEAN FloatingPointSave OPTIONAL
204 The SmmAllocatePool() function allocates a memory region of Size bytes from memory of
205 type PoolType and returns the address of the allocated memory in the location referenced
206 by Buffer. This function allocates pages from EFI SMRAM Memory as needed to grow the
207 requested pool type. All allocations are eight-byte aligned.
209 @param[in] This Protocol instance pointer.
210 @param[in] PoolType The type of pool to allocate.
211 The only supported type is EfiRuntimeServicesData;
212 the interface will internally map this runtime request to
213 SMRAM for IA-32 and leave as this type for the Itanium
214 processor family. Other types can be ignored.
215 @param[in] Size The number of bytes to allocate from the pool.
216 @param[out] Buffer A pointer to a pointer to the allocated buffer if the call
217 succeeds; undefined otherwise.
219 @retval EFI_SUCCESS The requested number of bytes was allocated.
220 @retval EFI_OUT_OF_RESOURCES The pool requested could not be allocated.
221 @retval EFI_UNSUPPORTED The platform is in runtime.
226 (EFIAPI
*EFI_SMM_ALLOCATE_POOL
)(
227 IN EFI_SMM_BASE_PROTOCOL
*This
,
228 IN EFI_MEMORY_TYPE PoolType
,
234 The SmmFreePool() function returns the memory specified by Buffer to the system.
235 On return, the memory's type is EFI SMRAM Memory. The Buffer that is freed must
236 have been allocated by SmmAllocatePool().
238 @param[in] This The protocol instance pointer.
239 @param[in] Buffer The pointer to the buffer allocation.
241 @retval EFI_SUCCESS The memory was returned to the system.
242 @retval EFI_INVALID_PARAMETER The buffer was invalid.
243 @retval EFI_UNSUPPORTED The platform is in runtime.
248 (EFIAPI
*EFI_SMM_FREE_POOL
)(
249 IN EFI_SMM_BASE_PROTOCOL
*This
,
254 This routine tells caller if execution context is SMM or not.
256 @param[in] This The protocol instance pointer.
257 @param[out] InSmm Whether the caller is inside SMM for IA-32
258 or servicing a PMI for the Itanium processor
261 @retval EFI_SUCCESS The operation was successful.
262 @retval EFI_INVALID_PARAMETER InSmm was NULL.
267 (EFIAPI
*EFI_SMM_INSIDE_OUT
)(
268 IN EFI_SMM_BASE_PROTOCOL
*This
,
273 The GetSmstLocation() function returns the location of the System Management
274 Service Table. The use of the API is such that a driver can discover the
275 location of the SMST in its entry point and then cache it in some driver
276 global variable so that the SMST can be invoked in subsequent callbacks.
278 @param[in] This The protocol instance pointer.
279 @param[in] Smst The pointer to the SMST.
281 @retval EFI_SUCCESS The operation was successful
282 @retval EFI_INVALID_PARAMETER Smst was invalid.
283 @retval EFI_UNSUPPORTED Not in SMM.
288 (EFIAPI
*EFI_SMM_GET_SMST_LOCATION
)(
289 IN EFI_SMM_BASE_PROTOCOL
*This
,
290 IN OUT EFI_SMM_SYSTEM_TABLE
**Smst
294 /// This protocol is used to install SMM handlers for support of subsequent SMI/PMI
295 /// activations. This protocol is available on both IA-32 and Itanium-based systems.
297 struct _EFI_SMM_BASE_PROTOCOL
{
298 EFI_SMM_REGISTER_HANDLER Register
;
299 EFI_SMM_UNREGISTER_HANDLER UnRegister
;
300 EFI_SMM_COMMUNICATE Communicate
;
301 EFI_SMM_CALLBACK_SERVICE RegisterCallback
;
302 EFI_SMM_INSIDE_OUT InSmm
;
303 EFI_SMM_ALLOCATE_POOL SmmAllocatePool
;
304 EFI_SMM_FREE_POOL SmmFreePool
;
305 EFI_SMM_GET_SMST_LOCATION GetSmstLocation
;
308 extern EFI_GUID gEfiSmmBaseProtocolGuid
;