]>
Commit | Line | Data |
---|---|---|
e42e9404 | 1 | /** @file\r |
2 | The internal header file includes the common header files, defines\r | |
3 | internal structure and functions used by SmmCore module.\r | |
4 | \r | |
ca41f3f4 | 5 | Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r |
e42e9404 | 6 | This program and the accompanying materials are licensed and made available \r |
7 | under the terms and conditions of the BSD License which accompanies this \r | |
8 | distribution. The full text of the license may be found at \r | |
9 | http://opensource.org/licenses/bsd-license.php \r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #ifndef _SMM_CORE_H_\r | |
17 | #define _SMM_CORE_H_\r | |
18 | \r | |
19 | #include <PiSmm.h>\r | |
20 | \r | |
21 | #include <Protocol/DxeSmmReadyToLock.h>\r | |
22 | #include <Protocol/SmmReadyToLock.h>\r | |
46ece1ff | 23 | #include <Protocol/SmmEndOfDxe.h>\r |
e42e9404 | 24 | #include <Protocol/CpuIo2.h>\r |
25 | #include <Protocol/SmmCommunication.h>\r | |
26 | #include <Protocol/SmmAccess2.h>\r | |
27 | #include <Protocol/FirmwareVolume2.h> \r | |
28 | #include <Protocol/LoadedImage.h> \r | |
29 | #include <Protocol/DevicePath.h> \r | |
30 | #include <Protocol/Security.h> \r | |
bc2dfdbc | 31 | #include <Protocol/Security2.h>\r |
53ec4d7f SZ |
32 | #include <Protocol/SmmExitBootServices.h>\r |
33 | #include <Protocol/SmmLegacyBoot.h>\r | |
34 | #include <Protocol/SmmReadyToBoot.h>\r | |
e42e9404 | 35 | \r |
36 | #include <Guid/Apriori.h>\r | |
37 | #include <Guid/EventGroup.h>\r | |
38 | #include <Guid/EventLegacyBios.h>\r | |
84edd20b | 39 | #include <Guid/MemoryProfile.h>\r |
94a1bc12 | 40 | #include <Guid/LoadModuleAtFixedAddress.h>\r |
ca41f3f4 | 41 | #include <Guid/SmiHandlerProfile.h>\r |
e42e9404 | 42 | \r |
43 | #include <Library/BaseLib.h>\r | |
44 | #include <Library/BaseMemoryLib.h>\r | |
45 | #include <Library/PeCoffLib.h>\r | |
e524f680 | 46 | #include <Library/PeCoffGetEntryPointLib.h>\r |
e42e9404 | 47 | #include <Library/CacheMaintenanceLib.h>\r |
48 | #include <Library/DebugLib.h>\r | |
49 | #include <Library/ReportStatusCodeLib.h>\r | |
50 | #include <Library/MemoryAllocationLib.h>\r | |
51 | #include <Library/DevicePathLib.h> \r | |
52 | #include <Library/UefiLib.h> \r | |
3c447c27 | 53 | #include <Library/UefiBootServicesTableLib.h>\r |
54 | #include <Library/PcdLib.h>\r | |
495797c5 | 55 | #include <Library/SmmCorePlatformHookLib.h>\r |
56 | #include <Library/PerformanceLib.h>\r | |
c2cb08df | 57 | #include <Library/TimerLib.h>\r |
3720ee6d | 58 | #include <Library/HobLib.h>\r |
842b1242 | 59 | #include <Library/SmmMemLib.h>\r |
e42e9404 | 60 | \r |
61 | #include "PiSmmCorePrivateData.h"\r | |
62 | \r | |
63 | //\r | |
64 | // Used to build a table of SMI Handlers that the SMM Core registers\r | |
65 | //\r | |
66 | typedef struct {\r | |
67 | EFI_SMM_HANDLER_ENTRY_POINT2 Handler;\r | |
68 | EFI_GUID *HandlerType;\r | |
69 | EFI_HANDLE DispatchHandle;\r | |
70 | BOOLEAN UnRegister;\r | |
71 | } SMM_CORE_SMI_HANDLERS;\r | |
72 | \r | |
ca41f3f4 JY |
73 | //\r |
74 | // SMM_HANDLER - used for each SMM handler\r | |
75 | //\r | |
76 | \r | |
77 | #define SMI_ENTRY_SIGNATURE SIGNATURE_32('s','m','i','e')\r | |
78 | \r | |
79 | typedef struct {\r | |
80 | UINTN Signature;\r | |
81 | LIST_ENTRY AllEntries; // All entries\r | |
82 | \r | |
83 | EFI_GUID HandlerType; // Type of interrupt\r | |
84 | LIST_ENTRY SmiHandlers; // All handlers\r | |
85 | } SMI_ENTRY;\r | |
86 | \r | |
87 | #define SMI_HANDLER_SIGNATURE SIGNATURE_32('s','m','i','h')\r | |
88 | \r | |
89 | typedef struct {\r | |
90 | UINTN Signature;\r | |
91 | LIST_ENTRY Link; // Link on SMI_ENTRY.SmiHandlers\r | |
92 | EFI_SMM_HANDLER_ENTRY_POINT2 Handler; // The smm handler's entry point\r | |
93 | UINTN CallerAddr; // The address of caller who register the SMI handler.\r | |
94 | SMI_ENTRY *SmiEntry;\r | |
95 | VOID *Context; // for profile\r | |
96 | UINTN ContextSize; // for profile\r | |
97 | } SMI_HANDLER;\r | |
98 | \r | |
e42e9404 | 99 | //\r |
100 | // Structure for recording the state of an SMM Driver\r | |
101 | //\r | |
102 | #define EFI_SMM_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('s', 'd','r','v')\r | |
103 | \r | |
104 | typedef struct {\r | |
105 | UINTN Signature;\r | |
106 | LIST_ENTRY Link; // mDriverList\r | |
107 | \r | |
108 | LIST_ENTRY ScheduledLink; // mScheduledQueue\r | |
109 | \r | |
110 | EFI_HANDLE FvHandle;\r | |
111 | EFI_GUID FileName;\r | |
112 | EFI_DEVICE_PATH_PROTOCOL *FvFileDevicePath;\r | |
113 | EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r | |
114 | \r | |
115 | VOID *Depex;\r | |
116 | UINTN DepexSize;\r | |
117 | \r | |
118 | BOOLEAN Before;\r | |
119 | BOOLEAN After;\r | |
120 | EFI_GUID BeforeAfterGuid;\r | |
121 | \r | |
122 | BOOLEAN Dependent;\r | |
e42e9404 | 123 | BOOLEAN Scheduled;\r |
e42e9404 | 124 | BOOLEAN Initialized;\r |
125 | BOOLEAN DepexProtocolError;\r | |
126 | \r | |
127 | EFI_HANDLE ImageHandle;\r | |
128 | EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;\r | |
129 | //\r | |
130 | // Image EntryPoint in SMRAM\r | |
131 | //\r | |
132 | PHYSICAL_ADDRESS ImageEntryPoint;\r | |
133 | //\r | |
134 | // Image Buffer in SMRAM \r | |
135 | //\r | |
136 | PHYSICAL_ADDRESS ImageBuffer;\r | |
137 | //\r | |
138 | // Image Page Number\r | |
139 | //\r | |
140 | UINTN NumberOfPage;\r | |
285a682c JY |
141 | EFI_HANDLE SmmImageHandle;\r |
142 | EFI_LOADED_IMAGE_PROTOCOL SmmLoadedImage;\r | |
e42e9404 | 143 | } EFI_SMM_DRIVER_ENTRY;\r |
144 | \r | |
145 | #define EFI_HANDLE_SIGNATURE SIGNATURE_32('h','n','d','l')\r | |
146 | \r | |
147 | ///\r | |
148 | /// IHANDLE - contains a list of protocol handles\r | |
149 | ///\r | |
150 | typedef struct {\r | |
151 | UINTN Signature;\r | |
152 | /// All handles list of IHANDLE\r | |
153 | LIST_ENTRY AllHandles;\r | |
154 | /// List of PROTOCOL_INTERFACE's for this handle\r | |
155 | LIST_ENTRY Protocols;\r | |
156 | UINTN LocateRequest;\r | |
157 | } IHANDLE;\r | |
158 | \r | |
159 | #define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)\r | |
160 | \r | |
161 | #define PROTOCOL_ENTRY_SIGNATURE SIGNATURE_32('p','r','t','e')\r | |
162 | \r | |
163 | ///\r | |
164 | /// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol\r | |
165 | /// database. Each handler that supports this protocol is listed, along\r | |
166 | /// with a list of registered notifies.\r | |
167 | ///\r | |
168 | typedef struct {\r | |
169 | UINTN Signature;\r | |
170 | /// Link Entry inserted to mProtocolDatabase\r | |
171 | LIST_ENTRY AllEntries;\r | |
172 | /// ID of the protocol\r | |
173 | EFI_GUID ProtocolID;\r | |
174 | /// All protocol interfaces\r | |
175 | LIST_ENTRY Protocols;\r | |
176 | /// Registerd notification handlers\r | |
177 | LIST_ENTRY Notify;\r | |
178 | } PROTOCOL_ENTRY;\r | |
179 | \r | |
180 | #define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('p','i','f','c')\r | |
181 | \r | |
182 | ///\r | |
183 | /// PROTOCOL_INTERFACE - each protocol installed on a handle is tracked\r | |
184 | /// with a protocol interface structure\r | |
185 | ///\r | |
186 | typedef struct {\r | |
187 | UINTN Signature;\r | |
188 | /// Link on IHANDLE.Protocols\r | |
189 | LIST_ENTRY Link;\r | |
190 | /// Back pointer\r | |
191 | IHANDLE *Handle;\r | |
192 | /// Link on PROTOCOL_ENTRY.Protocols\r | |
193 | LIST_ENTRY ByProtocol;\r | |
194 | /// The protocol ID\r | |
195 | PROTOCOL_ENTRY *Protocol;\r | |
196 | /// The interface value\r | |
197 | VOID *Interface;\r | |
198 | } PROTOCOL_INTERFACE;\r | |
199 | \r | |
200 | #define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')\r | |
201 | \r | |
202 | ///\r | |
203 | /// PROTOCOL_NOTIFY - used for each register notification for a protocol\r | |
204 | ///\r | |
205 | typedef struct {\r | |
206 | UINTN Signature;\r | |
207 | PROTOCOL_ENTRY *Protocol;\r | |
208 | /// All notifications for this protocol\r | |
209 | LIST_ENTRY Link;\r | |
210 | /// Notification function\r | |
211 | EFI_SMM_NOTIFY_FN Function;\r | |
212 | /// Last position notified\r | |
213 | LIST_ENTRY *Position;\r | |
214 | } PROTOCOL_NOTIFY;\r | |
215 | \r | |
216 | //\r | |
217 | // SMM Core Global Variables\r | |
218 | //\r | |
219 | extern SMM_CORE_PRIVATE_DATA *gSmmCorePrivate;\r | |
220 | extern EFI_SMM_SYSTEM_TABLE2 gSmmCoreSmst;\r | |
221 | extern LIST_ENTRY gHandleList;\r | |
3c447c27 | 222 | extern EFI_PHYSICAL_ADDRESS gLoadModuleAtFixAddressSmramBase;\r |
e42e9404 | 223 | \r |
224 | /**\r | |
225 | Called to initialize the memory service.\r | |
226 | \r | |
227 | @param SmramRangeCount Number of SMRAM Regions\r | |
228 | @param SmramRanges Pointer to SMRAM Descriptors\r | |
229 | \r | |
230 | **/\r | |
231 | VOID\r | |
232 | SmmInitializeMemoryServices (\r | |
233 | IN UINTN SmramRangeCount,\r | |
234 | IN EFI_SMRAM_DESCRIPTOR *SmramRanges\r | |
235 | );\r | |
236 | \r | |
237 | /**\r | |
238 | The SmmInstallConfigurationTable() function is used to maintain the list\r | |
239 | of configuration tables that are stored in the System Management System\r | |
240 | Table. The list is stored as an array of (GUID, Pointer) pairs. The list\r | |
241 | must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.\r | |
242 | \r | |
243 | @param SystemTable A pointer to the SMM System Table (SMST).\r | |
244 | @param Guid A pointer to the GUID for the entry to add, update, or remove.\r | |
245 | @param Table A pointer to the buffer of the table to add.\r | |
246 | @param TableSize The size of the table to install.\r | |
247 | \r | |
248 | @retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed.\r | |
249 | @retval EFI_INVALID_PARAMETER Guid is not valid.\r | |
250 | @retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry.\r | |
251 | @retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation.\r | |
252 | \r | |
253 | **/\r | |
254 | EFI_STATUS\r | |
255 | EFIAPI\r | |
256 | SmmInstallConfigurationTable (\r | |
257 | IN CONST EFI_SMM_SYSTEM_TABLE2 *SystemTable,\r | |
258 | IN CONST EFI_GUID *Guid,\r | |
259 | IN VOID *Table,\r | |
260 | IN UINTN TableSize\r | |
261 | );\r | |
262 | \r | |
263 | /**\r | |
264 | Wrapper function to SmmInstallProtocolInterfaceNotify. This is the public API which\r | |
265 | Calls the private one which contains a BOOLEAN parameter for notifications\r | |
266 | \r | |
267 | @param UserHandle The handle to install the protocol handler on,\r | |
268 | or NULL if a new handle is to be allocated\r | |
269 | @param Protocol The protocol to add to the handle\r | |
270 | @param InterfaceType Indicates whether Interface is supplied in\r | |
271 | native form.\r | |
272 | @param Interface The interface for the protocol being added\r | |
273 | \r | |
274 | @return Status code\r | |
275 | \r | |
276 | **/\r | |
277 | EFI_STATUS\r | |
278 | EFIAPI\r | |
279 | SmmInstallProtocolInterface (\r | |
280 | IN OUT EFI_HANDLE *UserHandle,\r | |
281 | IN EFI_GUID *Protocol,\r | |
282 | IN EFI_INTERFACE_TYPE InterfaceType,\r | |
283 | IN VOID *Interface\r | |
284 | );\r | |
285 | \r | |
286 | /**\r | |
287 | Allocates pages from the memory map.\r | |
288 | \r | |
289 | @param Type The type of allocation to perform\r | |
290 | @param MemoryType The type of memory to turn the allocated pages\r | |
291 | into\r | |
292 | @param NumberOfPages The number of pages to allocate\r | |
293 | @param Memory A pointer to receive the base allocated memory\r | |
294 | address\r | |
295 | \r | |
296 | @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.\r | |
297 | @retval EFI_NOT_FOUND Could not allocate pages match the requirement.\r | |
298 | @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.\r | |
299 | @retval EFI_SUCCESS Pages successfully allocated.\r | |
300 | \r | |
301 | **/\r | |
302 | EFI_STATUS\r | |
303 | EFIAPI\r | |
304 | SmmAllocatePages (\r | |
305 | IN EFI_ALLOCATE_TYPE Type,\r | |
306 | IN EFI_MEMORY_TYPE MemoryType,\r | |
307 | IN UINTN NumberOfPages,\r | |
308 | OUT EFI_PHYSICAL_ADDRESS *Memory\r | |
309 | );\r | |
310 | \r | |
84edd20b SZ |
311 | /**\r |
312 | Allocates pages from the memory map.\r | |
313 | \r | |
314 | @param Type The type of allocation to perform\r | |
315 | @param MemoryType The type of memory to turn the allocated pages\r | |
316 | into\r | |
317 | @param NumberOfPages The number of pages to allocate\r | |
318 | @param Memory A pointer to receive the base allocated memory\r | |
319 | address\r | |
320 | \r | |
321 | @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.\r | |
322 | @retval EFI_NOT_FOUND Could not allocate pages match the requirement.\r | |
323 | @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.\r | |
324 | @retval EFI_SUCCESS Pages successfully allocated.\r | |
325 | \r | |
326 | **/\r | |
327 | EFI_STATUS\r | |
328 | EFIAPI\r | |
329 | SmmInternalAllocatePages (\r | |
330 | IN EFI_ALLOCATE_TYPE Type,\r | |
331 | IN EFI_MEMORY_TYPE MemoryType,\r | |
332 | IN UINTN NumberOfPages,\r | |
333 | OUT EFI_PHYSICAL_ADDRESS *Memory\r | |
334 | );\r | |
335 | \r | |
e42e9404 | 336 | /**\r |
337 | Frees previous allocated pages.\r | |
338 | \r | |
339 | @param Memory Base address of memory being freed\r | |
340 | @param NumberOfPages The number of pages to free\r | |
341 | \r | |
342 | @retval EFI_NOT_FOUND Could not find the entry that covers the range\r | |
ddfae264 | 343 | @retval EFI_INVALID_PARAMETER Address not aligned, Address is zero or NumberOfPages is zero.\r |
e42e9404 | 344 | @return EFI_SUCCESS Pages successfully freed.\r |
345 | \r | |
346 | **/\r | |
347 | EFI_STATUS\r | |
348 | EFIAPI\r | |
349 | SmmFreePages (\r | |
350 | IN EFI_PHYSICAL_ADDRESS Memory,\r | |
351 | IN UINTN NumberOfPages\r | |
352 | );\r | |
353 | \r | |
84edd20b SZ |
354 | /**\r |
355 | Frees previous allocated pages.\r | |
356 | \r | |
357 | @param Memory Base address of memory being freed\r | |
358 | @param NumberOfPages The number of pages to free\r | |
359 | \r | |
360 | @retval EFI_NOT_FOUND Could not find the entry that covers the range\r | |
ddfae264 | 361 | @retval EFI_INVALID_PARAMETER Address not aligned, Address is zero or NumberOfPages is zero.\r |
84edd20b SZ |
362 | @return EFI_SUCCESS Pages successfully freed.\r |
363 | \r | |
364 | **/\r | |
365 | EFI_STATUS\r | |
366 | EFIAPI\r | |
367 | SmmInternalFreePages (\r | |
368 | IN EFI_PHYSICAL_ADDRESS Memory,\r | |
369 | IN UINTN NumberOfPages\r | |
370 | );\r | |
371 | \r | |
e42e9404 | 372 | /**\r |
373 | Allocate pool of a particular type.\r | |
374 | \r | |
375 | @param PoolType Type of pool to allocate\r | |
376 | @param Size The amount of pool to allocate\r | |
377 | @param Buffer The address to return a pointer to the allocated\r | |
378 | pool\r | |
379 | \r | |
380 | @retval EFI_INVALID_PARAMETER PoolType not valid\r | |
381 | @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.\r | |
382 | @retval EFI_SUCCESS Pool successfully allocated.\r | |
383 | \r | |
384 | **/\r | |
385 | EFI_STATUS\r | |
386 | EFIAPI\r | |
387 | SmmAllocatePool (\r | |
388 | IN EFI_MEMORY_TYPE PoolType,\r | |
389 | IN UINTN Size,\r | |
390 | OUT VOID **Buffer\r | |
391 | );\r | |
392 | \r | |
84edd20b SZ |
393 | /**\r |
394 | Allocate pool of a particular type.\r | |
395 | \r | |
396 | @param PoolType Type of pool to allocate\r | |
397 | @param Size The amount of pool to allocate\r | |
398 | @param Buffer The address to return a pointer to the allocated\r | |
399 | pool\r | |
400 | \r | |
401 | @retval EFI_INVALID_PARAMETER PoolType not valid\r | |
402 | @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.\r | |
403 | @retval EFI_SUCCESS Pool successfully allocated.\r | |
404 | \r | |
405 | **/\r | |
406 | EFI_STATUS\r | |
407 | EFIAPI\r | |
408 | SmmInternalAllocatePool (\r | |
409 | IN EFI_MEMORY_TYPE PoolType,\r | |
410 | IN UINTN Size,\r | |
411 | OUT VOID **Buffer\r | |
412 | );\r | |
413 | \r | |
e42e9404 | 414 | /**\r |
415 | Frees pool.\r | |
416 | \r | |
417 | @param Buffer The allocated pool entry to free\r | |
418 | \r | |
419 | @retval EFI_INVALID_PARAMETER Buffer is not a valid value.\r | |
420 | @retval EFI_SUCCESS Pool successfully freed.\r | |
421 | \r | |
422 | **/\r | |
423 | EFI_STATUS\r | |
424 | EFIAPI\r | |
425 | SmmFreePool (\r | |
426 | IN VOID *Buffer\r | |
427 | );\r | |
428 | \r | |
84edd20b SZ |
429 | /**\r |
430 | Frees pool.\r | |
431 | \r | |
432 | @param Buffer The allocated pool entry to free\r | |
433 | \r | |
434 | @retval EFI_INVALID_PARAMETER Buffer is not a valid value.\r | |
435 | @retval EFI_SUCCESS Pool successfully freed.\r | |
436 | \r | |
437 | **/\r | |
438 | EFI_STATUS\r | |
439 | EFIAPI\r | |
440 | SmmInternalFreePool (\r | |
441 | IN VOID *Buffer\r | |
442 | );\r | |
443 | \r | |
e42e9404 | 444 | /**\r |
445 | Installs a protocol interface into the boot services environment.\r | |
446 | \r | |
447 | @param UserHandle The handle to install the protocol handler on,\r | |
448 | or NULL if a new handle is to be allocated\r | |
449 | @param Protocol The protocol to add to the handle\r | |
450 | @param InterfaceType Indicates whether Interface is supplied in\r | |
451 | native form.\r | |
452 | @param Interface The interface for the protocol being added\r | |
453 | @param Notify indicates whether notify the notification list\r | |
454 | for this protocol\r | |
455 | \r | |
456 | @retval EFI_INVALID_PARAMETER Invalid parameter\r | |
457 | @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate\r | |
458 | @retval EFI_SUCCESS Protocol interface successfully installed\r | |
459 | \r | |
460 | **/\r | |
461 | EFI_STATUS\r | |
462 | SmmInstallProtocolInterfaceNotify (\r | |
463 | IN OUT EFI_HANDLE *UserHandle,\r | |
464 | IN EFI_GUID *Protocol,\r | |
465 | IN EFI_INTERFACE_TYPE InterfaceType,\r | |
466 | IN VOID *Interface,\r | |
467 | IN BOOLEAN Notify\r | |
468 | );\r | |
469 | \r | |
470 | /**\r | |
471 | Uninstalls all instances of a protocol:interfacer from a handle.\r | |
472 | If the last protocol interface is remove from the handle, the\r | |
473 | handle is freed.\r | |
474 | \r | |
475 | @param UserHandle The handle to remove the protocol handler from\r | |
476 | @param Protocol The protocol, of protocol:interface, to remove\r | |
477 | @param Interface The interface, of protocol:interface, to remove\r | |
478 | \r | |
479 | @retval EFI_INVALID_PARAMETER Protocol is NULL.\r | |
480 | @retval EFI_SUCCESS Protocol interface successfully uninstalled.\r | |
481 | \r | |
482 | **/\r | |
483 | EFI_STATUS\r | |
484 | EFIAPI\r | |
485 | SmmUninstallProtocolInterface (\r | |
486 | IN EFI_HANDLE UserHandle,\r | |
487 | IN EFI_GUID *Protocol,\r | |
488 | IN VOID *Interface\r | |
489 | );\r | |
490 | \r | |
491 | /**\r | |
492 | Queries a handle to determine if it supports a specified protocol.\r | |
493 | \r | |
494 | @param UserHandle The handle being queried.\r | |
495 | @param Protocol The published unique identifier of the protocol.\r | |
496 | @param Interface Supplies the address where a pointer to the\r | |
497 | corresponding Protocol Interface is returned.\r | |
498 | \r | |
499 | @return The requested protocol interface for the handle\r | |
500 | \r | |
501 | **/\r | |
502 | EFI_STATUS\r | |
503 | EFIAPI\r | |
504 | SmmHandleProtocol (\r | |
505 | IN EFI_HANDLE UserHandle,\r | |
506 | IN EFI_GUID *Protocol,\r | |
507 | OUT VOID **Interface\r | |
508 | );\r | |
509 | \r | |
510 | /**\r | |
511 | Add a new protocol notification record for the request protocol.\r | |
512 | \r | |
513 | @param Protocol The requested protocol to add the notify\r | |
514 | registration\r | |
515 | @param Function Points to the notification function\r | |
516 | @param Registration Returns the registration record\r | |
517 | \r | |
518 | @retval EFI_INVALID_PARAMETER Invalid parameter\r | |
519 | @retval EFI_SUCCESS Successfully returned the registration record\r | |
520 | that has been added\r | |
521 | \r | |
522 | **/\r | |
523 | EFI_STATUS\r | |
524 | EFIAPI\r | |
525 | SmmRegisterProtocolNotify (\r | |
526 | IN CONST EFI_GUID *Protocol,\r | |
527 | IN EFI_SMM_NOTIFY_FN Function,\r | |
528 | OUT VOID **Registration\r | |
529 | );\r | |
530 | \r | |
531 | /**\r | |
532 | Locates the requested handle(s) and returns them in Buffer.\r | |
533 | \r | |
534 | @param SearchType The type of search to perform to locate the\r | |
535 | handles\r | |
536 | @param Protocol The protocol to search for\r | |
537 | @param SearchKey Dependant on SearchType\r | |
538 | @param BufferSize On input the size of Buffer. On output the\r | |
539 | size of data returned.\r | |
540 | @param Buffer The buffer to return the results in\r | |
541 | \r | |
542 | @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is\r | |
543 | returned in BufferSize.\r | |
544 | @retval EFI_INVALID_PARAMETER Invalid parameter\r | |
545 | @retval EFI_SUCCESS Successfully found the requested handle(s) and\r | |
546 | returns them in Buffer.\r | |
547 | \r | |
548 | **/\r | |
549 | EFI_STATUS\r | |
550 | EFIAPI\r | |
551 | SmmLocateHandle (\r | |
552 | IN EFI_LOCATE_SEARCH_TYPE SearchType,\r | |
553 | IN EFI_GUID *Protocol OPTIONAL,\r | |
554 | IN VOID *SearchKey OPTIONAL,\r | |
555 | IN OUT UINTN *BufferSize,\r | |
556 | OUT EFI_HANDLE *Buffer\r | |
557 | );\r | |
558 | \r | |
559 | /**\r | |
560 | Return the first Protocol Interface that matches the Protocol GUID. If\r | |
561 | Registration is pasased in return a Protocol Instance that was just add\r | |
562 | to the system. If Retistration is NULL return the first Protocol Interface\r | |
563 | you find.\r | |
564 | \r | |
565 | @param Protocol The protocol to search for\r | |
566 | @param Registration Optional Registration Key returned from\r | |
567 | RegisterProtocolNotify()\r | |
568 | @param Interface Return the Protocol interface (instance).\r | |
569 | \r | |
570 | @retval EFI_SUCCESS If a valid Interface is returned\r | |
571 | @retval EFI_INVALID_PARAMETER Invalid parameter\r | |
572 | @retval EFI_NOT_FOUND Protocol interface not found\r | |
573 | \r | |
574 | **/\r | |
575 | EFI_STATUS\r | |
576 | EFIAPI\r | |
577 | SmmLocateProtocol (\r | |
578 | IN EFI_GUID *Protocol,\r | |
579 | IN VOID *Registration OPTIONAL,\r | |
580 | OUT VOID **Interface\r | |
581 | );\r | |
582 | \r | |
285a682c JY |
583 | /**\r |
584 | Function returns an array of handles that support the requested protocol\r | |
585 | in a buffer allocated from pool. This is a version of SmmLocateHandle()\r | |
586 | that allocates a buffer for the caller.\r | |
587 | \r | |
588 | @param SearchType Specifies which handle(s) are to be returned.\r | |
589 | @param Protocol Provides the protocol to search by. This\r | |
590 | parameter is only valid for SearchType\r | |
591 | ByProtocol.\r | |
592 | @param SearchKey Supplies the search key depending on the\r | |
593 | SearchType.\r | |
594 | @param NumberHandles The number of handles returned in Buffer.\r | |
595 | @param Buffer A pointer to the buffer to return the requested\r | |
596 | array of handles that support Protocol.\r | |
597 | \r | |
598 | @retval EFI_SUCCESS The result array of handles was returned.\r | |
599 | @retval EFI_NOT_FOUND No handles match the search.\r | |
600 | @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the\r | |
601 | matching results.\r | |
602 | @retval EFI_INVALID_PARAMETER One or more paramters are not valid.\r | |
603 | \r | |
604 | **/\r | |
605 | EFI_STATUS\r | |
606 | EFIAPI\r | |
607 | SmmLocateHandleBuffer (\r | |
608 | IN EFI_LOCATE_SEARCH_TYPE SearchType,\r | |
609 | IN EFI_GUID *Protocol OPTIONAL,\r | |
610 | IN VOID *SearchKey OPTIONAL,\r | |
611 | IN OUT UINTN *NumberHandles,\r | |
612 | OUT EFI_HANDLE **Buffer\r | |
613 | );\r | |
614 | \r | |
e42e9404 | 615 | /**\r |
616 | Manage SMI of a particular type.\r | |
617 | \r | |
618 | @param HandlerType Points to the handler type or NULL for root SMI handlers.\r | |
619 | @param Context Points to an optional context buffer.\r | |
620 | @param CommBuffer Points to the optional communication buffer.\r | |
621 | @param CommBufferSize Points to the size of the optional communication buffer.\r | |
622 | \r | |
623 | @retval EFI_SUCCESS Interrupt source was processed successfully but not quiesced.\r | |
624 | @retval EFI_INTERRUPT_PENDING One or more SMI sources could not be quiesced.\r | |
625 | @retval EFI_WARN_INTERRUPT_SOURCE_PENDING Interrupt source was not handled or quiesced.\r | |
626 | @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED Interrupt source was handled and quiesced.\r | |
627 | \r | |
628 | **/\r | |
629 | EFI_STATUS\r | |
630 | EFIAPI\r | |
631 | SmiManage (\r | |
632 | IN CONST EFI_GUID *HandlerType,\r | |
633 | IN CONST VOID *Context OPTIONAL,\r | |
634 | IN OUT VOID *CommBuffer OPTIONAL,\r | |
635 | IN OUT UINTN *CommBufferSize OPTIONAL\r | |
636 | );\r | |
637 | \r | |
638 | /**\r | |
639 | Registers a handler to execute within SMM.\r | |
640 | \r | |
641 | @param Handler Handler service funtion pointer.\r | |
642 | @param HandlerType Points to the handler type or NULL for root SMI handlers.\r | |
643 | @param DispatchHandle On return, contains a unique handle which can be used to later unregister the handler function.\r | |
644 | \r | |
645 | @retval EFI_SUCCESS Handler register success.\r | |
646 | @retval EFI_INVALID_PARAMETER Handler or DispatchHandle is NULL.\r | |
647 | \r | |
648 | **/\r | |
649 | EFI_STATUS\r | |
650 | EFIAPI\r | |
651 | SmiHandlerRegister (\r | |
652 | IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,\r | |
653 | IN CONST EFI_GUID *HandlerType OPTIONAL,\r | |
654 | OUT EFI_HANDLE *DispatchHandle\r | |
655 | );\r | |
656 | \r | |
657 | /**\r | |
658 | Unregister a handler in SMM.\r | |
659 | \r | |
660 | @param DispatchHandle The handle that was specified when the handler was registered.\r | |
661 | \r | |
662 | @retval EFI_SUCCESS Handler function was successfully unregistered.\r | |
663 | @retval EFI_INVALID_PARAMETER DispatchHandle does not refer to a valid handle.\r | |
664 | \r | |
665 | **/\r | |
666 | EFI_STATUS\r | |
667 | EFIAPI\r | |
668 | SmiHandlerUnRegister (\r | |
669 | IN EFI_HANDLE DispatchHandle\r | |
670 | );\r | |
671 | \r | |
672 | /**\r | |
673 | This function is the main entry point for an SMM handler dispatch\r | |
674 | or communicate-based callback.\r | |
675 | \r | |
676 | @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r | |
677 | @param Context Points to an optional handler context which was specified when the handler was registered.\r | |
678 | @param CommBuffer A pointer to a collection of data in memory that will\r | |
679 | be conveyed from a non-SMM environment into an SMM environment.\r | |
680 | @param CommBufferSize The size of the CommBuffer.\r | |
681 | \r | |
682 | @return Status Code\r | |
683 | \r | |
684 | **/\r | |
685 | EFI_STATUS\r | |
686 | EFIAPI\r | |
687 | SmmDriverDispatchHandler (\r | |
688 | IN EFI_HANDLE DispatchHandle,\r | |
689 | IN CONST VOID *Context, OPTIONAL\r | |
690 | IN OUT VOID *CommBuffer, OPTIONAL\r | |
691 | IN OUT UINTN *CommBufferSize OPTIONAL\r | |
692 | );\r | |
693 | \r | |
694 | /**\r | |
695 | This function is the main entry point for an SMM handler dispatch\r | |
696 | or communicate-based callback.\r | |
697 | \r | |
698 | @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r | |
699 | @param Context Points to an optional handler context which was specified when the handler was registered.\r | |
700 | @param CommBuffer A pointer to a collection of data in memory that will\r | |
701 | be conveyed from a non-SMM environment into an SMM environment.\r | |
702 | @param CommBufferSize The size of the CommBuffer.\r | |
703 | \r | |
704 | @return Status Code\r | |
705 | \r | |
706 | **/\r | |
707 | EFI_STATUS\r | |
708 | EFIAPI\r | |
709 | SmmLegacyBootHandler (\r | |
710 | IN EFI_HANDLE DispatchHandle,\r | |
711 | IN CONST VOID *Context, OPTIONAL\r | |
712 | IN OUT VOID *CommBuffer, OPTIONAL\r | |
713 | IN OUT UINTN *CommBufferSize OPTIONAL\r | |
714 | );\r | |
715 | \r | |
716 | /**\r | |
717 | This function is the main entry point for an SMM handler dispatch\r | |
718 | or communicate-based callback.\r | |
719 | \r | |
720 | @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r | |
721 | @param Context Points to an optional handler context which was specified when the handler was registered.\r | |
722 | @param CommBuffer A pointer to a collection of data in memory that will\r | |
723 | be conveyed from a non-SMM environment into an SMM environment.\r | |
724 | @param CommBufferSize The size of the CommBuffer.\r | |
725 | \r | |
726 | @return Status Code\r | |
727 | \r | |
728 | **/\r | |
729 | EFI_STATUS\r | |
730 | EFIAPI\r | |
731 | SmmReadyToLockHandler (\r | |
732 | IN EFI_HANDLE DispatchHandle,\r | |
733 | IN CONST VOID *Context, OPTIONAL\r | |
734 | IN OUT VOID *CommBuffer, OPTIONAL\r | |
735 | IN OUT UINTN *CommBufferSize OPTIONAL\r | |
736 | );\r | |
737 | \r | |
46ece1ff JY |
738 | /**\r |
739 | This function is the main entry point for an SMM handler dispatch\r | |
740 | or communicate-based callback.\r | |
741 | \r | |
742 | @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r | |
743 | @param Context Points to an optional handler context which was specified when the handler was registered.\r | |
744 | @param CommBuffer A pointer to a collection of data in memory that will\r | |
745 | be conveyed from a non-SMM environment into an SMM environment.\r | |
746 | @param CommBufferSize The size of the CommBuffer.\r | |
747 | \r | |
748 | @return Status Code\r | |
749 | \r | |
750 | **/\r | |
751 | EFI_STATUS\r | |
752 | EFIAPI\r | |
753 | SmmEndOfDxeHandler (\r | |
754 | IN EFI_HANDLE DispatchHandle,\r | |
755 | IN CONST VOID *Context, OPTIONAL\r | |
756 | IN OUT VOID *CommBuffer, OPTIONAL\r | |
757 | IN OUT UINTN *CommBufferSize OPTIONAL\r | |
758 | );\r | |
759 | \r | |
53ec4d7f SZ |
760 | /**\r |
761 | This function is the main entry point for an SMM handler dispatch\r | |
762 | or communicate-based callback.\r | |
763 | \r | |
764 | @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r | |
765 | @param Context Points to an optional handler context which was specified when the handler was registered.\r | |
766 | @param CommBuffer A pointer to a collection of data in memory that will\r | |
767 | be conveyed from a non-SMM environment into an SMM environment.\r | |
768 | @param CommBufferSize The size of the CommBuffer.\r | |
769 | \r | |
770 | @return Status Code\r | |
771 | \r | |
772 | **/\r | |
773 | EFI_STATUS\r | |
774 | EFIAPI\r | |
775 | SmmExitBootServicesHandler (\r | |
776 | IN EFI_HANDLE DispatchHandle,\r | |
777 | IN CONST VOID *Context, OPTIONAL\r | |
778 | IN OUT VOID *CommBuffer, OPTIONAL\r | |
779 | IN OUT UINTN *CommBufferSize OPTIONAL\r | |
780 | );\r | |
781 | \r | |
782 | /**\r | |
783 | This function is the main entry point for an SMM handler dispatch\r | |
784 | or communicate-based callback.\r | |
785 | \r | |
786 | @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r | |
787 | @param Context Points to an optional handler context which was specified when the handler was registered.\r | |
788 | @param CommBuffer A pointer to a collection of data in memory that will\r | |
789 | be conveyed from a non-SMM environment into an SMM environment.\r | |
790 | @param CommBufferSize The size of the CommBuffer.\r | |
791 | \r | |
792 | @return Status Code\r | |
793 | \r | |
794 | **/\r | |
795 | EFI_STATUS\r | |
796 | EFIAPI\r | |
797 | SmmReadyToBootHandler (\r | |
798 | IN EFI_HANDLE DispatchHandle,\r | |
799 | IN CONST VOID *Context, OPTIONAL\r | |
800 | IN OUT VOID *CommBuffer, OPTIONAL\r | |
801 | IN OUT UINTN *CommBufferSize OPTIONAL\r | |
802 | );\r | |
803 | \r | |
e42e9404 | 804 | /**\r |
805 | Place holder function until all the SMM System Table Service are available.\r | |
806 | \r | |
807 | @param Arg1 Undefined\r | |
808 | @param Arg2 Undefined\r | |
809 | @param Arg3 Undefined\r | |
810 | @param Arg4 Undefined\r | |
811 | @param Arg5 Undefined\r | |
812 | \r | |
813 | @return EFI_NOT_AVAILABLE_YET\r | |
814 | \r | |
815 | **/\r | |
816 | EFI_STATUS\r | |
817 | EFIAPI\r | |
818 | SmmEfiNotAvailableYetArg5 (\r | |
819 | UINTN Arg1,\r | |
820 | UINTN Arg2,\r | |
821 | UINTN Arg3,\r | |
822 | UINTN Arg4,\r | |
823 | UINTN Arg5\r | |
824 | );\r | |
825 | \r | |
826 | //\r | |
827 | //Functions used during debug buils\r | |
828 | //\r | |
829 | \r | |
830 | /**\r | |
831 | Traverse the discovered list for any drivers that were discovered but not loaded\r | |
832 | because the dependency experessions evaluated to false.\r | |
833 | \r | |
834 | **/\r | |
835 | VOID\r | |
836 | SmmDisplayDiscoveredNotDispatched (\r | |
837 | VOID\r | |
838 | );\r | |
839 | \r | |
840 | /**\r | |
841 | Add free SMRAM region for use by memory service.\r | |
842 | \r | |
843 | @param MemBase Base address of memory region.\r | |
844 | @param MemLength Length of the memory region.\r | |
845 | @param Type Memory type.\r | |
846 | @param Attributes Memory region state.\r | |
847 | \r | |
848 | **/\r | |
849 | VOID\r | |
850 | SmmAddMemoryRegion (\r | |
851 | IN EFI_PHYSICAL_ADDRESS MemBase,\r | |
852 | IN UINT64 MemLength,\r | |
853 | IN EFI_MEMORY_TYPE Type,\r | |
854 | IN UINT64 Attributes\r | |
855 | );\r | |
856 | \r | |
857 | /**\r | |
858 | Finds the protocol entry for the requested protocol.\r | |
859 | \r | |
860 | @param Protocol The ID of the protocol\r | |
861 | @param Create Create a new entry if not found\r | |
862 | \r | |
863 | @return Protocol entry\r | |
864 | \r | |
865 | **/\r | |
866 | PROTOCOL_ENTRY *\r | |
867 | SmmFindProtocolEntry (\r | |
868 | IN EFI_GUID *Protocol,\r | |
869 | IN BOOLEAN Create\r | |
870 | );\r | |
871 | \r | |
872 | /**\r | |
873 | Signal event for every protocol in protocol entry.\r | |
874 | \r | |
875 | @param Prot Protocol interface\r | |
876 | \r | |
877 | **/\r | |
878 | VOID\r | |
879 | SmmNotifyProtocol (\r | |
880 | IN PROTOCOL_INTERFACE *Prot\r | |
881 | );\r | |
882 | \r | |
883 | /**\r | |
884 | Finds the protocol instance for the requested handle and protocol.\r | |
885 | Note: This function doesn't do parameters checking, it's caller's responsibility\r | |
886 | to pass in valid parameters.\r | |
887 | \r | |
888 | @param Handle The handle to search the protocol on\r | |
889 | @param Protocol GUID of the protocol\r | |
890 | @param Interface The interface for the protocol being searched\r | |
891 | \r | |
892 | @return Protocol instance (NULL: Not found)\r | |
893 | \r | |
894 | **/\r | |
895 | PROTOCOL_INTERFACE *\r | |
896 | SmmFindProtocolInterface (\r | |
897 | IN IHANDLE *Handle,\r | |
898 | IN EFI_GUID *Protocol,\r | |
899 | IN VOID *Interface\r | |
900 | );\r | |
901 | \r | |
902 | /**\r | |
903 | Removes Protocol from the protocol list (but not the handle list).\r | |
904 | \r | |
905 | @param Handle The handle to remove protocol on.\r | |
906 | @param Protocol GUID of the protocol to be moved\r | |
907 | @param Interface The interface of the protocol\r | |
908 | \r | |
909 | @return Protocol Entry\r | |
910 | \r | |
911 | **/\r | |
912 | PROTOCOL_INTERFACE *\r | |
913 | SmmRemoveInterfaceFromProtocol (\r | |
914 | IN IHANDLE *Handle,\r | |
915 | IN EFI_GUID *Protocol,\r | |
916 | IN VOID *Interface\r | |
917 | );\r | |
918 | \r | |
919 | /**\r | |
920 | This is the POSTFIX version of the dependency evaluator. This code does\r | |
921 | not need to handle Before or After, as it is not valid to call this\r | |
fa542a1e | 922 | routine in this case. POSTFIX means all the math is done on top of the stack.\r |
e42e9404 | 923 | \r |
924 | @param DriverEntry DriverEntry element to update.\r | |
925 | \r | |
926 | @retval TRUE If driver is ready to run.\r | |
927 | @retval FALSE If driver is not ready to run or some fatal error\r | |
928 | was found.\r | |
929 | \r | |
930 | **/\r | |
931 | BOOLEAN\r | |
932 | SmmIsSchedulable (\r | |
933 | IN EFI_SMM_DRIVER_ENTRY *DriverEntry\r | |
934 | );\r | |
935 | \r | |
84edd20b SZ |
936 | //\r |
937 | // SmramProfile\r | |
938 | //\r | |
939 | \r | |
940 | /**\r | |
941 | Initialize SMRAM profile.\r | |
942 | \r | |
943 | **/\r | |
944 | VOID\r | |
945 | SmramProfileInit (\r | |
946 | VOID\r | |
947 | );\r | |
948 | \r | |
e524f680 SZ |
949 | /**\r |
950 | Install SMRAM profile protocol.\r | |
951 | \r | |
952 | **/\r | |
953 | VOID\r | |
954 | SmramProfileInstallProtocol (\r | |
955 | VOID\r | |
956 | );\r | |
957 | \r | |
84edd20b SZ |
958 | /**\r |
959 | Register SMM image to SMRAM profile.\r | |
960 | \r | |
961 | @param DriverEntry SMM image info.\r | |
962 | @param RegisterToDxe Register image to DXE.\r | |
963 | \r | |
e524f680 SZ |
964 | @return EFI_SUCCESS Register successfully.\r |
965 | @return EFI_UNSUPPORTED Memory profile unsupported,\r | |
966 | or memory profile for the image is not required.\r | |
967 | @return EFI_OUT_OF_RESOURCES No enough resource for this register.\r | |
84edd20b SZ |
968 | \r |
969 | **/\r | |
e524f680 | 970 | EFI_STATUS\r |
84edd20b SZ |
971 | RegisterSmramProfileImage (\r |
972 | IN EFI_SMM_DRIVER_ENTRY *DriverEntry,\r | |
973 | IN BOOLEAN RegisterToDxe\r | |
974 | );\r | |
975 | \r | |
976 | /**\r | |
977 | Unregister image from SMRAM profile.\r | |
978 | \r | |
979 | @param DriverEntry SMM image info.\r | |
980 | @param UnregisterToDxe Unregister image from DXE.\r | |
981 | \r | |
e524f680 SZ |
982 | @return EFI_SUCCESS Unregister successfully.\r |
983 | @return EFI_UNSUPPORTED Memory profile unsupported,\r | |
984 | or memory profile for the image is not required.\r | |
985 | @return EFI_NOT_FOUND The image is not found.\r | |
84edd20b SZ |
986 | \r |
987 | **/\r | |
e524f680 | 988 | EFI_STATUS\r |
84edd20b SZ |
989 | UnregisterSmramProfileImage (\r |
990 | IN EFI_SMM_DRIVER_ENTRY *DriverEntry,\r | |
991 | IN BOOLEAN UnregisterToDxe\r | |
992 | );\r | |
993 | \r | |
994 | /**\r | |
995 | Update SMRAM profile information.\r | |
996 | \r | |
997 | @param CallerAddress Address of caller who call Allocate or Free.\r | |
998 | @param Action This Allocate or Free action.\r | |
999 | @param MemoryType Memory type.\r | |
e524f680 | 1000 | EfiMaxMemoryType means the MemoryType is unknown.\r |
84edd20b SZ |
1001 | @param Size Buffer size.\r |
1002 | @param Buffer Buffer address.\r | |
e524f680 SZ |
1003 | @param ActionString String for memory profile action.\r |
1004 | Only needed for user defined allocate action.\r | |
84edd20b | 1005 | \r |
e524f680 SZ |
1006 | @return EFI_SUCCESS Memory profile is updated.\r |
1007 | @return EFI_UNSUPPORTED Memory profile is unsupported,\r | |
1008 | or memory profile for the image is not required,\r | |
1009 | or memory profile for the memory type is not required.\r | |
1010 | @return EFI_ACCESS_DENIED It is during memory profile data getting.\r | |
1011 | @return EFI_ABORTED Memory profile recording is not enabled.\r | |
1012 | @return EFI_OUT_OF_RESOURCES No enough resource to update memory profile for allocate action.\r | |
1013 | @return EFI_NOT_FOUND No matched allocate info found for free action.\r | |
84edd20b SZ |
1014 | \r |
1015 | **/\r | |
e524f680 SZ |
1016 | EFI_STATUS\r |
1017 | EFIAPI\r | |
84edd20b | 1018 | SmmCoreUpdateProfile (\r |
e524f680 SZ |
1019 | IN PHYSICAL_ADDRESS CallerAddress,\r |
1020 | IN MEMORY_PROFILE_ACTION Action,\r | |
1021 | IN EFI_MEMORY_TYPE MemoryType, // Valid for AllocatePages/AllocatePool\r | |
1022 | IN UINTN Size, // Valid for AllocatePages/FreePages/AllocatePool\r | |
1023 | IN VOID *Buffer,\r | |
1024 | IN CHAR8 *ActionString OPTIONAL\r | |
84edd20b SZ |
1025 | );\r |
1026 | \r | |
1027 | /**\r | |
1028 | Register SMRAM profile handler.\r | |
1029 | \r | |
1030 | **/\r | |
1031 | VOID\r | |
1032 | RegisterSmramProfileHandler (\r | |
1033 | VOID\r | |
1034 | );\r | |
1035 | \r | |
1036 | /**\r | |
1037 | SMRAM profile ready to lock callback function.\r | |
1038 | \r | |
1039 | **/\r | |
1040 | VOID\r | |
1041 | SmramProfileReadyToLock (\r | |
1042 | VOID\r | |
1043 | );\r | |
1044 | \r | |
285a682c JY |
1045 | /**\r |
1046 | Initialize MemoryAttributes support.\r | |
1047 | **/\r | |
1048 | VOID\r | |
1049 | EFIAPI\r | |
1050 | SmmCoreInitializeMemoryAttributesTable (\r | |
1051 | VOID\r | |
1052 | );\r | |
1053 | \r | |
1054 | /**\r | |
1055 | This function returns a copy of the current memory map. The map is an array of\r | |
1056 | memory descriptors, each of which describes a contiguous block of memory.\r | |
1057 | \r | |
1058 | @param[in, out] MemoryMapSize A pointer to the size, in bytes, of the\r | |
1059 | MemoryMap buffer. On input, this is the size of\r | |
1060 | the buffer allocated by the caller. On output,\r | |
1061 | it is the size of the buffer returned by the\r | |
1062 | firmware if the buffer was large enough, or the\r | |
1063 | size of the buffer needed to contain the map if\r | |
1064 | the buffer was too small.\r | |
1065 | @param[in, out] MemoryMap A pointer to the buffer in which firmware places\r | |
1066 | the current memory map.\r | |
1067 | @param[out] MapKey A pointer to the location in which firmware\r | |
1068 | returns the key for the current memory map.\r | |
1069 | @param[out] DescriptorSize A pointer to the location in which firmware\r | |
1070 | returns the size, in bytes, of an individual\r | |
1071 | EFI_MEMORY_DESCRIPTOR.\r | |
1072 | @param[out] DescriptorVersion A pointer to the location in which firmware\r | |
1073 | returns the version number associated with the\r | |
1074 | EFI_MEMORY_DESCRIPTOR.\r | |
1075 | \r | |
1076 | @retval EFI_SUCCESS The memory map was returned in the MemoryMap\r | |
1077 | buffer.\r | |
1078 | @retval EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small. The current\r | |
1079 | buffer size needed to hold the memory map is\r | |
1080 | returned in MemoryMapSize.\r | |
1081 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r | |
1082 | \r | |
1083 | **/\r | |
1084 | EFI_STATUS\r | |
1085 | EFIAPI\r | |
1086 | SmmCoreGetMemoryMap (\r | |
1087 | IN OUT UINTN *MemoryMapSize,\r | |
1088 | IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,\r | |
1089 | OUT UINTN *MapKey,\r | |
1090 | OUT UINTN *DescriptorSize,\r | |
1091 | OUT UINT32 *DescriptorVersion\r | |
1092 | );\r | |
1093 | \r | |
ca41f3f4 JY |
1094 | /**\r |
1095 | Initialize SmiHandler profile feature.\r | |
1096 | **/\r | |
1097 | VOID\r | |
1098 | SmmCoreInitializeSmiHandlerProfile (\r | |
1099 | VOID\r | |
1100 | );\r | |
1101 | \r | |
1102 | /**\r | |
1103 | This function is called by SmmChildDispatcher module to report\r | |
1104 | a new SMI handler is registered, to SmmCore.\r | |
1105 | \r | |
1106 | @param This The protocol instance\r | |
1107 | @param HandlerGuid The GUID to identify the type of the handler.\r | |
1108 | For the SmmChildDispatch protocol, the HandlerGuid\r | |
1109 | must be the GUID of SmmChildDispatch protocol.\r | |
1110 | @param Handler The SMI handler.\r | |
1111 | @param CallerAddress The address of the module who registers the SMI handler.\r | |
1112 | @param Context The context of the SMI handler.\r | |
1113 | For the SmmChildDispatch protocol, the Context\r | |
1114 | must match the one defined for SmmChildDispatch protocol.\r | |
1115 | @param ContextSize The size of the context in bytes.\r | |
1116 | For the SmmChildDispatch protocol, the Context\r | |
1117 | must match the one defined for SmmChildDispatch protocol.\r | |
1118 | \r | |
1119 | @retval EFI_SUCCESS The information is recorded.\r | |
1120 | @retval EFI_OUT_OF_RESOURCES There is no enough resource to record the information.\r | |
1121 | **/\r | |
1122 | EFI_STATUS\r | |
1123 | EFIAPI\r | |
1124 | SmiHandlerProfileRegisterHandler (\r | |
1125 | IN SMI_HANDLER_PROFILE_PROTOCOL *This,\r | |
1126 | IN EFI_GUID *HandlerGuid,\r | |
1127 | IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,\r | |
1128 | IN PHYSICAL_ADDRESS CallerAddress,\r | |
1129 | IN VOID *Context, OPTIONAL\r | |
1130 | IN UINTN ContextSize OPTIONAL\r | |
1131 | );\r | |
1132 | \r | |
1133 | /**\r | |
1134 | This function is called by SmmChildDispatcher module to report\r | |
1135 | an existing SMI handler is unregistered, to SmmCore.\r | |
1136 | \r | |
1137 | @param This The protocol instance\r | |
1138 | @param HandlerGuid The GUID to identify the type of the handler.\r | |
1139 | For the SmmChildDispatch protocol, the HandlerGuid\r | |
1140 | must be the GUID of SmmChildDispatch protocol.\r | |
1141 | @param Handler The SMI handler.\r | |
1c3ac4b9 JY |
1142 | @param Context The context of the SMI handler.\r |
1143 | If it is NOT NULL, it will be used to check what is registered.\r | |
1144 | @param ContextSize The size of the context in bytes.\r | |
1145 | If Context is NOT NULL, it will be used to check what is registered.\r | |
ca41f3f4 JY |
1146 | \r |
1147 | @retval EFI_SUCCESS The original record is removed.\r | |
1148 | @retval EFI_NOT_FOUND There is no record for the HandlerGuid and handler.\r | |
1149 | **/\r | |
1150 | EFI_STATUS\r | |
1151 | EFIAPI\r | |
1152 | SmiHandlerProfileUnregisterHandler (\r | |
1153 | IN SMI_HANDLER_PROFILE_PROTOCOL *This,\r | |
1154 | IN EFI_GUID *HandlerGuid,\r | |
1c3ac4b9 JY |
1155 | IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,\r |
1156 | IN VOID *Context, OPTIONAL\r | |
1157 | IN UINTN ContextSize OPTIONAL\r | |
ca41f3f4 JY |
1158 | );\r |
1159 | \r | |
84edd20b SZ |
1160 | extern UINTN mFullSmramRangeCount;\r |
1161 | extern EFI_SMRAM_DESCRIPTOR *mFullSmramRanges;\r | |
1162 | \r | |
285a682c JY |
1163 | extern EFI_SMM_DRIVER_ENTRY *mSmmCoreDriverEntry;\r |
1164 | \r | |
0b256fb1 JY |
1165 | extern EFI_LOADED_IMAGE_PROTOCOL *mSmmCoreLoadedImage;\r |
1166 | \r | |
63aa86b0 SZ |
1167 | //\r |
1168 | // Page management\r | |
1169 | //\r | |
1170 | \r | |
1171 | typedef struct {\r | |
1172 | LIST_ENTRY Link;\r | |
1173 | UINTN NumberOfPages;\r | |
1174 | } FREE_PAGE_LIST;\r | |
1175 | \r | |
1176 | extern LIST_ENTRY mSmmMemoryMap;\r | |
1177 | \r | |
1178 | //\r | |
1179 | // Pool management\r | |
1180 | //\r | |
1181 | \r | |
1182 | //\r | |
1183 | // MIN_POOL_SHIFT must not be less than 5\r | |
1184 | //\r | |
1185 | #define MIN_POOL_SHIFT 6\r | |
1186 | #define MIN_POOL_SIZE (1 << MIN_POOL_SHIFT)\r | |
1187 | \r | |
1188 | //\r | |
1189 | // MAX_POOL_SHIFT must not be less than EFI_PAGE_SHIFT - 1\r | |
1190 | //\r | |
1191 | #define MAX_POOL_SHIFT (EFI_PAGE_SHIFT - 1)\r | |
1192 | #define MAX_POOL_SIZE (1 << MAX_POOL_SHIFT)\r | |
1193 | \r | |
1194 | //\r | |
1195 | // MAX_POOL_INDEX are calculated by maximum and minimum pool sizes\r | |
1196 | //\r | |
1197 | #define MAX_POOL_INDEX (MAX_POOL_SHIFT - MIN_POOL_SHIFT + 1)\r | |
1198 | \r | |
861c8dff SZ |
1199 | #define POOL_HEAD_SIGNATURE SIGNATURE_32('p','h','d','0')\r |
1200 | \r | |
63aa86b0 | 1201 | typedef struct {\r |
861c8dff SZ |
1202 | UINT32 Signature;\r |
1203 | BOOLEAN Available;\r | |
1204 | EFI_MEMORY_TYPE Type;\r | |
1205 | UINTN Size;\r | |
63aa86b0 SZ |
1206 | } POOL_HEADER;\r |
1207 | \r | |
861c8dff SZ |
1208 | #define POOL_TAIL_SIGNATURE SIGNATURE_32('p','t','a','l')\r |
1209 | \r | |
1210 | typedef struct {\r | |
1211 | UINT32 Signature;\r | |
1212 | UINT32 Reserved;\r | |
1213 | UINTN Size;\r | |
1214 | } POOL_TAIL;\r | |
1215 | \r | |
1216 | #define POOL_OVERHEAD (sizeof(POOL_HEADER) + sizeof(POOL_TAIL))\r | |
1217 | \r | |
1218 | #define HEAD_TO_TAIL(a) \\r | |
1219 | ((POOL_TAIL *) (((CHAR8 *) (a)) + (a)->Size - sizeof(POOL_TAIL)));\r | |
1220 | \r | |
63aa86b0 SZ |
1221 | typedef struct {\r |
1222 | POOL_HEADER Header;\r | |
1223 | LIST_ENTRY Link;\r | |
1224 | } FREE_POOL_HEADER;\r | |
1225 | \r | |
5f4d3e17 JY |
1226 | typedef enum {\r |
1227 | SmmPoolTypeCode,\r | |
1228 | SmmPoolTypeData,\r | |
1229 | SmmPoolTypeMax,\r | |
1230 | } SMM_POOL_TYPE;\r | |
1231 | \r | |
1232 | extern LIST_ENTRY mSmmPoolLists[SmmPoolTypeMax][MAX_POOL_INDEX];\r | |
63aa86b0 | 1233 | \r |
e42e9404 | 1234 | #endif\r |