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