9#ifndef _MEMORY_PROFILE_H_
10#define _MEMORY_PROFILE_H_
26#define MEMORY_PROFILE_CONTEXT_SIGNATURE SIGNATURE_32 ('M','P','C','T')
27#define MEMORY_PROFILE_CONTEXT_REVISION 0x0002
31 UINT64 CurrentTotalUsage;
32 UINT64 PeakTotalUsage;
33 UINT64 CurrentTotalUsageByType[EfiMaxMemoryType + 2];
34 UINT64 PeakTotalUsageByType[EfiMaxMemoryType + 2];
35 UINT64 TotalImageSize;
40#define MEMORY_PROFILE_DRIVER_INFO_SIGNATURE SIGNATURE_32 ('M','P','D','I')
41#define MEMORY_PROFILE_DRIVER_INFO_REVISION 0x0003
46 PHYSICAL_ADDRESS ImageBase;
48 PHYSICAL_ADDRESS EntryPoint;
49 UINT16 ImageSubsystem;
50 EFI_FV_FILETYPE FileType;
52 UINT32 AllocRecordCount;
55 UINT64 CurrentUsageByType[EfiMaxMemoryType + 2];
56 UINT64 PeakUsageByType[EfiMaxMemoryType + 2];
57 UINT16 PdbStringOffset;
63 MemoryProfileActionAllocatePages = 1,
64 MemoryProfileActionFreePages = 2,
65 MemoryProfileActionAllocatePool = 3,
66 MemoryProfileActionFreePool = 4,
67} MEMORY_PROFILE_ACTION;
85#define MEMORY_PROFILE_ACTION_BASIC_MASK 0xF
90#define MEMORY_PROFILE_ACTION_EXTENSION_MASK 0xFFF0
91#define MEMORY_PROFILE_ACTION_EXTENSION_LIB_MASK 0x8000
92#define MEMORY_PROFILE_ACTION_EXTENSION_REALLOC_MASK 0x0200
93#define MEMORY_PROFILE_ACTION_EXTENSION_COPY_MASK 0x0100
94#define MEMORY_PROFILE_ACTION_EXTENSION_ZERO_MASK 0x0080
95#define MEMORY_PROFILE_ACTION_EXTENSION_ALIGN_MASK 0x0040
96#define MEMORY_PROFILE_ACTION_EXTENSION_MEM_TYPE_MASK 0x0030
97#define MEMORY_PROFILE_ACTION_EXTENSION_MEM_TYPE_BASIC 0x0000
98#define MEMORY_PROFILE_ACTION_EXTENSION_MEM_TYPE_RUNTIME 0x0010
99#define MEMORY_PROFILE_ACTION_EXTENSION_MEM_TYPE_RESERVED 0x0020
104#define MEMORY_PROFILE_ACTION_LIB_ALLOCATE_PAGES 0x8001
105#define MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_PAGES 0x8011
106#define MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_PAGES 0x8021
107#define MEMORY_PROFILE_ACTION_LIB_FREE_PAGES 0x8002
108#define MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_PAGES 0x8041
109#define MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RUNTIME_PAGES 0x8051
110#define MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RESERVED_PAGES 0x8061
111#define MEMORY_PROFILE_ACTION_LIB_FREE_ALIGNED_PAGES 0x8042
112#define MEMORY_PROFILE_ACTION_LIB_ALLOCATE_POOL 0x8003
113#define MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_POOL 0x8013
114#define MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_POOL 0x8023
115#define MEMORY_PROFILE_ACTION_LIB_FREE_POOL 0x8004
116#define MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ZERO_POOL 0x8083
117#define MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_ZERO_POOL 0x8093
118#define MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_ZERO_POOL 0x80a3
119#define MEMORY_PROFILE_ACTION_LIB_ALLOCATE_COPY_POOL 0x8103
120#define MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_COPY_POOL 0x8113
121#define MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_COPY_POOL 0x8123
122#define MEMORY_PROFILE_ACTION_LIB_REALLOCATE_POOL 0x8203
123#define MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RUNTIME_POOL 0x8213
124#define MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RESERVED_POOL 0x8223
134#define MEMORY_PROFILE_ACTION_USER_DEFINED_MASK 0x80000000
136#define MEMORY_PROFILE_ALLOC_INFO_SIGNATURE SIGNATURE_32 ('M','P','A','I')
137#define MEMORY_PROFILE_ALLOC_INFO_REVISION 0x0002
141 PHYSICAL_ADDRESS CallerAddress;
144 UINT16 ActionStringOffset;
145 MEMORY_PROFILE_ACTION Action;
147 PHYSICAL_ADDRESS Buffer;
152#define MEMORY_PROFILE_DESCRIPTOR_SIGNATURE SIGNATURE_32 ('M','P','D','R')
153#define MEMORY_PROFILE_DESCRIPTOR_REVISION 0x0001
157 PHYSICAL_ADDRESS Address;
161#define MEMORY_PROFILE_FREE_MEMORY_SIGNATURE SIGNATURE_32 ('M','P','R','M')
162#define MEMORY_PROFILE_FREE_MEMORY_REVISION 0x0001
166 UINT64 TotalFreeMemoryPages;
167 UINT32 FreeMemoryEntryCount;
172#define MEMORY_PROFILE_MEMORY_RANGE_SIGNATURE SIGNATURE_32 ('M','P','M','R')
173#define MEMORY_PROFILE_MEMORY_RANGE_REVISION 0x0001
177 UINT32 MemoryRangeCount;
221 IN OUT UINT64 *ProfileSize,
222 OUT VOID *ProfileBuffer
245 IN PHYSICAL_ADDRESS ImageBase,
247 IN EFI_FV_FILETYPE FileType
269 IN PHYSICAL_ADDRESS ImageBase,
273#define MEMORY_PROFILE_RECORDING_ENABLE TRUE
274#define MEMORY_PROFILE_RECORDING_DISABLE FALSE
291 OUT BOOLEAN *RecordingState
308 IN BOOLEAN RecordingState
338 IN PHYSICAL_ADDRESS CallerAddress,
339 IN MEMORY_PROFILE_ACTION Action,
389#define SMRAM_PROFILE_COMMAND_GET_PROFILE_INFO 0x1
390#define SMRAM_PROFILE_COMMAND_GET_PROFILE_DATA 0x2
394#define SMRAM_PROFILE_COMMAND_DEPRECATED1 0x3
395#define SMRAM_PROFILE_COMMAND_DEPRECATED2 0x4
397#define SMRAM_PROFILE_COMMAND_GET_PROFILE_DATA_BY_OFFSET 0x5
398#define SMRAM_PROFILE_COMMAND_GET_RECORDING_STATE 0x6
399#define SMRAM_PROFILE_COMMAND_SET_RECORDING_STATE 0x7
415 PHYSICAL_ADDRESS ProfileBuffer;
425 PHYSICAL_ADDRESS ProfileBuffer;
430 UINT64 ProfileOffset;
435 BOOLEAN RecordingState;
441 PHYSICAL_ADDRESS ImageBuffer;
448 PHYSICAL_ADDRESS ImageBuffer;
452#define EDKII_MEMORY_PROFILE_GUID {\
453 0x821c9a09, 0x541a, 0x40f6, { 0x9f, 0x43, 0xa, 0xd1, 0x93, 0xa1, 0x2c, 0xfe } \
456extern EFI_GUID gEdkiiMemoryProfileGuid;
460#define EDKII_SMM_MEMORY_PROFILE_GUID {\
461 0xe22bbcca, 0x516a, 0x46a8, { 0x80, 0xe2, 0x67, 0x45, 0xe8, 0x36, 0x93, 0xbd } \
464extern EFI_GUID gEdkiiSmmMemoryProfileGuid;
EFI_STATUS(EFIAPI * EDKII_MEMORY_PROFILE_UNREGISTER_IMAGE)(IN EDKII_MEMORY_PROFILE_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN PHYSICAL_ADDRESS ImageBase, IN UINT64 ImageSize)
EFI_STATUS(EFIAPI * EDKII_MEMORY_PROFILE_GET_RECORDING_STATE)(IN EDKII_MEMORY_PROFILE_PROTOCOL *This, OUT BOOLEAN *RecordingState)
EFI_STATUS(EFIAPI * EDKII_MEMORY_PROFILE_REGISTER_IMAGE)(IN EDKII_MEMORY_PROFILE_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN PHYSICAL_ADDRESS ImageBase, IN UINT64 ImageSize, IN EFI_FV_FILETYPE FileType)
EFI_STATUS(EFIAPI * EDKII_MEMORY_PROFILE_SET_RECORDING_STATE)(IN EDKII_MEMORY_PROFILE_PROTOCOL *This, IN BOOLEAN RecordingState)
EFI_STATUS(EFIAPI * EDKII_MEMORY_PROFILE_GET_DATA)(IN EDKII_MEMORY_PROFILE_PROTOCOL *This, IN OUT UINT64 *ProfileSize, OUT VOID *ProfileBuffer)
EFI_STATUS(EFIAPI * EDKII_MEMORY_PROFILE_RECORD)(IN EDKII_MEMORY_PROFILE_PROTOCOL *This, IN PHYSICAL_ADDRESS CallerAddress, IN MEMORY_PROFILE_ACTION Action, IN EFI_MEMORY_TYPE MemoryType, IN VOID *Buffer, IN UINTN Size, IN CHAR8 *ActionString OPTIONAL)