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