]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkPkg/Include/Protocol/SmmBase.h
IntelFrameworkPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / IntelFrameworkPkg / Include / Protocol / SmmBase.h
CommitLineData
79964ac8 1/** @file\r
2 This file declares SMM Base abstraction protocol.\r
8411f1c0 3 This protocol is used to install SMM handlers for support of subsequent SMI/PMI activations. This\r
5259c97d 4 protocol is available on both IA-32 and Itanium-based systems.\r
1c2f052d 5\r
8411f1c0 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
5259c97d 8 runtime mode. However, only the following member functions need to exist during runtime:\r
8411f1c0 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
79964ac8 21\r
1c2f052d 22Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
22a69a5e 23SPDX-License-Identifier: BSD-2-Clause-Patent\r
f7590642 24\r
79964ac8 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
a77e0eb1 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
d5555a10 40///\r
f22f941e 41/// Global ID for the EFI_SMM_BASE_PROTOCOL.\r
d5555a10 42///\r
79964ac8 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
d5555a10 48///\r
f22f941e 49/// Forward declaration for EFI_SMM_BASE_PROTOCOL.\r
d5555a10 50///\r
51typedef struct _EFI_SMM_BASE_PROTOCOL EFI_SMM_BASE_PROTOCOL;\r
79964ac8 52\r
d5555a10 53///\r
54/// EFI SMM Handler return codes\r
55///\r
56///@{\r
79964ac8 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
d5555a10 61///@}\r
62\r
79964ac8 63/**\r
64 Entry Point to Callback service\r
65\r
ac9868ec 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
1c2f052d
LG
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
f22f941e 72 a physical address.\r
ac9868ec 73 @param[in] SourceSize The size of the CommunicationBuffer.\r
79964ac8 74\r
ac9868ec 75 @return Status code\r
79964ac8 76\r
77**/\r
78typedef\r
79EFI_STATUS\r
69686d56 80(EFIAPI *EFI_SMM_CALLBACK_ENTRY_POINT)(\r
79964ac8 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
5259c97d 90 Register a given driver into SMRAM. This is the equivalent of performing\r
79964ac8 91 the LoadImage/StartImage into System Management Mode.\r
92\r
f22f941e 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
5259c97d 96 is in memory.\r
f22f941e 97 @param[in] SourceSize The size of the source image file, if in memory.\r
1c2f052d
LG
98 @param[out] ImageHandle The handle that the base driver uses to decode\r
99 the handler. Unique among SMM handlers only;\r
ac9868ec 100 not unique across DXE/EFI.\r
1c2f052d 101 @param[in] LegacyIA32Binary An optional parameter specifying that the associated\r
ac9868ec 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
f22f941e 107 @retval EFI_UNSUPPORTED The platform is in runtime.\r
108 @retval EFI_INVALID_PARAMETER The handlers were not the correct image type.\r
79964ac8 109\r
110**/\r
111typedef\r
112EFI_STATUS\r
69686d56 113(EFIAPI *EFI_SMM_REGISTER_HANDLER)(\r
a77e0eb1 114 IN EFI_SMM_BASE_PROTOCOL *This,\r
79964ac8 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
ed66e1bc 120 );\r
79964ac8 121\r
122/**\r
700a7869 123 Removes a handler from execution within SMRAM. This is the equivalent of performing\r
124 the UnloadImage in System Management Mode.\r
79964ac8 125\r
f22f941e 126 @param[in] This The protocol instance pointer.\r
ac9868ec 127 @param[in] ImageHandle The handler to be removed.\r
79964ac8 128\r
f22f941e 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
79964ac8 132\r
133**/\r
134typedef\r
135EFI_STATUS\r
69686d56 136(EFIAPI *EFI_SMM_UNREGISTER_HANDLER)(\r
79964ac8 137 IN EFI_SMM_BASE_PROTOCOL *This,\r
138 IN EFI_HANDLE ImageHandle\r
ed66e1bc 139 );\r
79964ac8 140\r
141/**\r
142 The SMM Inter-module Communicate Service Communicate() function\r
5259c97d 143 provides a service to send/receive messages from a registered\r
79964ac8 144 EFI service. The BASE protocol driver is responsible for doing\r
700a7869 145 any of the copies such that the data lives in boot-service-accessible RAM.\r
79964ac8 146\r
f22f941e 147 @param[in] This The protocol instance pointer.\r
ac9868ec 148 @param[in] ImageHandle The handle of the registered driver.\r
f22f941e 149 @param[in,out] CommunicationBuffer The pointer to the buffer to convey into SMRAM.\r
ac9868ec 150 @param[in,out] SourceSize The size of the data buffer being passed in.\r
ebcfa880 151 On exit, the size of data being returned.\r
152 Zero if the handler does not wish to reply with any data.\r
79964ac8 153\r
f22f941e 154 @retval EFI_SUCCESS The message was successfully posted.\r
155 @retval EFI_INVALID_PARAMETER The buffer was NULL.\r
79964ac8 156\r
157**/\r
158typedef\r
159EFI_STATUS\r
69686d56 160(EFIAPI *EFI_SMM_COMMUNICATE)(\r
79964ac8 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
ed66e1bc 165 );\r
79964ac8 166\r
167/**\r
168 Register a callback to execute within SMM.\r
700a7869 169 This allows receipt of messages created with EFI_SMM_BASE_PROTOCOL.Communicate().\r
79964ac8 170\r
ac9868ec 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
1c2f052d 174 @param[in] MakeLast If present, will stipulate that the handler is posted to\r
ac9868ec 175 be executed last in the dispatch table.\r
5259c97d 176 @param[in] FloatingPointSave An optional parameter that informs the\r
ac9868ec 177 EFI_SMM_ACCESS_PROTOCOL Driver core if it needs to save\r
5259c97d 178 the floating point register state. If any handler\r
179 require this, the state will be saved for all handlers.\r
ac9868ec 180\r
f22f941e 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
ac9868ec 184 @retval EFI_UNSUPPORTED The caller is not in SMM.\r
79964ac8 185\r
186**/\r
187typedef\r
188EFI_STATUS\r
69686d56 189(EFIAPI *EFI_SMM_CALLBACK_SERVICE)(\r
79964ac8 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
ed66e1bc 195 );\r
79964ac8 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
ac9868ec 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
1c2f052d
LG
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
ac9868ec 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
f22f941e 215 @retval EFI_UNSUPPORTED The platform is in runtime.\r
79964ac8 216\r
217**/\r
218typedef\r
219EFI_STATUS\r
69686d56 220(EFIAPI *EFI_SMM_ALLOCATE_POOL)(\r
79964ac8 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
ed66e1bc 225 );\r
79964ac8 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
f22f941e 232 @param[in] This The protocol instance pointer.\r
233 @param[in] Buffer The pointer to the buffer allocation.\r
79964ac8 234\r
ac9868ec 235 @retval EFI_SUCCESS The memory was returned to the system.\r
f22f941e 236 @retval EFI_INVALID_PARAMETER The buffer was invalid.\r
237 @retval EFI_UNSUPPORTED The platform is in runtime.\r
79964ac8 238\r
239**/\r
240typedef\r
241EFI_STATUS\r
69686d56 242(EFIAPI *EFI_SMM_FREE_POOL)(\r
79964ac8 243 IN EFI_SMM_BASE_PROTOCOL *This,\r
244 IN VOID *Buffer\r
ed66e1bc 245 );\r
79964ac8 246\r
247/**\r
248 This routine tells caller if execution context is SMM or not.\r
249\r
f22f941e 250 @param[in] This The protocol instance pointer.\r
ac9868ec 251 @param[out] InSmm Whether the caller is inside SMM for IA-32\r
252 or servicing a PMI for the Itanium processor\r
ebcfa880 253 family.\r
79964ac8 254\r
f22f941e 255 @retval EFI_SUCCESS The operation was successful.\r
ac9868ec 256 @retval EFI_INVALID_PARAMETER InSmm was NULL.\r
79964ac8 257\r
258**/\r
259typedef\r
260EFI_STATUS\r
69686d56 261(EFIAPI *EFI_SMM_INSIDE_OUT)(\r
79964ac8 262 IN EFI_SMM_BASE_PROTOCOL *This,\r
263 OUT BOOLEAN *InSmm\r
ed66e1bc 264 );\r
79964ac8 265\r
266/**\r
5259c97d 267 The GetSmstLocation() function returns the location of the System Management\r
79964ac8 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
f22f941e 272 @param[in] This The protocol instance pointer.\r
273 @param[in] Smst The pointer to the SMST.\r
79964ac8 274\r
ac9868ec 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
79964ac8 278\r
279**/\r
280typedef\r
281EFI_STATUS\r
69686d56 282(EFIAPI *EFI_SMM_GET_SMST_LOCATION)(\r
79964ac8 283 IN EFI_SMM_BASE_PROTOCOL *This,\r
284 IN OUT EFI_SMM_SYSTEM_TABLE **Smst\r
ed66e1bc 285 );\r
79964ac8 286\r
ebcfa880 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
79964ac8 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