2 Memory profile data structure.
4 Copyright (c) 2014, 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.
15 #ifndef _MEMORY_PROFILE_H_
16 #define _MEMORY_PROFILE_H_
19 // For BIOS MemoryType (0 ~ EfiMaxMemoryType), it is recorded in UsageByType[MemoryType]. (Each valid entry has one entry)
20 // For OS MemoryType (0x80000000 ~ 0xFFFFFFFF), it is recorded in UsageByType[EfiMaxMemoryType]. (All types are combined into one entry)
27 } MEMORY_PROFILE_COMMON_HEADER
;
29 #define MEMORY_PROFILE_CONTEXT_SIGNATURE SIGNATURE_32 ('M','P','C','T')
30 #define MEMORY_PROFILE_CONTEXT_REVISION 0x0001
33 MEMORY_PROFILE_COMMON_HEADER Header
;
34 UINT64 CurrentTotalUsage
;
35 UINT64 PeakTotalUsage
;
36 UINT64 CurrentTotalUsageByType
[EfiMaxMemoryType
+ 1];
37 UINT64 PeakTotalUsageByType
[EfiMaxMemoryType
+ 1];
38 UINT64 TotalImageSize
;
41 } MEMORY_PROFILE_CONTEXT
;
43 #define MEMORY_PROFILE_DRIVER_INFO_SIGNATURE SIGNATURE_32 ('M','P','D','I')
44 #define MEMORY_PROFILE_DRIVER_INFO_REVISION 0x0001
47 MEMORY_PROFILE_COMMON_HEADER Header
;
49 PHYSICAL_ADDRESS ImageBase
;
51 PHYSICAL_ADDRESS EntryPoint
;
52 UINT16 ImageSubsystem
;
53 EFI_FV_FILETYPE FileType
;
55 UINT32 AllocRecordCount
;
58 UINT64 CurrentUsageByType
[EfiMaxMemoryType
+ 1];
59 UINT64 PeakUsageByType
[EfiMaxMemoryType
+ 1];
60 } MEMORY_PROFILE_DRIVER_INFO
;
63 MemoryProfileActionAllocatePages
= 1,
64 MemoryProfileActionFreePages
= 2,
65 MemoryProfileActionAllocatePool
= 3,
66 MemoryProfileActionFreePool
= 4,
67 } MEMORY_PROFILE_ACTION
;
69 #define MEMORY_PROFILE_ALLOC_INFO_SIGNATURE SIGNATURE_32 ('M','P','A','I')
70 #define MEMORY_PROFILE_ALLOC_INFO_REVISION 0x0001
73 MEMORY_PROFILE_COMMON_HEADER Header
;
74 PHYSICAL_ADDRESS CallerAddress
;
77 MEMORY_PROFILE_ACTION Action
;
78 EFI_MEMORY_TYPE MemoryType
;
79 PHYSICAL_ADDRESS Buffer
;
81 } MEMORY_PROFILE_ALLOC_INFO
;
83 #define MEMORY_PROFILE_DESCRIPTOR_SIGNATURE SIGNATURE_32 ('M','P','D','R')
84 #define MEMORY_PROFILE_DESCRIPTOR_REVISION 0x0001
87 MEMORY_PROFILE_COMMON_HEADER Header
;
88 PHYSICAL_ADDRESS Address
;
90 } MEMORY_PROFILE_DESCRIPTOR
;
92 #define MEMORY_PROFILE_FREE_MEMORY_SIGNATURE SIGNATURE_32 ('M','P','R','M')
93 #define MEMORY_PROFILE_FREE_MEMORY_REVISION 0x0001
96 MEMORY_PROFILE_COMMON_HEADER Header
;
97 UINT64 TotalFreeMemoryPages
;
98 UINT32 FreeMemoryEntryCount
;
100 //MEMORY_PROFILE_DESCRIPTOR MemoryDescriptor[FreeMemoryEntryCount];
101 } MEMORY_PROFILE_FREE_MEMORY
;
103 #define MEMORY_PROFILE_MEMORY_RANGE_SIGNATURE SIGNATURE_32 ('M','P','M','R')
104 #define MEMORY_PROFILE_MEMORY_RANGE_REVISION 0x0001
107 MEMORY_PROFILE_COMMON_HEADER Header
;
108 UINT32 MemoryRangeCount
;
110 //MEMORY_PROFILE_DESCRIPTOR MemoryDescriptor[MemoryRangeCount];
111 } MEMORY_PROFILE_MEMORY_RANGE
;
114 // UEFI memory profile layout:
115 // +--------------------------------+
117 // +--------------------------------+
118 // | DRIVER_INFO(1) |
119 // +--------------------------------+
120 // | ALLOC_INFO(1, 1) |
121 // +--------------------------------+
122 // | ALLOC_INFO(1, m1) |
123 // +--------------------------------+
124 // | DRIVER_INFO(n) |
125 // +--------------------------------+
126 // | ALLOC_INFO(n, 1) |
127 // +--------------------------------+
128 // | ALLOC_INFO(n, mn) |
129 // +--------------------------------+
132 typedef struct _EDKII_MEMORY_PROFILE_PROTOCOL EDKII_MEMORY_PROFILE_PROTOCOL
;
135 Get memory profile data.
137 @param[in] This The EDKII_MEMORY_PROFILE_PROTOCOL instance.
138 @param[in, out] ProfileSize On entry, points to the size in bytes of the ProfileBuffer.
139 On return, points to the size of the data returned in ProfileBuffer.
140 @param[out] ProfileBuffer Profile buffer.
142 @return EFI_SUCCESS Get the memory profile data successfully.
143 @return EFI_BUFFER_TO_SMALL The ProfileSize is too small for the resulting data.
144 ProfileSize is updated with the size required.
149 (EFIAPI
*EDKII_MEMORY_PROFILE_GET_DATA
)(
150 IN EDKII_MEMORY_PROFILE_PROTOCOL
*This
,
151 IN OUT UINT64
*ProfileSize
,
152 OUT VOID
*ProfileBuffer
156 Register image to memory profile.
158 @param[in] This The EDKII_MEMORY_PROFILE_PROTOCOL instance.
159 @param[in] FilePath File path of the image.
160 @param[in] ImageBase Image base address.
161 @param[in] ImageSize Image size.
162 @param[in] FileType File type of the image.
164 @return EFI_SUCCESS Register success.
165 @return EFI_OUT_OF_RESOURCE No enough resource for this register.
170 (EFIAPI
*EDKII_MEMORY_PROFILE_REGISTER_IMAGE
)(
171 IN EDKII_MEMORY_PROFILE_PROTOCOL
*This
,
172 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
173 IN PHYSICAL_ADDRESS ImageBase
,
175 IN EFI_FV_FILETYPE FileType
179 Unregister image from memory profile.
181 @param[in] This The EDKII_MEMORY_PROFILE_PROTOCOL instance.
182 @param[in] FilePath File path of the image.
183 @param[in] ImageBase Image base address.
184 @param[in] ImageSize Image size.
186 @return EFI_SUCCESS Unregister success.
187 @return EFI_NOT_FOUND The image is not found.
192 (EFIAPI
*EDKII_MEMORY_PROFILE_UNREGISTER_IMAGE
)(
193 IN EDKII_MEMORY_PROFILE_PROTOCOL
*This
,
194 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
195 IN PHYSICAL_ADDRESS ImageBase
,
199 struct _EDKII_MEMORY_PROFILE_PROTOCOL
{
200 EDKII_MEMORY_PROFILE_GET_DATA GetData
;
201 EDKII_MEMORY_PROFILE_REGISTER_IMAGE RegisterImage
;
202 EDKII_MEMORY_PROFILE_UNREGISTER_IMAGE UnregisterImage
;
206 // SMRAM profile layout:
207 // +--------------------------------+
209 // +--------------------------------+
210 // | DRIVER_INFO(1) |
211 // +--------------------------------+
212 // | ALLOC_INFO(1, 1) |
213 // +--------------------------------+
214 // | ALLOC_INFO(1, m1) |
215 // +--------------------------------+
216 // | DRIVER_INFO(n) |
217 // +--------------------------------+
218 // | ALLOC_INFO(n, 1) |
219 // +--------------------------------+
220 // | ALLOC_INFO(n, mn) |
221 // +--------------------------------+
223 // +--------------------------------+
224 // | FREE MEMORY DESCRIPTOR(1) |
225 // +--------------------------------+
226 // | FREE MEMORY DESCRIPTOR(p) |
227 // +--------------------------------+
229 // +--------------------------------+
230 // | MEMORY RANGE DESCRIPTOR(1) |
231 // +--------------------------------+
232 // | MEMORY RANGE DESCRIPTOR(q) |
233 // +--------------------------------+
237 // SMRAM profile command
239 #define SMRAM_PROFILE_COMMAND_GET_PROFILE_INFO 0x1
240 #define SMRAM_PROFILE_COMMAND_GET_PROFILE_DATA 0x2
242 // Below 2 commands are now used by ECP only and only valid before SmmReadyToLock
244 #define SMRAM_PROFILE_COMMAND_REGISTER_IMAGE 0x3
245 #define SMRAM_PROFILE_COMMAND_UNREGISTER_IMAGE 0x4
251 } SMRAM_PROFILE_PARAMETER_HEADER
;
254 SMRAM_PROFILE_PARAMETER_HEADER Header
;
256 } SMRAM_PROFILE_PARAMETER_GET_PROFILE_INFO
;
259 SMRAM_PROFILE_PARAMETER_HEADER Header
;
261 PHYSICAL_ADDRESS ProfileBuffer
;
262 } SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA
;
265 SMRAM_PROFILE_PARAMETER_HEADER Header
;
267 PHYSICAL_ADDRESS ImageBuffer
;
269 } SMRAM_PROFILE_PARAMETER_REGISTER_IMAGE
;
272 SMRAM_PROFILE_PARAMETER_HEADER Header
;
274 PHYSICAL_ADDRESS ImageBuffer
;
276 } SMRAM_PROFILE_PARAMETER_UNREGISTER_IMAGE
;
279 #define EDKII_MEMORY_PROFILE_GUID { \
280 0x821c9a09, 0x541a, 0x40f6, 0x9f, 0x43, 0xa, 0xd1, 0x93, 0xa1, 0x2c, 0xfe \
283 extern EFI_GUID gEdkiiMemoryProfileGuid
;