2 Support routines for memory profile for Dxe phase drivers.
4 Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #include <Library/UefiBootServicesTableLib.h>
14 #include <Library/DebugLib.h>
16 #include <Guid/MemoryProfile.h>
18 EDKII_MEMORY_PROFILE_PROTOCOL
*mLibProfileProtocol
;
21 The constructor function initializes memory profile for DXE phase.
23 @param ImageHandle The firmware allocated handle for the EFI image.
24 @param SystemTable A pointer to the EFI System Table.
26 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
31 MemoryProfileLibConstructor (
32 IN EFI_HANDLE ImageHandle
,
33 IN EFI_SYSTEM_TABLE
*SystemTable
38 Status
= gBS
->LocateProtocol (
39 &gEdkiiMemoryProfileGuid
,
41 (VOID
**) &mLibProfileProtocol
43 if (EFI_ERROR (Status
)) {
44 mLibProfileProtocol
= NULL
;
51 Record memory profile of multilevel caller.
53 @param[in] CallerAddress Address of caller.
54 @param[in] Action Memory profile action.
55 @param[in] MemoryType Memory type.
56 EfiMaxMemoryType means the MemoryType is unknown.
57 @param[in] Buffer Buffer address.
58 @param[in] Size Buffer size.
59 @param[in] ActionString String for memory profile action.
60 Only needed for user defined allocate action.
62 @return EFI_SUCCESS Memory profile is updated.
63 @return EFI_UNSUPPORTED Memory profile is unsupported,
64 or memory profile for the image is not required,
65 or memory profile for the memory type is not required.
66 @return EFI_ACCESS_DENIED It is during memory profile data getting.
67 @return EFI_ABORTED Memory profile recording is not enabled.
68 @return EFI_OUT_OF_RESOURCES No enough resource to update memory profile for allocate action.
69 @return EFI_NOT_FOUND No matched allocate info found for free action.
74 MemoryProfileLibRecord (
75 IN PHYSICAL_ADDRESS CallerAddress
,
76 IN MEMORY_PROFILE_ACTION Action
,
77 IN EFI_MEMORY_TYPE MemoryType
,
80 IN CHAR8
*ActionString OPTIONAL
83 if (mLibProfileProtocol
== NULL
) {
84 return EFI_UNSUPPORTED
;
86 return mLibProfileProtocol
->Record (