]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/UefiMemoryAllocationProfileLib/DxeMemoryProfileLib.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Library / UefiMemoryAllocationProfileLib / DxeMemoryProfileLib.c
CommitLineData
1439c255
SZ
1/** @file\r
2 Support routines for memory profile for Dxe phase drivers.\r
3\r
d1102dba
LG
4 Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php.\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
1439c255
SZ
12\r
13**/\r
14\r
15\r
16#include <Uefi.h>\r
17\r
18\r
19#include <Library/UefiBootServicesTableLib.h>\r
20#include <Library/DebugLib.h>\r
21\r
22#include <Guid/MemoryProfile.h>\r
23\r
24EDKII_MEMORY_PROFILE_PROTOCOL *mLibProfileProtocol;\r
25\r
26/**\r
27 The constructor function initializes memory profile for DXE phase.\r
28\r
29 @param ImageHandle The firmware allocated handle for the EFI image.\r
30 @param SystemTable A pointer to the EFI System Table.\r
31\r
32 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
33\r
34**/\r
35EFI_STATUS\r
36EFIAPI\r
37MemoryProfileLibConstructor (\r
38 IN EFI_HANDLE ImageHandle,\r
39 IN EFI_SYSTEM_TABLE *SystemTable\r
40 )\r
41{\r
42 EFI_STATUS Status;\r
43\r
44 Status = gBS->LocateProtocol (\r
45 &gEdkiiMemoryProfileGuid,\r
46 NULL,\r
47 (VOID **) &mLibProfileProtocol\r
48 );\r
49 if (EFI_ERROR (Status)) {\r
50 mLibProfileProtocol = NULL;\r
51 }\r
52\r
53 return EFI_SUCCESS;\r
54}\r
55\r
56/**\r
57 Record memory profile of multilevel caller.\r
58\r
59 @param[in] CallerAddress Address of caller.\r
60 @param[in] Action Memory profile action.\r
61 @param[in] MemoryType Memory type.\r
62 EfiMaxMemoryType means the MemoryType is unknown.\r
63 @param[in] Buffer Buffer address.\r
64 @param[in] Size Buffer size.\r
65 @param[in] ActionString String for memory profile action.\r
66 Only needed for user defined allocate action.\r
67\r
68 @return EFI_SUCCESS Memory profile is updated.\r
69 @return EFI_UNSUPPORTED Memory profile is unsupported,\r
70 or memory profile for the image is not required,\r
71 or memory profile for the memory type is not required.\r
72 @return EFI_ACCESS_DENIED It is during memory profile data getting.\r
73 @return EFI_ABORTED Memory profile recording is not enabled.\r
74 @return EFI_OUT_OF_RESOURCES No enough resource to update memory profile for allocate action.\r
75 @return EFI_NOT_FOUND No matched allocate info found for free action.\r
76\r
77**/\r
78EFI_STATUS\r
79EFIAPI\r
80MemoryProfileLibRecord (\r
81 IN PHYSICAL_ADDRESS CallerAddress,\r
82 IN MEMORY_PROFILE_ACTION Action,\r
83 IN EFI_MEMORY_TYPE MemoryType,\r
84 IN VOID *Buffer,\r
85 IN UINTN Size,\r
86 IN CHAR8 *ActionString OPTIONAL\r
87 )\r
88{\r
89 if (mLibProfileProtocol == NULL) {\r
90 return EFI_UNSUPPORTED;\r
91 }\r
92 return mLibProfileProtocol->Record (\r
93 mLibProfileProtocol,\r
94 CallerAddress,\r
95 Action,\r
96 MemoryType,\r
97 Buffer,\r
98 Size,\r
99 ActionString\r
100 );\r
101}\r
102\r