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