2 Support routines for memory profile for Dxe phase drivers.
4 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #include <Library/UefiBootServicesTableLib.h>
20 #include <Library/DebugLib.h>
22 #include <Guid/MemoryProfile.h>
24 EDKII_MEMORY_PROFILE_PROTOCOL
*mLibProfileProtocol
;
27 The constructor function initializes memory profile for DXE phase.
29 @param ImageHandle The firmware allocated handle for the EFI image.
30 @param SystemTable A pointer to the EFI System Table.
32 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
37 MemoryProfileLibConstructor (
38 IN EFI_HANDLE ImageHandle
,
39 IN EFI_SYSTEM_TABLE
*SystemTable
44 Status
= gBS
->LocateProtocol (
45 &gEdkiiMemoryProfileGuid
,
47 (VOID
**) &mLibProfileProtocol
49 if (EFI_ERROR (Status
)) {
50 mLibProfileProtocol
= NULL
;
57 Record memory profile of multilevel caller.
59 @param[in] CallerAddress Address of caller.
60 @param[in] Action Memory profile action.
61 @param[in] MemoryType Memory type.
62 EfiMaxMemoryType means the MemoryType is unknown.
63 @param[in] Buffer Buffer address.
64 @param[in] Size Buffer size.
65 @param[in] ActionString String for memory profile action.
66 Only needed for user defined allocate action.
68 @return EFI_SUCCESS Memory profile is updated.
69 @return EFI_UNSUPPORTED Memory profile is unsupported,
70 or memory profile for the image is not required,
71 or memory profile for the memory type is not required.
72 @return EFI_ACCESS_DENIED It is during memory profile data getting.
73 @return EFI_ABORTED Memory profile recording is not enabled.
74 @return EFI_OUT_OF_RESOURCES No enough resource to update memory profile for allocate action.
75 @return EFI_NOT_FOUND No matched allocate info found for free action.
80 MemoryProfileLibRecord (
81 IN PHYSICAL_ADDRESS CallerAddress
,
82 IN MEMORY_PROFILE_ACTION Action
,
83 IN EFI_MEMORY_TYPE MemoryType
,
86 IN CHAR8
*ActionString OPTIONAL
89 if (mLibProfileProtocol
== NULL
) {
90 return EFI_UNSUPPORTED
;
92 return mLibProfileProtocol
->Record (