]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkPkg/Include/Protocol/SmmBase.h
Remove IntelFrameworkModulePkg
[mirror_edk2.git] / IntelFrameworkPkg / Include / Protocol / SmmBase.h
1 /** @file
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.
5
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:
9 - InSmm()
10 - Communicate()
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.
21
22 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
23 SPDX-License-Identifier: BSD-2-Clause-Patent
24
25 @par Revision Reference:
26 This Protocol is defined in Framework of EFI SMM Core Interface Spec
27 Version 0.9.
28
29 **/
30
31 #ifndef _SMM_BASE_H_
32 #define _SMM_BASE_H_
33
34 //
35 // Share some common definitions with PI SMM
36 //
37 #include <Framework/SmmCis.h>
38 #include <Protocol/SmmCommunication.h>
39
40 ///
41 /// Global ID for the EFI_SMM_BASE_PROTOCOL.
42 ///
43 #define EFI_SMM_BASE_PROTOCOL_GUID \
44 { \
45 0x1390954D, 0xda95, 0x4227, {0x93, 0x28, 0x72, 0x82, 0xc2, 0x17, 0xda, 0xa8 } \
46 }
47
48 ///
49 /// Forward declaration for EFI_SMM_BASE_PROTOCOL.
50 ///
51 typedef struct _EFI_SMM_BASE_PROTOCOL EFI_SMM_BASE_PROTOCOL;
52
53 ///
54 /// EFI SMM Handler return codes
55 ///
56 ///@{
57 #define EFI_HANDLER_SUCCESS 0x0000
58 #define EFI_HANDLER_CRITICAL_EXIT 0x0001
59 #define EFI_HANDLER_SOURCE_QUIESCED 0x0002
60 #define EFI_HANDLER_SOURCE_PENDING 0x0003
61 ///@}
62
63 /**
64 Entry Point to Callback service
65
66 @param[in] SmmImageHandle A handle allocated by the SMM infrastructure code
67 to uniquely designate a specific DXE SMM driver.
68 @param[in] CommunicationBuffer A pointer to a collection of data in memory
69 that will be conveyed from a non-SMM environment
70 into an SMM environment. The buffer must be
71 contiguous and physically mapped, and must be
72 a physical address.
73 @param[in] SourceSize The size of the CommunicationBuffer.
74
75 @return Status code
76
77 **/
78 typedef
79 EFI_STATUS
80 (EFIAPI *EFI_SMM_CALLBACK_ENTRY_POINT)(
81 IN EFI_HANDLE SmmImageHandle,
82 IN OUT VOID *CommunicationBuffer OPTIONAL,
83 IN OUT UINTN *SourceSize OPTIONAL
84 );
85
86 //
87 // SMM Base Protocol Definition
88 //
89 /**
90 Register a given driver into SMRAM. This is the equivalent of performing
91 the LoadImage/StartImage into System Management Mode.
92
93 @param[in] This The protocol instance pointer.
94 @param[in] FilePath The location of the image to be installed as the handler.
95 @param[in] SourceBuffer An optional source buffer in case the image file
96 is in memory.
97 @param[in] SourceSize The size of the source image file, if in memory.
98 @param[out] ImageHandle The handle that the base driver uses to decode
99 the handler. Unique among SMM handlers only;
100 not unique across DXE/EFI.
101 @param[in] LegacyIA32Binary An optional parameter specifying that the associated
102 file is a real-mode IA-32 binary.
103
104 @retval EFI_SUCCESS The operation was successful.
105 @retval EFI_OUT_OF_RESOURCES There were no additional SMRAM resources to load the handler
106 @retval EFI_UNSUPPORTED This platform does not support 16-bit handlers.
107 @retval EFI_UNSUPPORTED The platform is in runtime.
108 @retval EFI_INVALID_PARAMETER The handlers were not the correct image type.
109
110 **/
111 typedef
112 EFI_STATUS
113 (EFIAPI *EFI_SMM_REGISTER_HANDLER)(
114 IN EFI_SMM_BASE_PROTOCOL *This,
115 IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
116 IN VOID *SourceBuffer OPTIONAL,
117 IN UINTN SourceSize,
118 OUT EFI_HANDLE *ImageHandle,
119 IN BOOLEAN LegacyIA32Binary OPTIONAL
120 );
121
122 /**
123 Removes a handler from execution within SMRAM. This is the equivalent of performing
124 the UnloadImage in System Management Mode.
125
126 @param[in] This The protocol instance pointer.
127 @param[in] ImageHandle The handler to be removed.
128
129 @retval EFI_SUCCESS The operation was successful.
130 @retval EFI_INVALID_PARAMETER The handler did not exist.
131 @retval EFI_UNSUPPORTED The platform is in runtime.
132
133 **/
134 typedef
135 EFI_STATUS
136 (EFIAPI *EFI_SMM_UNREGISTER_HANDLER)(
137 IN EFI_SMM_BASE_PROTOCOL *This,
138 IN EFI_HANDLE ImageHandle
139 );
140
141 /**
142 The SMM Inter-module Communicate Service Communicate() function
143 provides a service to send/receive messages from a registered
144 EFI service. The BASE protocol driver is responsible for doing
145 any of the copies such that the data lives in boot-service-accessible RAM.
146
147 @param[in] This The protocol instance pointer.
148 @param[in] ImageHandle The handle of the registered driver.
149 @param[in,out] CommunicationBuffer The pointer to the buffer to convey into SMRAM.
150 @param[in,out] SourceSize The size of the data buffer being passed in.
151 On exit, the size of data being returned.
152 Zero if the handler does not wish to reply with any data.
153
154 @retval EFI_SUCCESS The message was successfully posted.
155 @retval EFI_INVALID_PARAMETER The buffer was NULL.
156
157 **/
158 typedef
159 EFI_STATUS
160 (EFIAPI *EFI_SMM_COMMUNICATE)(
161 IN EFI_SMM_BASE_PROTOCOL *This,
162 IN EFI_HANDLE ImageHandle,
163 IN OUT VOID *CommunicationBuffer,
164 IN OUT UINTN *SourceSize
165 );
166
167 /**
168 Register a callback to execute within SMM.
169 This allows receipt of messages created with EFI_SMM_BASE_PROTOCOL.Communicate().
170
171 @param[in] This Protocol instance pointer.
172 @param[in] SmmImageHandle Handle of the callback service.
173 @param[in] CallbackAddress Address of the callback service.
174 @param[in] MakeLast If present, will stipulate that the handler is posted to
175 be executed last in the dispatch table.
176 @param[in] FloatingPointSave An optional parameter that informs the
177 EFI_SMM_ACCESS_PROTOCOL Driver core if it needs to save
178 the floating point register state. If any handler
179 require this, the state will be saved for all handlers.
180
181 @retval EFI_SUCCESS The operation was successful.
182 @retval EFI_OUT_OF_RESOURCES Not enough space in the dispatch queue.
183 @retval EFI_UNSUPPORTED The platform is in runtime.
184 @retval EFI_UNSUPPORTED The caller is not in SMM.
185
186 **/
187 typedef
188 EFI_STATUS
189 (EFIAPI *EFI_SMM_CALLBACK_SERVICE)(
190 IN EFI_SMM_BASE_PROTOCOL *This,
191 IN EFI_HANDLE SmmImageHandle,
192 IN EFI_SMM_CALLBACK_ENTRY_POINT CallbackAddress,
193 IN BOOLEAN MakeLast OPTIONAL,
194 IN BOOLEAN FloatingPointSave OPTIONAL
195 );
196
197 /**
198 The SmmAllocatePool() function allocates a memory region of Size bytes from memory of
199 type PoolType and returns the address of the allocated memory in the location referenced
200 by Buffer. This function allocates pages from EFI SMRAM Memory as needed to grow the
201 requested pool type. All allocations are eight-byte aligned.
202
203 @param[in] This Protocol instance pointer.
204 @param[in] PoolType The type of pool to allocate.
205 The only supported type is EfiRuntimeServicesData;
206 the interface will internally map this runtime request to
207 SMRAM for IA-32 and leave as this type for the Itanium
208 processor family. Other types can be ignored.
209 @param[in] Size The number of bytes to allocate from the pool.
210 @param[out] Buffer A pointer to a pointer to the allocated buffer if the call
211 succeeds; undefined otherwise.
212
213 @retval EFI_SUCCESS The requested number of bytes was allocated.
214 @retval EFI_OUT_OF_RESOURCES The pool requested could not be allocated.
215 @retval EFI_UNSUPPORTED The platform is in runtime.
216
217 **/
218 typedef
219 EFI_STATUS
220 (EFIAPI *EFI_SMM_ALLOCATE_POOL)(
221 IN EFI_SMM_BASE_PROTOCOL *This,
222 IN EFI_MEMORY_TYPE PoolType,
223 IN UINTN Size,
224 OUT VOID **Buffer
225 );
226
227 /**
228 The SmmFreePool() function returns the memory specified by Buffer to the system.
229 On return, the memory's type is EFI SMRAM Memory. The Buffer that is freed must
230 have been allocated by SmmAllocatePool().
231
232 @param[in] This The protocol instance pointer.
233 @param[in] Buffer The pointer to the buffer allocation.
234
235 @retval EFI_SUCCESS The memory was returned to the system.
236 @retval EFI_INVALID_PARAMETER The buffer was invalid.
237 @retval EFI_UNSUPPORTED The platform is in runtime.
238
239 **/
240 typedef
241 EFI_STATUS
242 (EFIAPI *EFI_SMM_FREE_POOL)(
243 IN EFI_SMM_BASE_PROTOCOL *This,
244 IN VOID *Buffer
245 );
246
247 /**
248 This routine tells caller if execution context is SMM or not.
249
250 @param[in] This The protocol instance pointer.
251 @param[out] InSmm Whether the caller is inside SMM for IA-32
252 or servicing a PMI for the Itanium processor
253 family.
254
255 @retval EFI_SUCCESS The operation was successful.
256 @retval EFI_INVALID_PARAMETER InSmm was NULL.
257
258 **/
259 typedef
260 EFI_STATUS
261 (EFIAPI *EFI_SMM_INSIDE_OUT)(
262 IN EFI_SMM_BASE_PROTOCOL *This,
263 OUT BOOLEAN *InSmm
264 );
265
266 /**
267 The GetSmstLocation() function returns the location of the System Management
268 Service Table. The use of the API is such that a driver can discover the
269 location of the SMST in its entry point and then cache it in some driver
270 global variable so that the SMST can be invoked in subsequent callbacks.
271
272 @param[in] This The protocol instance pointer.
273 @param[in] Smst The pointer to the SMST.
274
275 @retval EFI_SUCCESS The operation was successful
276 @retval EFI_INVALID_PARAMETER Smst was invalid.
277 @retval EFI_UNSUPPORTED Not in SMM.
278
279 **/
280 typedef
281 EFI_STATUS
282 (EFIAPI *EFI_SMM_GET_SMST_LOCATION)(
283 IN EFI_SMM_BASE_PROTOCOL *This,
284 IN OUT EFI_SMM_SYSTEM_TABLE **Smst
285 );
286
287 ///
288 /// This protocol is used to install SMM handlers for support of subsequent SMI/PMI
289 /// activations. This protocol is available on both IA-32 and Itanium-based systems.
290 ///
291 struct _EFI_SMM_BASE_PROTOCOL {
292 EFI_SMM_REGISTER_HANDLER Register;
293 EFI_SMM_UNREGISTER_HANDLER UnRegister;
294 EFI_SMM_COMMUNICATE Communicate;
295 EFI_SMM_CALLBACK_SERVICE RegisterCallback;
296 EFI_SMM_INSIDE_OUT InSmm;
297 EFI_SMM_ALLOCATE_POOL SmmAllocatePool;
298 EFI_SMM_FREE_POOL SmmFreePool;
299 EFI_SMM_GET_SMST_LOCATION GetSmstLocation;
300 };
301
302 extern EFI_GUID gEfiSmmBaseProtocolGuid;
303
304 #endif