2 The internal header file includes the common header files, defines
3 internal structure and functions used by SmmCore module.
5 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are licensed and made available
7 under the terms and conditions of the BSD License which accompanies this
8 distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 #include <Protocol/DxeSmmReadyToLock.h>
22 #include <Protocol/SmmReadyToLock.h>
23 #include <Protocol/SmmEndOfDxe.h>
24 #include <Protocol/CpuIo2.h>
25 #include <Protocol/SmmCommunication.h>
26 #include <Protocol/SmmAccess2.h>
27 #include <Protocol/FirmwareVolume2.h>
28 #include <Protocol/LoadedImage.h>
29 #include <Protocol/DevicePath.h>
30 #include <Protocol/Security.h>
31 #include <Protocol/Security2.h>
32 #include <Protocol/SmmExitBootServices.h>
33 #include <Protocol/SmmLegacyBoot.h>
34 #include <Protocol/SmmReadyToBoot.h>
36 #include <Guid/Apriori.h>
37 #include <Guid/EventGroup.h>
38 #include <Guid/EventLegacyBios.h>
39 #include <Guid/ZeroGuid.h>
40 #include <Guid/MemoryProfile.h>
42 #include <Library/BaseLib.h>
43 #include <Library/BaseMemoryLib.h>
44 #include <Library/PeCoffLib.h>
45 #include <Library/PeCoffGetEntryPointLib.h>
46 #include <Library/CacheMaintenanceLib.h>
47 #include <Library/DebugLib.h>
48 #include <Library/ReportStatusCodeLib.h>
49 #include <Library/MemoryAllocationLib.h>
50 #include <Library/DevicePathLib.h>
51 #include <Library/UefiLib.h>
52 #include <Library/UefiBootServicesTableLib.h>
53 #include <Library/PcdLib.h>
54 #include <Library/SmmCorePlatformHookLib.h>
55 #include <Library/PerformanceLib.h>
56 #include <Library/TimerLib.h>
57 #include <Library/HobLib.h>
58 #include <Library/SmmMemLib.h>
60 #include "PiSmmCorePrivateData.h"
63 // Used to build a table of SMI Handlers that the SMM Core registers
66 EFI_SMM_HANDLER_ENTRY_POINT2 Handler
;
67 EFI_GUID
*HandlerType
;
68 EFI_HANDLE DispatchHandle
;
70 } SMM_CORE_SMI_HANDLERS
;
73 // Structure for recording the state of an SMM Driver
75 #define EFI_SMM_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('s', 'd','r','v')
79 LIST_ENTRY Link
; // mDriverList
81 LIST_ENTRY ScheduledLink
; // mScheduledQueue
85 EFI_DEVICE_PATH_PROTOCOL
*FvFileDevicePath
;
86 EFI_FIRMWARE_VOLUME2_PROTOCOL
*Fv
;
93 EFI_GUID BeforeAfterGuid
;
98 BOOLEAN DepexProtocolError
;
100 EFI_HANDLE ImageHandle
;
101 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
103 // Image EntryPoint in SMRAM
105 PHYSICAL_ADDRESS ImageEntryPoint
;
107 // Image Buffer in SMRAM
109 PHYSICAL_ADDRESS ImageBuffer
;
114 } EFI_SMM_DRIVER_ENTRY
;
116 #define EFI_HANDLE_SIGNATURE SIGNATURE_32('h','n','d','l')
119 /// IHANDLE - contains a list of protocol handles
123 /// All handles list of IHANDLE
124 LIST_ENTRY AllHandles
;
125 /// List of PROTOCOL_INTERFACE's for this handle
126 LIST_ENTRY Protocols
;
130 #define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)
132 #define PROTOCOL_ENTRY_SIGNATURE SIGNATURE_32('p','r','t','e')
135 /// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol
136 /// database. Each handler that supports this protocol is listed, along
137 /// with a list of registered notifies.
141 /// Link Entry inserted to mProtocolDatabase
142 LIST_ENTRY AllEntries
;
143 /// ID of the protocol
145 /// All protocol interfaces
146 LIST_ENTRY Protocols
;
147 /// Registerd notification handlers
151 #define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('p','i','f','c')
154 /// PROTOCOL_INTERFACE - each protocol installed on a handle is tracked
155 /// with a protocol interface structure
159 /// Link on IHANDLE.Protocols
163 /// Link on PROTOCOL_ENTRY.Protocols
164 LIST_ENTRY ByProtocol
;
166 PROTOCOL_ENTRY
*Protocol
;
167 /// The interface value
169 } PROTOCOL_INTERFACE
;
171 #define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')
174 /// PROTOCOL_NOTIFY - used for each register notification for a protocol
178 PROTOCOL_ENTRY
*Protocol
;
179 /// All notifications for this protocol
181 /// Notification function
182 EFI_SMM_NOTIFY_FN Function
;
183 /// Last position notified
184 LIST_ENTRY
*Position
;
188 // SMM Core Global Variables
190 extern SMM_CORE_PRIVATE_DATA
*gSmmCorePrivate
;
191 extern EFI_SMM_SYSTEM_TABLE2 gSmmCoreSmst
;
192 extern LIST_ENTRY gHandleList
;
193 extern EFI_PHYSICAL_ADDRESS gLoadModuleAtFixAddressSmramBase
;
196 Called to initialize the memory service.
198 @param SmramRangeCount Number of SMRAM Regions
199 @param SmramRanges Pointer to SMRAM Descriptors
203 SmmInitializeMemoryServices (
204 IN UINTN SmramRangeCount
,
205 IN EFI_SMRAM_DESCRIPTOR
*SmramRanges
209 The SmmInstallConfigurationTable() function is used to maintain the list
210 of configuration tables that are stored in the System Management System
211 Table. The list is stored as an array of (GUID, Pointer) pairs. The list
212 must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.
214 @param SystemTable A pointer to the SMM System Table (SMST).
215 @param Guid A pointer to the GUID for the entry to add, update, or remove.
216 @param Table A pointer to the buffer of the table to add.
217 @param TableSize The size of the table to install.
219 @retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed.
220 @retval EFI_INVALID_PARAMETER Guid is not valid.
221 @retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry.
222 @retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation.
227 SmmInstallConfigurationTable (
228 IN CONST EFI_SMM_SYSTEM_TABLE2
*SystemTable
,
229 IN CONST EFI_GUID
*Guid
,
235 Wrapper function to SmmInstallProtocolInterfaceNotify. This is the public API which
236 Calls the private one which contains a BOOLEAN parameter for notifications
238 @param UserHandle The handle to install the protocol handler on,
239 or NULL if a new handle is to be allocated
240 @param Protocol The protocol to add to the handle
241 @param InterfaceType Indicates whether Interface is supplied in
243 @param Interface The interface for the protocol being added
250 SmmInstallProtocolInterface (
251 IN OUT EFI_HANDLE
*UserHandle
,
252 IN EFI_GUID
*Protocol
,
253 IN EFI_INTERFACE_TYPE InterfaceType
,
258 Allocates pages from the memory map.
260 @param Type The type of allocation to perform
261 @param MemoryType The type of memory to turn the allocated pages
263 @param NumberOfPages The number of pages to allocate
264 @param Memory A pointer to receive the base allocated memory
267 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
268 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
269 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
270 @retval EFI_SUCCESS Pages successfully allocated.
276 IN EFI_ALLOCATE_TYPE Type
,
277 IN EFI_MEMORY_TYPE MemoryType
,
278 IN UINTN NumberOfPages
,
279 OUT EFI_PHYSICAL_ADDRESS
*Memory
283 Allocates pages from the memory map.
285 @param Type The type of allocation to perform
286 @param MemoryType The type of memory to turn the allocated pages
288 @param NumberOfPages The number of pages to allocate
289 @param Memory A pointer to receive the base allocated memory
292 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
293 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
294 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
295 @retval EFI_SUCCESS Pages successfully allocated.
300 SmmInternalAllocatePages (
301 IN EFI_ALLOCATE_TYPE Type
,
302 IN EFI_MEMORY_TYPE MemoryType
,
303 IN UINTN NumberOfPages
,
304 OUT EFI_PHYSICAL_ADDRESS
*Memory
308 Frees previous allocated pages.
310 @param Memory Base address of memory being freed
311 @param NumberOfPages The number of pages to free
313 @retval EFI_NOT_FOUND Could not find the entry that covers the range
314 @retval EFI_INVALID_PARAMETER Address not aligned
315 @return EFI_SUCCESS Pages successfully freed.
321 IN EFI_PHYSICAL_ADDRESS Memory
,
322 IN UINTN NumberOfPages
326 Frees previous allocated pages.
328 @param Memory Base address of memory being freed
329 @param NumberOfPages The number of pages to free
331 @retval EFI_NOT_FOUND Could not find the entry that covers the range
332 @retval EFI_INVALID_PARAMETER Address not aligned
333 @return EFI_SUCCESS Pages successfully freed.
338 SmmInternalFreePages (
339 IN EFI_PHYSICAL_ADDRESS Memory
,
340 IN UINTN NumberOfPages
344 Allocate pool of a particular type.
346 @param PoolType Type of pool to allocate
347 @param Size The amount of pool to allocate
348 @param Buffer The address to return a pointer to the allocated
351 @retval EFI_INVALID_PARAMETER PoolType not valid
352 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
353 @retval EFI_SUCCESS Pool successfully allocated.
359 IN EFI_MEMORY_TYPE PoolType
,
365 Allocate pool of a particular type.
367 @param PoolType Type of pool to allocate
368 @param Size The amount of pool to allocate
369 @param Buffer The address to return a pointer to the allocated
372 @retval EFI_INVALID_PARAMETER PoolType not valid
373 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
374 @retval EFI_SUCCESS Pool successfully allocated.
379 SmmInternalAllocatePool (
380 IN EFI_MEMORY_TYPE PoolType
,
388 @param Buffer The allocated pool entry to free
390 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
391 @retval EFI_SUCCESS Pool successfully freed.
403 @param Buffer The allocated pool entry to free
405 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
406 @retval EFI_SUCCESS Pool successfully freed.
411 SmmInternalFreePool (
416 Installs a protocol interface into the boot services environment.
418 @param UserHandle The handle to install the protocol handler on,
419 or NULL if a new handle is to be allocated
420 @param Protocol The protocol to add to the handle
421 @param InterfaceType Indicates whether Interface is supplied in
423 @param Interface The interface for the protocol being added
424 @param Notify indicates whether notify the notification list
427 @retval EFI_INVALID_PARAMETER Invalid parameter
428 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
429 @retval EFI_SUCCESS Protocol interface successfully installed
433 SmmInstallProtocolInterfaceNotify (
434 IN OUT EFI_HANDLE
*UserHandle
,
435 IN EFI_GUID
*Protocol
,
436 IN EFI_INTERFACE_TYPE InterfaceType
,
442 Uninstalls all instances of a protocol:interfacer from a handle.
443 If the last protocol interface is remove from the handle, the
446 @param UserHandle The handle to remove the protocol handler from
447 @param Protocol The protocol, of protocol:interface, to remove
448 @param Interface The interface, of protocol:interface, to remove
450 @retval EFI_INVALID_PARAMETER Protocol is NULL.
451 @retval EFI_SUCCESS Protocol interface successfully uninstalled.
456 SmmUninstallProtocolInterface (
457 IN EFI_HANDLE UserHandle
,
458 IN EFI_GUID
*Protocol
,
463 Queries a handle to determine if it supports a specified protocol.
465 @param UserHandle The handle being queried.
466 @param Protocol The published unique identifier of the protocol.
467 @param Interface Supplies the address where a pointer to the
468 corresponding Protocol Interface is returned.
470 @return The requested protocol interface for the handle
476 IN EFI_HANDLE UserHandle
,
477 IN EFI_GUID
*Protocol
,
482 Add a new protocol notification record for the request protocol.
484 @param Protocol The requested protocol to add the notify
486 @param Function Points to the notification function
487 @param Registration Returns the registration record
489 @retval EFI_INVALID_PARAMETER Invalid parameter
490 @retval EFI_SUCCESS Successfully returned the registration record
496 SmmRegisterProtocolNotify (
497 IN CONST EFI_GUID
*Protocol
,
498 IN EFI_SMM_NOTIFY_FN Function
,
499 OUT VOID
**Registration
503 Locates the requested handle(s) and returns them in Buffer.
505 @param SearchType The type of search to perform to locate the
507 @param Protocol The protocol to search for
508 @param SearchKey Dependant on SearchType
509 @param BufferSize On input the size of Buffer. On output the
510 size of data returned.
511 @param Buffer The buffer to return the results in
513 @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is
514 returned in BufferSize.
515 @retval EFI_INVALID_PARAMETER Invalid parameter
516 @retval EFI_SUCCESS Successfully found the requested handle(s) and
517 returns them in Buffer.
523 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
524 IN EFI_GUID
*Protocol OPTIONAL
,
525 IN VOID
*SearchKey OPTIONAL
,
526 IN OUT UINTN
*BufferSize
,
527 OUT EFI_HANDLE
*Buffer
531 Return the first Protocol Interface that matches the Protocol GUID. If
532 Registration is pasased in return a Protocol Instance that was just add
533 to the system. If Retistration is NULL return the first Protocol Interface
536 @param Protocol The protocol to search for
537 @param Registration Optional Registration Key returned from
538 RegisterProtocolNotify()
539 @param Interface Return the Protocol interface (instance).
541 @retval EFI_SUCCESS If a valid Interface is returned
542 @retval EFI_INVALID_PARAMETER Invalid parameter
543 @retval EFI_NOT_FOUND Protocol interface not found
549 IN EFI_GUID
*Protocol
,
550 IN VOID
*Registration OPTIONAL
,
555 Manage SMI of a particular type.
557 @param HandlerType Points to the handler type or NULL for root SMI handlers.
558 @param Context Points to an optional context buffer.
559 @param CommBuffer Points to the optional communication buffer.
560 @param CommBufferSize Points to the size of the optional communication buffer.
562 @retval EFI_SUCCESS Interrupt source was processed successfully but not quiesced.
563 @retval EFI_INTERRUPT_PENDING One or more SMI sources could not be quiesced.
564 @retval EFI_WARN_INTERRUPT_SOURCE_PENDING Interrupt source was not handled or quiesced.
565 @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED Interrupt source was handled and quiesced.
571 IN CONST EFI_GUID
*HandlerType
,
572 IN CONST VOID
*Context OPTIONAL
,
573 IN OUT VOID
*CommBuffer OPTIONAL
,
574 IN OUT UINTN
*CommBufferSize OPTIONAL
578 Registers a handler to execute within SMM.
580 @param Handler Handler service funtion pointer.
581 @param HandlerType Points to the handler type or NULL for root SMI handlers.
582 @param DispatchHandle On return, contains a unique handle which can be used to later unregister the handler function.
584 @retval EFI_SUCCESS Handler register success.
585 @retval EFI_INVALID_PARAMETER Handler or DispatchHandle is NULL.
591 IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler
,
592 IN CONST EFI_GUID
*HandlerType OPTIONAL
,
593 OUT EFI_HANDLE
*DispatchHandle
597 Unregister a handler in SMM.
599 @param DispatchHandle The handle that was specified when the handler was registered.
601 @retval EFI_SUCCESS Handler function was successfully unregistered.
602 @retval EFI_INVALID_PARAMETER DispatchHandle does not refer to a valid handle.
607 SmiHandlerUnRegister (
608 IN EFI_HANDLE DispatchHandle
612 This function is the main entry point for an SMM handler dispatch
613 or communicate-based callback.
615 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
616 @param Context Points to an optional handler context which was specified when the handler was registered.
617 @param CommBuffer A pointer to a collection of data in memory that will
618 be conveyed from a non-SMM environment into an SMM environment.
619 @param CommBufferSize The size of the CommBuffer.
626 SmmDriverDispatchHandler (
627 IN EFI_HANDLE DispatchHandle
,
628 IN CONST VOID
*Context
, OPTIONAL
629 IN OUT VOID
*CommBuffer
, OPTIONAL
630 IN OUT UINTN
*CommBufferSize OPTIONAL
634 This function is the main entry point for an SMM handler dispatch
635 or communicate-based callback.
637 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
638 @param Context Points to an optional handler context which was specified when the handler was registered.
639 @param CommBuffer A pointer to a collection of data in memory that will
640 be conveyed from a non-SMM environment into an SMM environment.
641 @param CommBufferSize The size of the CommBuffer.
648 SmmLegacyBootHandler (
649 IN EFI_HANDLE DispatchHandle
,
650 IN CONST VOID
*Context
, OPTIONAL
651 IN OUT VOID
*CommBuffer
, OPTIONAL
652 IN OUT UINTN
*CommBufferSize OPTIONAL
656 This function is the main entry point for an SMM handler dispatch
657 or communicate-based callback.
659 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
660 @param Context Points to an optional handler context which was specified when the handler was registered.
661 @param CommBuffer A pointer to a collection of data in memory that will
662 be conveyed from a non-SMM environment into an SMM environment.
663 @param CommBufferSize The size of the CommBuffer.
670 SmmReadyToLockHandler (
671 IN EFI_HANDLE DispatchHandle
,
672 IN CONST VOID
*Context
, OPTIONAL
673 IN OUT VOID
*CommBuffer
, OPTIONAL
674 IN OUT UINTN
*CommBufferSize OPTIONAL
678 This function is the main entry point for an SMM handler dispatch
679 or communicate-based callback.
681 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
682 @param Context Points to an optional handler context which was specified when the handler was registered.
683 @param CommBuffer A pointer to a collection of data in memory that will
684 be conveyed from a non-SMM environment into an SMM environment.
685 @param CommBufferSize The size of the CommBuffer.
693 IN EFI_HANDLE DispatchHandle
,
694 IN CONST VOID
*Context
, OPTIONAL
695 IN OUT VOID
*CommBuffer
, OPTIONAL
696 IN OUT UINTN
*CommBufferSize OPTIONAL
700 This function is the main entry point for an SMM handler dispatch
701 or communicate-based callback.
703 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
704 @param Context Points to an optional handler context which was specified when the handler was registered.
705 @param CommBuffer A pointer to a collection of data in memory that will
706 be conveyed from a non-SMM environment into an SMM environment.
707 @param CommBufferSize The size of the CommBuffer.
714 SmmExitBootServicesHandler (
715 IN EFI_HANDLE DispatchHandle
,
716 IN CONST VOID
*Context
, OPTIONAL
717 IN OUT VOID
*CommBuffer
, OPTIONAL
718 IN OUT UINTN
*CommBufferSize OPTIONAL
722 This function is the main entry point for an SMM handler dispatch
723 or communicate-based callback.
725 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
726 @param Context Points to an optional handler context which was specified when the handler was registered.
727 @param CommBuffer A pointer to a collection of data in memory that will
728 be conveyed from a non-SMM environment into an SMM environment.
729 @param CommBufferSize The size of the CommBuffer.
736 SmmReadyToBootHandler (
737 IN EFI_HANDLE DispatchHandle
,
738 IN CONST VOID
*Context
, OPTIONAL
739 IN OUT VOID
*CommBuffer
, OPTIONAL
740 IN OUT UINTN
*CommBufferSize OPTIONAL
744 Place holder function until all the SMM System Table Service are available.
746 @param Arg1 Undefined
747 @param Arg2 Undefined
748 @param Arg3 Undefined
749 @param Arg4 Undefined
750 @param Arg5 Undefined
752 @return EFI_NOT_AVAILABLE_YET
757 SmmEfiNotAvailableYetArg5 (
766 //Functions used during debug buils
770 Traverse the discovered list for any drivers that were discovered but not loaded
771 because the dependency experessions evaluated to false.
775 SmmDisplayDiscoveredNotDispatched (
780 Add free SMRAM region for use by memory service.
782 @param MemBase Base address of memory region.
783 @param MemLength Length of the memory region.
784 @param Type Memory type.
785 @param Attributes Memory region state.
790 IN EFI_PHYSICAL_ADDRESS MemBase
,
792 IN EFI_MEMORY_TYPE Type
,
797 Finds the protocol entry for the requested protocol.
799 @param Protocol The ID of the protocol
800 @param Create Create a new entry if not found
802 @return Protocol entry
806 SmmFindProtocolEntry (
807 IN EFI_GUID
*Protocol
,
812 Signal event for every protocol in protocol entry.
814 @param Prot Protocol interface
819 IN PROTOCOL_INTERFACE
*Prot
823 Finds the protocol instance for the requested handle and protocol.
824 Note: This function doesn't do parameters checking, it's caller's responsibility
825 to pass in valid parameters.
827 @param Handle The handle to search the protocol on
828 @param Protocol GUID of the protocol
829 @param Interface The interface for the protocol being searched
831 @return Protocol instance (NULL: Not found)
835 SmmFindProtocolInterface (
837 IN EFI_GUID
*Protocol
,
842 Removes Protocol from the protocol list (but not the handle list).
844 @param Handle The handle to remove protocol on.
845 @param Protocol GUID of the protocol to be moved
846 @param Interface The interface of the protocol
848 @return Protocol Entry
852 SmmRemoveInterfaceFromProtocol (
854 IN EFI_GUID
*Protocol
,
859 This is the POSTFIX version of the dependency evaluator. This code does
860 not need to handle Before or After, as it is not valid to call this
861 routine in this case. POSTFIX means all the math is done on top of the stack.
863 @param DriverEntry DriverEntry element to update.
865 @retval TRUE If driver is ready to run.
866 @retval FALSE If driver is not ready to run or some fatal error
872 IN EFI_SMM_DRIVER_ENTRY
*DriverEntry
880 Initialize SMRAM profile.
889 Install SMRAM profile protocol.
893 SmramProfileInstallProtocol (
898 Register SMM image to SMRAM profile.
900 @param DriverEntry SMM image info.
901 @param RegisterToDxe Register image to DXE.
903 @return EFI_SUCCESS Register successfully.
904 @return EFI_UNSUPPORTED Memory profile unsupported,
905 or memory profile for the image is not required.
906 @return EFI_OUT_OF_RESOURCES No enough resource for this register.
910 RegisterSmramProfileImage (
911 IN EFI_SMM_DRIVER_ENTRY
*DriverEntry
,
912 IN BOOLEAN RegisterToDxe
916 Unregister image from SMRAM profile.
918 @param DriverEntry SMM image info.
919 @param UnregisterToDxe Unregister image from DXE.
921 @return EFI_SUCCESS Unregister successfully.
922 @return EFI_UNSUPPORTED Memory profile unsupported,
923 or memory profile for the image is not required.
924 @return EFI_NOT_FOUND The image is not found.
928 UnregisterSmramProfileImage (
929 IN EFI_SMM_DRIVER_ENTRY
*DriverEntry
,
930 IN BOOLEAN UnregisterToDxe
934 Update SMRAM profile information.
936 @param CallerAddress Address of caller who call Allocate or Free.
937 @param Action This Allocate or Free action.
938 @param MemoryType Memory type.
939 EfiMaxMemoryType means the MemoryType is unknown.
940 @param Size Buffer size.
941 @param Buffer Buffer address.
942 @param ActionString String for memory profile action.
943 Only needed for user defined allocate action.
945 @return EFI_SUCCESS Memory profile is updated.
946 @return EFI_UNSUPPORTED Memory profile is unsupported,
947 or memory profile for the image is not required,
948 or memory profile for the memory type is not required.
949 @return EFI_ACCESS_DENIED It is during memory profile data getting.
950 @return EFI_ABORTED Memory profile recording is not enabled.
951 @return EFI_OUT_OF_RESOURCES No enough resource to update memory profile for allocate action.
952 @return EFI_NOT_FOUND No matched allocate info found for free action.
957 SmmCoreUpdateProfile (
958 IN PHYSICAL_ADDRESS CallerAddress
,
959 IN MEMORY_PROFILE_ACTION Action
,
960 IN EFI_MEMORY_TYPE MemoryType
, // Valid for AllocatePages/AllocatePool
961 IN UINTN Size
, // Valid for AllocatePages/FreePages/AllocatePool
963 IN CHAR8
*ActionString OPTIONAL
967 Register SMRAM profile handler.
971 RegisterSmramProfileHandler (
976 SMRAM profile ready to lock callback function.
980 SmramProfileReadyToLock (
984 extern UINTN mFullSmramRangeCount
;
985 extern EFI_SMRAM_DESCRIPTOR
*mFullSmramRanges
;
987 extern EFI_LOADED_IMAGE_PROTOCOL
*mSmmCoreLoadedImage
;
998 extern LIST_ENTRY mSmmMemoryMap
;
1005 // MIN_POOL_SHIFT must not be less than 5
1007 #define MIN_POOL_SHIFT 6
1008 #define MIN_POOL_SIZE (1 << MIN_POOL_SHIFT)
1011 // MAX_POOL_SHIFT must not be less than EFI_PAGE_SHIFT - 1
1013 #define MAX_POOL_SHIFT (EFI_PAGE_SHIFT - 1)
1014 #define MAX_POOL_SIZE (1 << MAX_POOL_SHIFT)
1017 // MAX_POOL_INDEX are calculated by maximum and minimum pool sizes
1019 #define MAX_POOL_INDEX (MAX_POOL_SHIFT - MIN_POOL_SHIFT + 1)
1031 extern LIST_ENTRY mSmmPoolLists
[MAX_POOL_INDEX
];