12#define IS_UEFI_MEMORY_PROFILE_ENABLED ((PcdGet8 (PcdMemoryProfilePropertyMask) & BIT0) != 0)
14#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
15 ((ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)))
40 MEMORY_PROFILE_CONTEXT_SIGNATURE,
43 MEMORY_PROFILE_CONTEXT_SIGNATURE,
45 MEMORY_PROFILE_CONTEXT_REVISION
83 IN OUT UINT64 *ProfileSize,
107 IN PHYSICAL_ADDRESS ImageBase,
109 IN EFI_FV_FILETYPE FileType
131 IN PHYSICAL_ADDRESS ImageBase,
150 OUT BOOLEAN *RecordingState
167 IN BOOLEAN RecordingState
197 IN PHYSICAL_ADDRESS CallerAddress,
198 IN MEMORY_PROFILE_ACTION Action,
202 IN CHAR8 *ActionString OPTIONAL
247 return mMemoryProfileContextPtr;
268 ASSERT (Pe32Data !=
NULL);
271 if (DosHdr->
e_magic == EFI_IMAGE_DOS_SIGNATURE) {
283 if (Hdr.Te->
Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
285 }
else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
286 Magic = Hdr.Pe32->OptionalHeader.
Magic;
288 return Hdr.Pe32->OptionalHeader.Subsystem;
290 return Hdr.Pe32Plus->OptionalHeader.Subsystem;
323 ASSERT (Pe32Data !=
NULL);
324 ASSERT (EntryPoint !=
NULL);
327 if (DosHdr->
e_magic == EFI_IMAGE_DOS_SIGNATURE) {
343 if (Hdr.Te->
Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
346 }
else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
347 *EntryPoint = (
VOID *)((
UINTN)Pe32Data + (
UINTN)(Hdr.Pe32->OptionalHeader.AddressOfEntryPoint & 0x0ffffffff));
372 IN PHYSICAL_ADDRESS ImageBase,
374 IN PHYSICAL_ADDRESS EntryPoint,
375 IN UINT16 ImageSubsystem,
376 IN EFI_FV_FILETYPE FileType
382 VOID *EntryPointInImage;
385 UINTN PdbOccupiedSize;
390 if (ImageBase != 0) {
391 PdbString = PeCoffLoaderGetPdbPointer ((
VOID *)(
UINTN)ImageBase);
392 if (PdbString !=
NULL) {
394 PdbOccupiedSize = GET_OCCUPIED_SIZE (PdbSize,
sizeof (UINT64));
403 sizeof (*DriverInfoData) +
sizeof (
LIST_ENTRY) + PdbSize,
404 (
VOID **)&DriverInfoData
406 if (EFI_ERROR (Status)) {
410 ASSERT (DriverInfoData !=
NULL);
412 ZeroMem (DriverInfoData,
sizeof (*DriverInfoData));
414 DriverInfo = &DriverInfoData->DriverInfo;
415 DriverInfoData->Signature = MEMORY_PROFILE_DRIVER_INFO_SIGNATURE;
416 DriverInfo->Header.Signature = MEMORY_PROFILE_DRIVER_INFO_SIGNATURE;
418 DriverInfo->Header.Revision = MEMORY_PROFILE_DRIVER_INFO_REVISION;
419 if (FileName !=
NULL) {
423 DriverInfo->ImageBase = ImageBase;
424 DriverInfo->ImageSize = ImageSize;
425 DriverInfo->EntryPoint = EntryPoint;
426 DriverInfo->ImageSubsystem = ImageSubsystem;
427 if ((EntryPoint != 0) && ((EntryPoint < ImageBase) || (EntryPoint >= (ImageBase + ImageSize)))) {
434 DriverInfo->ImageBase = ImageBase + EntryPoint - (PHYSICAL_ADDRESS)(
UINTN)EntryPointInImage;
437 DriverInfo->FileType = FileType;
438 DriverInfoData->AllocInfoList = (
LIST_ENTRY *)(DriverInfoData + 1);
440 DriverInfo->CurrentUsage = 0;
441 DriverInfo->PeakUsage = 0;
442 DriverInfo->AllocRecordCount = 0;
445 DriverInfoData->PdbString = (CHAR8 *)(DriverInfoData->AllocInfoList + 1);
446 CopyMem (DriverInfoData->PdbString, PdbString, PdbSize);
448 DriverInfo->PdbStringOffset = 0;
449 DriverInfoData->PdbString =
NULL;
452 InsertTailList (ContextData->DriverInfoList, &DriverInfoData->Link);
453 ContextData->Context.ImageCount++;
454 ContextData->Context.TotalImageSize += DriverInfo->ImageSize;
456 return DriverInfoData;
475 UINTN DevicePathSize;
478 if (!
IsDevicePathValid (mMemoryProfileDriverPath, mMemoryProfileDriverPathSize)) {
490 DevicePathInstance = mMemoryProfileDriverPath;
495 TmpDevicePath = DevicePathInstance;
503 DevicePathSize = (
UINTN)TmpDevicePath - (
UINTN)DevicePathInstance;
504 if ((FilePathSize == DevicePathSize) &&
505 (
CompareMem (DriverFilePath, DevicePathInstance, DevicePathSize) == 0))
537 PHYSICAL_ADDRESS ImageBase;
541 ASSERT (ContextData !=
NULL);
546 DxeCoreHob.Raw = HobStart;
547 while ((DxeCoreHob.Raw =
GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, DxeCoreHob.Raw)) !=
NULL) {
557 DxeCoreHob.Raw = GET_NEXT_HOB (DxeCoreHob);
560 ASSERT (DxeCoreHob.Raw !=
NULL);
573 &DxeCoreHob.MemoryAllocationModule->
ModuleName,
576 DxeCoreHob.MemoryAllocationModule->
EntryPoint,
578 EFI_FV_FILETYPE_DXE_CORE
580 if (DriverInfoData ==
NULL) {
600 if (!IS_UEFI_MEMORY_PROFILE_ENABLED) {
605 if (ContextData !=
NULL) {
609 mMemoryProfileGettingStatus =
FALSE;
610 if ((
PcdGet8 (PcdMemoryProfilePropertyMask) & BIT7) != 0) {
611 mMemoryProfileRecordingEnable = MEMORY_PROFILE_RECORDING_DISABLE;
613 mMemoryProfileRecordingEnable = MEMORY_PROFILE_RECORDING_ENABLE;
616 mMemoryProfileDriverPathSize =
PcdGetSize (PcdMemoryProfileDriverPath);
618 mMemoryProfileContextPtr = &mMemoryProfileContext;
622 DEBUG ((DEBUG_INFO,
"MemoryProfileInit MemoryProfileContext - 0x%x\n", &mMemoryProfileContext));
637 if (!IS_UEFI_MEMORY_PROFILE_ENABLED) {
644 &gEdkiiMemoryProfileGuid,
668 if (FilePath !=
NULL) {
672 if (FileName !=
NULL) {
698 IN EFI_FV_FILETYPE FileType
704 if (!IS_UEFI_MEMORY_PROFILE_ENABLED) {
705 return EFI_UNSUPPORTED;
709 return EFI_UNSUPPORTED;
713 if (ContextData ==
NULL) {
714 return EFI_UNSUPPORTED;
726 if (DriverInfoData ==
NULL) {
727 return EFI_OUT_OF_RESOURCES;
747 IN PHYSICAL_ADDRESS Address
755 DriverInfoList = ContextData->DriverInfoList;
757 for (DriverLink = DriverInfoList->ForwardLink;
758 DriverLink != DriverInfoList;
759 DriverLink = DriverLink->ForwardLink)
761 DriverInfoData =
CR (
765 MEMORY_PROFILE_DRIVER_INFO_SIGNATURE
767 DriverInfo = &DriverInfoData->DriverInfo;
768 if ((
CompareGuid (&DriverInfo->FileName, FileName)) &&
769 (Address >= DriverInfo->ImageBase) &&
770 (Address < (DriverInfo->ImageBase + DriverInfo->ImageSize)))
772 return DriverInfoData;
792 IN PHYSICAL_ADDRESS Address
800 DriverInfoList = ContextData->DriverInfoList;
802 for (DriverLink = DriverInfoList->ForwardLink;
803 DriverLink != DriverInfoList;
804 DriverLink = DriverLink->ForwardLink)
806 DriverInfoData =
CR (
810 MEMORY_PROFILE_DRIVER_INFO_SIGNATURE
812 DriverInfo = &DriverInfoData->DriverInfo;
813 if ((Address >= DriverInfo->ImageBase) &&
814 (Address < (DriverInfo->ImageBase + DriverInfo->ImageSize)))
816 return DriverInfoData;
843 PHYSICAL_ADDRESS ImageAddress;
844 VOID *EntryPointInImage;
846 if (!IS_UEFI_MEMORY_PROFILE_ENABLED) {
847 return EFI_UNSUPPORTED;
851 return EFI_UNSUPPORTED;
855 if (ContextData ==
NULL) {
856 return EFI_UNSUPPORTED;
859 DriverInfoData =
NULL;
861 ImageAddress =
DriverEntry->ImageContext.ImageAddress;
869 ImageAddress = ImageAddress + (
UINTN)
DriverEntry->ImageContext.EntryPoint - (
UINTN)EntryPointInImage;
872 if (FileName !=
NULL) {
876 if (DriverInfoData ==
NULL) {
880 if (DriverInfoData ==
NULL) {
881 return EFI_NOT_FOUND;
884 ContextData->Context.TotalImageSize -= DriverInfoData->DriverInfo.ImageSize;
888 DriverInfoData->DriverInfo.ImageSize = 0;
890 if (DriverInfoData->DriverInfo.PeakUsage == 0) {
891 ContextData->Context.ImageCount--;
921 if ((UINT32)MemoryType >= MEMORY_TYPE_OS_RESERVED_MIN) {
923 }
else if ((UINT32)MemoryType >= MEMORY_TYPE_OEM_RESERVED_MIN) {
929 if ((
PcdGet64 (PcdMemoryProfileMemoryType) & TestBit) != 0) {
952 if ((UINT32)MemoryType >= MEMORY_TYPE_OS_RESERVED_MIN) {
953 return EfiMaxMemoryType;
954 }
else if ((UINT32)MemoryType >= MEMORY_TYPE_OEM_RESERVED_MIN) {
955 return EfiMaxMemoryType + 1;
979 IN PHYSICAL_ADDRESS CallerAddress,
980 IN MEMORY_PROFILE_ACTION Action,
984 IN CHAR8 *ActionString OPTIONAL
994 UINTN ProfileMemoryIndex;
995 MEMORY_PROFILE_ACTION BasicAction;
996 UINTN ActionStringSize;
997 UINTN ActionStringOccupiedSize;
999 BasicAction = Action & MEMORY_PROFILE_ACTION_BASIC_MASK;
1002 if (ContextData ==
NULL) {
1003 return EFI_UNSUPPORTED;
1007 if (DriverInfoData ==
NULL) {
1008 return EFI_UNSUPPORTED;
1011 ActionStringSize = 0;
1012 ActionStringOccupiedSize = 0;
1013 if (ActionString !=
NULL) {
1015 ActionStringOccupiedSize = GET_OCCUPIED_SIZE (ActionStringSize,
sizeof (UINT64));
1021 AllocInfoData =
NULL;
1024 sizeof (*AllocInfoData) + ActionStringSize,
1025 (
VOID **)&AllocInfoData
1027 if (EFI_ERROR (Status)) {
1028 return EFI_OUT_OF_RESOURCES;
1031 ASSERT (AllocInfoData !=
NULL);
1036 if (Action == BasicAction) {
1037 ContextData->Context.SequenceCount++;
1040 AllocInfo = &AllocInfoData->AllocInfo;
1041 AllocInfoData->Signature = MEMORY_PROFILE_ALLOC_INFO_SIGNATURE;
1042 AllocInfo->Header.Signature = MEMORY_PROFILE_ALLOC_INFO_SIGNATURE;
1044 AllocInfo->Header.Revision = MEMORY_PROFILE_ALLOC_INFO_REVISION;
1045 AllocInfo->CallerAddress = CallerAddress;
1046 AllocInfo->SequenceId = ContextData->Context.SequenceCount;
1047 AllocInfo->Action = Action;
1048 AllocInfo->MemoryType = MemoryType;
1049 AllocInfo->Buffer = (PHYSICAL_ADDRESS)(
UINTN)Buffer;
1050 AllocInfo->Size = Size;
1051 if (ActionString !=
NULL) {
1053 AllocInfoData->ActionString = (CHAR8 *)(AllocInfoData + 1);
1054 CopyMem (AllocInfoData->ActionString, ActionString, ActionStringSize);
1056 AllocInfo->ActionStringOffset = 0;
1057 AllocInfoData->ActionString =
NULL;
1060 InsertTailList (DriverInfoData->AllocInfoList, &AllocInfoData->Link);
1062 Context = &ContextData->Context;
1063 DriverInfo = &DriverInfoData->DriverInfo;
1064 DriverInfo->AllocRecordCount++;
1069 if (Action == BasicAction) {
1072 DriverInfo->CurrentUsage += Size;
1073 if (DriverInfo->PeakUsage < DriverInfo->CurrentUsage) {
1074 DriverInfo->PeakUsage = DriverInfo->CurrentUsage;
1077 DriverInfo->CurrentUsageByType[ProfileMemoryIndex] += Size;
1078 if (DriverInfo->PeakUsageByType[ProfileMemoryIndex] < DriverInfo->CurrentUsageByType[ProfileMemoryIndex]) {
1079 DriverInfo->PeakUsageByType[ProfileMemoryIndex] = DriverInfo->CurrentUsageByType[ProfileMemoryIndex];
1082 Context->CurrentTotalUsage += Size;
1083 if (Context->PeakTotalUsage < Context->CurrentTotalUsage) {
1084 Context->PeakTotalUsage = Context->CurrentTotalUsage;
1087 Context->CurrentTotalUsageByType[ProfileMemoryIndex] += Size;
1088 if (Context->PeakTotalUsageByType[ProfileMemoryIndex] < Context->CurrentTotalUsageByType[ProfileMemoryIndex]) {
1089 Context->PeakTotalUsageByType[ProfileMemoryIndex] = Context->CurrentTotalUsageByType[ProfileMemoryIndex];
1110 IN MEMORY_PROFILE_ACTION BasicAction,
1120 AllocInfoList = DriverInfoData->AllocInfoList;
1122 for (AllocLink = AllocInfoList->ForwardLink;
1123 AllocLink != AllocInfoList;
1124 AllocLink = AllocLink->ForwardLink)
1126 AllocInfoData =
CR (
1130 MEMORY_PROFILE_ALLOC_INFO_SIGNATURE
1132 AllocInfo = &AllocInfoData->AllocInfo;
1133 if ((AllocInfo->Action & MEMORY_PROFILE_ACTION_BASIC_MASK) != BasicAction) {
1137 switch (BasicAction) {
1138 case MemoryProfileActionAllocatePages:
1139 if ((AllocInfo->Buffer <= (PHYSICAL_ADDRESS)(
UINTN)Buffer) &&
1140 ((AllocInfo->Buffer + AllocInfo->Size) >= ((PHYSICAL_ADDRESS)(
UINTN)Buffer + Size)))
1142 return AllocInfoData;
1146 case MemoryProfileActionAllocatePool:
1147 if (AllocInfo->Buffer == (PHYSICAL_ADDRESS)(
UINTN)Buffer) {
1148 return AllocInfoData;
1176 IN PHYSICAL_ADDRESS CallerAddress,
1177 IN MEMORY_PROFILE_ACTION Action,
1191 UINTN ProfileMemoryIndex;
1192 MEMORY_PROFILE_ACTION BasicAction;
1195 BasicAction = Action & MEMORY_PROFILE_ACTION_BASIC_MASK;
1198 if (ContextData ==
NULL) {
1199 return EFI_UNSUPPORTED;
1214 AllocInfoData =
NULL;
1216 if (DriverInfoData !=
NULL) {
1217 switch (BasicAction) {
1218 case MemoryProfileActionFreePages:
1221 case MemoryProfileActionFreePool:
1226 AllocInfoData =
NULL;
1231 if (AllocInfoData ==
NULL) {
1235 DriverInfoList = ContextData->DriverInfoList;
1237 for (DriverLink = DriverInfoList->ForwardLink;
1238 DriverLink != DriverInfoList;
1239 DriverLink = DriverLink->ForwardLink)
1241 ThisDriverInfoData =
CR (
1245 MEMORY_PROFILE_DRIVER_INFO_SIGNATURE
1247 switch (BasicAction) {
1248 case MemoryProfileActionFreePages:
1251 case MemoryProfileActionFreePool:
1256 AllocInfoData =
NULL;
1260 if (AllocInfoData !=
NULL) {
1261 DriverInfoData = ThisDriverInfoData;
1266 if (AllocInfoData ==
NULL) {
1279 if ((DriverInfoData ==
NULL) || (AllocInfoData ==
NULL)) {
1280 ASSERT (DriverInfoData !=
NULL);
1281 ASSERT (AllocInfoData !=
NULL);
1282 return EFI_NOT_FOUND;
1287 Context = &ContextData->Context;
1288 DriverInfo = &DriverInfoData->DriverInfo;
1289 AllocInfo = &AllocInfoData->AllocInfo;
1291 DriverInfo->AllocRecordCount--;
1295 if (AllocInfo->Action == (AllocInfo->Action & MEMORY_PROFILE_ACTION_BASIC_MASK)) {
1298 Context->CurrentTotalUsage -= AllocInfo->Size;
1299 Context->CurrentTotalUsageByType[ProfileMemoryIndex] -= AllocInfo->Size;
1301 DriverInfo->CurrentUsage -= AllocInfo->Size;
1302 DriverInfo->CurrentUsageByType[ProfileMemoryIndex] -= AllocInfo->Size;
1307 if (BasicAction == MemoryProfileActionFreePages) {
1308 if (AllocInfo->Buffer != (PHYSICAL_ADDRESS)(
UINTN)Buffer) {
1310 AllocInfo->CallerAddress,
1312 AllocInfo->MemoryType,
1313 (
UINTN)((PHYSICAL_ADDRESS)(
UINTN)Buffer - AllocInfo->Buffer),
1315 AllocInfoData->ActionString
1319 if (AllocInfo->Buffer + AllocInfo->Size != ((PHYSICAL_ADDRESS)(
UINTN)Buffer + Size)) {
1321 AllocInfo->CallerAddress,
1323 AllocInfo->MemoryType,
1324 (
UINTN)((AllocInfo->Buffer + AllocInfo->Size) - ((PHYSICAL_ADDRESS)(
UINTN)Buffer + Size)),
1326 AllocInfoData->ActionString
1363 IN PHYSICAL_ADDRESS CallerAddress,
1364 IN MEMORY_PROFILE_ACTION Action,
1368 IN CHAR8 *ActionString OPTIONAL
1373 MEMORY_PROFILE_ACTION BasicAction;
1375 if (!IS_UEFI_MEMORY_PROFILE_ENABLED) {
1376 return EFI_UNSUPPORTED;
1379 if (mMemoryProfileGettingStatus) {
1380 return EFI_ACCESS_DENIED;
1383 if (!mMemoryProfileRecordingEnable) {
1390 BasicAction = Action & MEMORY_PROFILE_ACTION_BASIC_MASK;
1395 if (MemoryType != EfiMaxMemoryType) {
1400 return EFI_UNSUPPORTED;
1405 if (ContextData ==
NULL) {
1406 return EFI_UNSUPPORTED;
1410 switch (BasicAction) {
1411 case MemoryProfileActionAllocatePages:
1414 case MemoryProfileActionFreePages:
1417 case MemoryProfileActionAllocatePool:
1420 case MemoryProfileActionFreePool:
1425 Status = EFI_UNSUPPORTED;
1457 if (ContextData ==
NULL) {
1463 DriverInfoList = ContextData->DriverInfoList;
1464 for (DriverLink = DriverInfoList->ForwardLink;
1465 DriverLink != DriverInfoList;
1466 DriverLink = DriverLink->ForwardLink)
1468 DriverInfoData =
CR (
1472 MEMORY_PROFILE_DRIVER_INFO_SIGNATURE
1474 TotalSize += DriverInfoData->DriverInfo.Header.Length;
1476 AllocInfoList = DriverInfoData->AllocInfoList;
1477 for (AllocLink = AllocInfoList->ForwardLink;
1478 AllocLink != AllocInfoList;
1479 AllocLink = AllocLink->ForwardLink)
1481 AllocInfoData =
CR (
1485 MEMORY_PROFILE_ALLOC_INFO_SIGNATURE
1487 TotalSize += AllocInfoData->AllocInfo.Header.Length;
1516 UINTN ActionStringSize;
1519 if (ContextData ==
NULL) {
1523 Context = ProfileBuffer;
1527 DriverInfoList = ContextData->DriverInfoList;
1528 for (DriverLink = DriverInfoList->ForwardLink;
1529 DriverLink != DriverInfoList;
1530 DriverLink = DriverLink->ForwardLink)
1532 DriverInfoData =
CR (
1536 MEMORY_PROFILE_DRIVER_INFO_SIGNATURE
1539 if (DriverInfo->PdbStringOffset != 0) {
1541 CopyMem ((
VOID *)((
UINTN)DriverInfo + DriverInfo->PdbStringOffset), DriverInfoData->PdbString, PdbSize);
1546 AllocInfoList = DriverInfoData->AllocInfoList;
1547 for (AllocLink = AllocInfoList->ForwardLink;
1548 AllocLink != AllocInfoList;
1549 AllocLink = AllocLink->ForwardLink)
1551 AllocInfoData =
CR (
1555 MEMORY_PROFILE_ALLOC_INFO_SIGNATURE
1558 if (AllocInfo->ActionStringOffset != 0) {
1559 ActionStringSize =
AsciiStrSize (AllocInfoData->ActionString);
1560 CopyMem ((
VOID *)((
UINTN)AllocInfo + AllocInfo->ActionStringOffset), AllocInfoData->ActionString, ActionStringSize);
1588 IN OUT UINT64 *ProfileSize,
1594 BOOLEAN MemoryProfileGettingStatus;
1597 if (ContextData ==
NULL) {
1598 return EFI_UNSUPPORTED;
1601 MemoryProfileGettingStatus = mMemoryProfileGettingStatus;
1602 mMemoryProfileGettingStatus =
TRUE;
1606 if (*ProfileSize < Size) {
1607 *ProfileSize = Size;
1608 mMemoryProfileGettingStatus = MemoryProfileGettingStatus;
1609 return EFI_BUFFER_TOO_SMALL;
1612 *ProfileSize = Size;
1615 mMemoryProfileGettingStatus = MemoryProfileGettingStatus;
1639 IN PHYSICAL_ADDRESS ImageBase,
1640 IN UINT64 ImageSize,
1641 IN EFI_FV_FILETYPE FileType
1646 VOID *EntryPointInImage;
1650 DriverEntry.ImageContext.ImageAddress = ImageBase;
1654 DriverEntry.ImageContext.EntryPoint = (PHYSICAL_ADDRESS)(
UINTN)EntryPointInImage;
1679 IN PHYSICAL_ADDRESS ImageBase,
1685 VOID *EntryPointInImage;
1689 DriverEntry.ImageContext.ImageAddress = ImageBase;
1693 DriverEntry.ImageContext.EntryPoint = (PHYSICAL_ADDRESS)(
UINTN)EntryPointInImage;
1713 OUT BOOLEAN *RecordingState
1719 if (ContextData ==
NULL) {
1720 return EFI_UNSUPPORTED;
1723 if (RecordingState ==
NULL) {
1724 return EFI_INVALID_PARAMETER;
1727 *RecordingState = mMemoryProfileRecordingEnable;
1745 IN BOOLEAN RecordingState
1751 if (ContextData ==
NULL) {
1752 return EFI_UNSUPPORTED;
1755 mMemoryProfileRecordingEnable = RecordingState;
1786 IN PHYSICAL_ADDRESS CallerAddress,
1787 IN MEMORY_PROFILE_ACTION Action,
1791 IN CHAR8 *ActionString OPTIONAL
1794 return CoreUpdateProfile (CallerAddress, Action, MemoryType, Size, Buffer, ActionString);
VOID *EFIAPI GetNextHob(IN UINT16 Type, IN CONST VOID *HobStart)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead)
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
UINTN EFIAPI AsciiStrSize(IN CONST CHAR8 *String)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
UINTN EFIAPI DevicePathNodeLength(IN CONST VOID *Node)
UINT8 EFIAPI DevicePathSubType(IN CONST VOID *Node)
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI NextDevicePathNode(IN CONST VOID *Node)
BOOLEAN EFIAPI IsDevicePathValid(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN UINTN MaxSize)
UINTN EFIAPI GetDevicePathSize(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
BOOLEAN EFIAPI IsDevicePathEndType(IN CONST VOID *Node)
VOID EFIAPI SetDevicePathEndNode(OUT VOID *Node)
EFI_STATUS EFIAPI CoreInternalFreePool(IN VOID *Buffer, OUT EFI_MEMORY_TYPE *PoolType OPTIONAL)
VOID CoreAcquireLock(IN EFI_LOCK *Lock)
VOID CoreReleaseLock(IN EFI_LOCK *Lock)
EFI_STATUS EFIAPI CoreInstallMultipleProtocolInterfaces(IN OUT EFI_HANDLE *Handle,...)
EFI_STATUS EFIAPI CoreInternalAllocatePool(IN EFI_MEMORY_TYPE PoolType, IN UINTN Size, OUT VOID **Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
#define RETURN_UNSUPPORTED
#define GLOBAL_REMOVE_IF_UNREFERENCED
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define CR(Record, TYPE, Field, TestSignature)
VOID MemoryProfileCopyData(IN VOID *ProfileBuffer)
EFI_GUID * GetFileNameFromFilePath(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
UINTN MemoryProfileGetDataSize(VOID)
VOID CoreReleaseMemoryProfileLock(VOID)
MEMORY_PROFILE_CONTEXT_DATA * GetMemoryProfileContext(VOID)
EFI_STATUS EFIAPI CoreUpdateProfile(IN PHYSICAL_ADDRESS CallerAddress, IN MEMORY_PROFILE_ACTION Action, IN EFI_MEMORY_TYPE MemoryType, IN UINTN Size, IN VOID *Buffer, IN CHAR8 *ActionString OPTIONAL)
EFI_STATUS EFIAPI ProfileProtocolUnregisterImage(IN EDKII_MEMORY_PROFILE_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN PHYSICAL_ADDRESS ImageBase, IN UINT64 ImageSize)
EFI_STATUS CoreUpdateProfileAllocate(IN PHYSICAL_ADDRESS CallerAddress, IN MEMORY_PROFILE_ACTION Action, IN EFI_MEMORY_TYPE MemoryType, IN UINTN Size, IN VOID *Buffer, IN CHAR8 *ActionString OPTIONAL)
UINT16 InternalPeCoffGetSubsystem(IN VOID *Pe32Data)
MEMORY_PROFILE_ALLOC_INFO_DATA * GetMemoryProfileAllocInfoFromAddress(IN MEMORY_PROFILE_DRIVER_INFO_DATA *DriverInfoData, IN MEMORY_PROFILE_ACTION BasicAction, IN UINTN Size, IN VOID *Buffer)
EFI_STATUS EFIAPI ProfileProtocolGetData(IN EDKII_MEMORY_PROFILE_PROTOCOL *This, IN OUT UINT64 *ProfileSize, OUT VOID *ProfileBuffer)
EFI_STATUS UnregisterMemoryProfileImage(IN LOADED_IMAGE_PRIVATE_DATA *DriverEntry)
EFI_STATUS EFIAPI ProfileProtocolRecord(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)
VOID MemoryProfileInstallProtocol(VOID)
VOID CoreAcquireMemoryProfileLock(VOID)
MEMORY_PROFILE_DRIVER_INFO_DATA * GetMemoryProfileDriverInfoFromAddress(IN MEMORY_PROFILE_CONTEXT_DATA *ContextData, IN PHYSICAL_ADDRESS Address)
EFI_STATUS RegisterMemoryProfileImage(IN LOADED_IMAGE_PRIVATE_DATA *DriverEntry, IN EFI_FV_FILETYPE FileType)
MEMORY_PROFILE_DRIVER_INFO_DATA * GetMemoryProfileDriverInfoByFileNameAndAddress(IN MEMORY_PROFILE_CONTEXT_DATA *ContextData, IN EFI_GUID *FileName, IN PHYSICAL_ADDRESS Address)
BOOLEAN CoreNeedRecordProfile(IN EFI_MEMORY_TYPE MemoryType)
UINTN GetProfileMemoryIndex(IN EFI_MEMORY_TYPE MemoryType)
BOOLEAN RegisterDxeCore(IN VOID *HobStart, IN MEMORY_PROFILE_CONTEXT_DATA *ContextData)
EFI_STATUS CoreUpdateProfileFree(IN PHYSICAL_ADDRESS CallerAddress, IN MEMORY_PROFILE_ACTION Action, IN UINTN Size, IN VOID *Buffer)
VOID MemoryProfileInit(IN VOID *HobStart)
BOOLEAN NeedRecordThisDriver(IN EFI_DEVICE_PATH_PROTOCOL *DriverFilePath)
EFI_STATUS EFIAPI ProfileProtocolSetRecordingState(IN EDKII_MEMORY_PROFILE_PROTOCOL *This, IN BOOLEAN RecordingState)
MEMORY_PROFILE_DRIVER_INFO_DATA * BuildDriverInfo(IN MEMORY_PROFILE_CONTEXT_DATA *ContextData, IN EFI_GUID *FileName, IN PHYSICAL_ADDRESS ImageBase, IN UINT64 ImageSize, IN PHYSICAL_ADDRESS EntryPoint, IN UINT16 ImageSubsystem, IN EFI_FV_FILETYPE FileType)
EFI_STATUS EFIAPI ProfileProtocolGetRecordingState(IN EDKII_MEMORY_PROFILE_PROTOCOL *This, OUT BOOLEAN *RecordingState)
EFI_STATUS EFIAPI ProfileProtocolRegisterImage(IN EDKII_MEMORY_PROFILE_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN PHYSICAL_ADDRESS ImageBase, IN UINT64 ImageSize, IN EFI_FV_FILETYPE FileType)
RETURN_STATUS InternalPeCoffGetEntryPoint(IN VOID *Pe32Data, OUT VOID **EntryPoint)
#define PcdGetSize(TokenName)
#define PcdGet64(TokenName)
#define PcdGet8(TokenName)
#define PcdGetPtr(TokenName)
#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
EFI_STATUS EFIAPI DriverEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
#define EFI_INITIALIZE_LOCK_VARIABLE(Priority)
VOID EFIAPI EfiInitializeFwVolDevicepathNode(IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, IN CONST EFI_GUID *NameGuid)
EFI_GUID *EFIAPI EfiGetNameGuidFromFwVolDevicePathNode(IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode)
EFI_PHYSICAL_ADDRESS MemoryBaseAddress
EFI_PHYSICAL_ADDRESS EntryPoint
EFI_HOB_MEMORY_ALLOCATION_HEADER MemoryAllocationHeader
UINT32 e_lfanew
File address of new exe header.
UINT16 e_magic
Magic number.
UINT32 AddressOfEntryPoint
Offset to entry point – from original optional header.
UINT16 Signature
The signature for TE format = "VZ".
UINT8 Subsystem
From original optional header.
UINT16 StrippedSize
Number of bytes we removed from the header.