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
11 #include <Library/UefiBootServicesTableLib.h>
12 #include <Library/DebugLib.h>
14 #include <Guid/MemoryProfile.h>
16 EDKII_MEMORY_PROFILE_PROTOCOL
*mLibProfileProtocol
;
19 The constructor function initializes memory profile for DXE phase.
21 @param ImageHandle The firmware allocated handle for the EFI image.
22 @param SystemTable A pointer to the EFI System Table.
24 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
29 MemoryProfileLibConstructor (
30 IN EFI_HANDLE ImageHandle
,
31 IN EFI_SYSTEM_TABLE
*SystemTable
36 Status
= gBS
->LocateProtocol (
37 &gEdkiiMemoryProfileGuid
,
39 (VOID
**)&mLibProfileProtocol
41 if (EFI_ERROR (Status
)) {
42 mLibProfileProtocol
= NULL
;
49 Record memory profile of multilevel caller.
51 @param[in] CallerAddress Address of caller.
52 @param[in] Action Memory profile action.
53 @param[in] MemoryType Memory type.
54 EfiMaxMemoryType means the MemoryType is unknown.
55 @param[in] Buffer Buffer address.
56 @param[in] Size Buffer size.
57 @param[in] ActionString String for memory profile action.
58 Only needed for user defined allocate action.
60 @return EFI_SUCCESS Memory profile is updated.
61 @return EFI_UNSUPPORTED Memory profile is unsupported,
62 or memory profile for the image is not required,
63 or memory profile for the memory type is not required.
64 @return EFI_ACCESS_DENIED It is during memory profile data getting.
65 @return EFI_ABORTED Memory profile recording is not enabled.
66 @return EFI_OUT_OF_RESOURCES No enough resource to update memory profile for allocate action.
67 @return EFI_NOT_FOUND No matched allocate info found for free action.
72 MemoryProfileLibRecord (
73 IN PHYSICAL_ADDRESS CallerAddress
,
74 IN MEMORY_PROFILE_ACTION Action
,
75 IN EFI_MEMORY_TYPE MemoryType
,
78 IN CHAR8
*ActionString OPTIONAL
81 if (mLibProfileProtocol
== NULL
) {
82 return EFI_UNSUPPORTED
;
85 return mLibProfileProtocol
->Record (