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