2 Memory profile data structure.
4 Copyright (c) 2014 - 2015, 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 - 1), 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)
21 // For OEM MemoryType (0x70000000 ~ 0x7FFFFFFF), it is recorded in UsageByType[EfiMaxMemoryType + 1]. (All types are combined into one entry)
28 } MEMORY_PROFILE_COMMON_HEADER
;
30 #define MEMORY_PROFILE_CONTEXT_SIGNATURE SIGNATURE_32 ('M','P','C','T')
31 #define MEMORY_PROFILE_CONTEXT_REVISION 0x0002
34 MEMORY_PROFILE_COMMON_HEADER Header
;
35 UINT64 CurrentTotalUsage
;
36 UINT64 PeakTotalUsage
;
37 UINT64 CurrentTotalUsageByType
[EfiMaxMemoryType
+ 2];
38 UINT64 PeakTotalUsageByType
[EfiMaxMemoryType
+ 2];
39 UINT64 TotalImageSize
;
42 } MEMORY_PROFILE_CONTEXT
;
44 #define MEMORY_PROFILE_DRIVER_INFO_SIGNATURE SIGNATURE_32 ('M','P','D','I')
45 #define MEMORY_PROFILE_DRIVER_INFO_REVISION 0x0002
48 MEMORY_PROFILE_COMMON_HEADER Header
;
50 PHYSICAL_ADDRESS ImageBase
;
52 PHYSICAL_ADDRESS EntryPoint
;
53 UINT16 ImageSubsystem
;
54 EFI_FV_FILETYPE FileType
;
56 UINT32 AllocRecordCount
;
59 UINT64 CurrentUsageByType
[EfiMaxMemoryType
+ 2];
60 UINT64 PeakUsageByType
[EfiMaxMemoryType
+ 2];
61 } MEMORY_PROFILE_DRIVER_INFO
;
64 MemoryProfileActionAllocatePages
= 1,
65 MemoryProfileActionFreePages
= 2,
66 MemoryProfileActionAllocatePool
= 3,
67 MemoryProfileActionFreePool
= 4,
68 } MEMORY_PROFILE_ACTION
;
70 #define MEMORY_PROFILE_ALLOC_INFO_SIGNATURE SIGNATURE_32 ('M','P','A','I')
71 #define MEMORY_PROFILE_ALLOC_INFO_REVISION 0x0001
74 MEMORY_PROFILE_COMMON_HEADER Header
;
75 PHYSICAL_ADDRESS CallerAddress
;
78 MEMORY_PROFILE_ACTION Action
;
79 EFI_MEMORY_TYPE MemoryType
;
80 PHYSICAL_ADDRESS Buffer
;
82 } MEMORY_PROFILE_ALLOC_INFO
;
84 #define MEMORY_PROFILE_DESCRIPTOR_SIGNATURE SIGNATURE_32 ('M','P','D','R')
85 #define MEMORY_PROFILE_DESCRIPTOR_REVISION 0x0001
88 MEMORY_PROFILE_COMMON_HEADER Header
;
89 PHYSICAL_ADDRESS Address
;
91 } MEMORY_PROFILE_DESCRIPTOR
;
93 #define MEMORY_PROFILE_FREE_MEMORY_SIGNATURE SIGNATURE_32 ('M','P','R','M')
94 #define MEMORY_PROFILE_FREE_MEMORY_REVISION 0x0001
97 MEMORY_PROFILE_COMMON_HEADER Header
;
98 UINT64 TotalFreeMemoryPages
;
99 UINT32 FreeMemoryEntryCount
;
101 //MEMORY_PROFILE_DESCRIPTOR MemoryDescriptor[FreeMemoryEntryCount];
102 } MEMORY_PROFILE_FREE_MEMORY
;
104 #define MEMORY_PROFILE_MEMORY_RANGE_SIGNATURE SIGNATURE_32 ('M','P','M','R')
105 #define MEMORY_PROFILE_MEMORY_RANGE_REVISION 0x0001
108 MEMORY_PROFILE_COMMON_HEADER Header
;
109 UINT32 MemoryRangeCount
;
111 //MEMORY_PROFILE_DESCRIPTOR MemoryDescriptor[MemoryRangeCount];
112 } MEMORY_PROFILE_MEMORY_RANGE
;
115 // UEFI memory profile layout:
116 // +--------------------------------+
118 // +--------------------------------+
119 // | DRIVER_INFO(1) |
120 // +--------------------------------+
121 // | ALLOC_INFO(1, 1) |
122 // +--------------------------------+
123 // | ALLOC_INFO(1, m1) |
124 // +--------------------------------+
125 // | DRIVER_INFO(n) |
126 // +--------------------------------+
127 // | ALLOC_INFO(n, 1) |
128 // +--------------------------------+
129 // | ALLOC_INFO(n, mn) |
130 // +--------------------------------+
133 typedef struct _EDKII_MEMORY_PROFILE_PROTOCOL EDKII_MEMORY_PROFILE_PROTOCOL
;
136 Get memory profile data.
138 @param[in] This The EDKII_MEMORY_PROFILE_PROTOCOL instance.
139 @param[in, out] ProfileSize On entry, points to the size in bytes of the ProfileBuffer.
140 On return, points to the size of the data returned in ProfileBuffer.
141 @param[out] ProfileBuffer Profile buffer.
143 @return EFI_SUCCESS Get the memory profile data successfully.
144 @return EFI_BUFFER_TO_SMALL The ProfileSize is too small for the resulting data.
145 ProfileSize is updated with the size required.
150 (EFIAPI
*EDKII_MEMORY_PROFILE_GET_DATA
)(
151 IN EDKII_MEMORY_PROFILE_PROTOCOL
*This
,
152 IN OUT UINT64
*ProfileSize
,
153 OUT VOID
*ProfileBuffer
157 Register image to memory profile.
159 @param[in] This The EDKII_MEMORY_PROFILE_PROTOCOL instance.
160 @param[in] FilePath File path of the image.
161 @param[in] ImageBase Image base address.
162 @param[in] ImageSize Image size.
163 @param[in] FileType File type of the image.
165 @return EFI_SUCCESS Register success.
166 @return EFI_OUT_OF_RESOURCE No enough resource for this register.
171 (EFIAPI
*EDKII_MEMORY_PROFILE_REGISTER_IMAGE
)(
172 IN EDKII_MEMORY_PROFILE_PROTOCOL
*This
,
173 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
174 IN PHYSICAL_ADDRESS ImageBase
,
176 IN EFI_FV_FILETYPE FileType
180 Unregister image from memory profile.
182 @param[in] This The EDKII_MEMORY_PROFILE_PROTOCOL instance.
183 @param[in] FilePath File path of the image.
184 @param[in] ImageBase Image base address.
185 @param[in] ImageSize Image size.
187 @return EFI_SUCCESS Unregister success.
188 @return EFI_NOT_FOUND The image is not found.
193 (EFIAPI
*EDKII_MEMORY_PROFILE_UNREGISTER_IMAGE
)(
194 IN EDKII_MEMORY_PROFILE_PROTOCOL
*This
,
195 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
196 IN PHYSICAL_ADDRESS ImageBase
,
200 struct _EDKII_MEMORY_PROFILE_PROTOCOL
{
201 EDKII_MEMORY_PROFILE_GET_DATA GetData
;
202 EDKII_MEMORY_PROFILE_REGISTER_IMAGE RegisterImage
;
203 EDKII_MEMORY_PROFILE_UNREGISTER_IMAGE UnregisterImage
;
207 // SMRAM profile layout:
208 // +--------------------------------+
210 // +--------------------------------+
211 // | DRIVER_INFO(1) |
212 // +--------------------------------+
213 // | ALLOC_INFO(1, 1) |
214 // +--------------------------------+
215 // | ALLOC_INFO(1, m1) |
216 // +--------------------------------+
217 // | DRIVER_INFO(n) |
218 // +--------------------------------+
219 // | ALLOC_INFO(n, 1) |
220 // +--------------------------------+
221 // | ALLOC_INFO(n, mn) |
222 // +--------------------------------+
224 // +--------------------------------+
225 // | FREE MEMORY DESCRIPTOR(1) |
226 // +--------------------------------+
227 // | FREE MEMORY DESCRIPTOR(p) |
228 // +--------------------------------+
230 // +--------------------------------+
231 // | MEMORY RANGE DESCRIPTOR(1) |
232 // +--------------------------------+
233 // | MEMORY RANGE DESCRIPTOR(q) |
234 // +--------------------------------+
238 // SMRAM profile command
240 #define SMRAM_PROFILE_COMMAND_GET_PROFILE_INFO 0x1
241 #define SMRAM_PROFILE_COMMAND_GET_PROFILE_DATA 0x2
243 // Below 2 commands are now used by ECP only and only valid before SmmReadyToLock
245 #define SMRAM_PROFILE_COMMAND_REGISTER_IMAGE 0x3
246 #define SMRAM_PROFILE_COMMAND_UNREGISTER_IMAGE 0x4
252 } SMRAM_PROFILE_PARAMETER_HEADER
;
255 SMRAM_PROFILE_PARAMETER_HEADER Header
;
257 } SMRAM_PROFILE_PARAMETER_GET_PROFILE_INFO
;
260 SMRAM_PROFILE_PARAMETER_HEADER Header
;
262 PHYSICAL_ADDRESS ProfileBuffer
;
263 } SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA
;
266 SMRAM_PROFILE_PARAMETER_HEADER Header
;
268 PHYSICAL_ADDRESS ImageBuffer
;
270 } SMRAM_PROFILE_PARAMETER_REGISTER_IMAGE
;
273 SMRAM_PROFILE_PARAMETER_HEADER Header
;
275 PHYSICAL_ADDRESS ImageBuffer
;
277 } SMRAM_PROFILE_PARAMETER_UNREGISTER_IMAGE
;
280 #define EDKII_MEMORY_PROFILE_GUID { \
281 0x821c9a09, 0x541a, 0x40f6, 0x9f, 0x43, 0xa, 0xd1, 0x93, 0xa1, 0x2c, 0xfe \
284 extern EFI_GUID gEdkiiMemoryProfileGuid
;