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,
84 OUT VOID *ProfileBuffer
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;
317 OUT VOID **EntryPoint
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) {
555 DxeCoreHob.Raw = GET_NEXT_HOB (DxeCoreHob);
558 ASSERT (DxeCoreHob.Raw !=
NULL);
571 &DxeCoreHob.MemoryAllocationModule->
ModuleName,
574 DxeCoreHob.MemoryAllocationModule->
EntryPoint,
576 EFI_FV_FILETYPE_DXE_CORE
578 if (DriverInfoData ==
NULL) {
598 if (!IS_UEFI_MEMORY_PROFILE_ENABLED) {
603 if (ContextData !=
NULL) {
607 mMemoryProfileGettingStatus =
FALSE;
608 if ((
PcdGet8 (PcdMemoryProfilePropertyMask) & BIT7) != 0) {
609 mMemoryProfileRecordingEnable = MEMORY_PROFILE_RECORDING_DISABLE;
611 mMemoryProfileRecordingEnable = MEMORY_PROFILE_RECORDING_ENABLE;
614 mMemoryProfileDriverPathSize =
PcdGetSize (PcdMemoryProfileDriverPath);
616 mMemoryProfileContextPtr = &mMemoryProfileContext;
620 DEBUG ((DEBUG_INFO,
"MemoryProfileInit MemoryProfileContext - 0x%x\n", &mMemoryProfileContext));
635 if (!IS_UEFI_MEMORY_PROFILE_ENABLED) {
642 &gEdkiiMemoryProfileGuid,
666 if (FilePath !=
NULL) {
670 if (FileName !=
NULL) {
696 IN EFI_FV_FILETYPE FileType
702 if (!IS_UEFI_MEMORY_PROFILE_ENABLED) {
703 return EFI_UNSUPPORTED;
707 return EFI_UNSUPPORTED;
711 if (ContextData ==
NULL) {
712 return EFI_UNSUPPORTED;
724 if (DriverInfoData ==
NULL) {
725 return EFI_OUT_OF_RESOURCES;
745 IN PHYSICAL_ADDRESS Address
753 DriverInfoList = ContextData->DriverInfoList;
755 for (DriverLink = DriverInfoList->ForwardLink;
756 DriverLink != DriverInfoList;
757 DriverLink = DriverLink->ForwardLink)
759 DriverInfoData =
CR (
763 MEMORY_PROFILE_DRIVER_INFO_SIGNATURE
765 DriverInfo = &DriverInfoData->DriverInfo;
766 if ((
CompareGuid (&DriverInfo->FileName, FileName)) &&
767 (Address >= DriverInfo->ImageBase) &&
768 (Address < (DriverInfo->ImageBase + DriverInfo->ImageSize)))
770 return DriverInfoData;
790 IN PHYSICAL_ADDRESS Address
798 DriverInfoList = ContextData->DriverInfoList;
800 for (DriverLink = DriverInfoList->ForwardLink;
801 DriverLink != DriverInfoList;
802 DriverLink = DriverLink->ForwardLink)
804 DriverInfoData =
CR (
808 MEMORY_PROFILE_DRIVER_INFO_SIGNATURE
810 DriverInfo = &DriverInfoData->DriverInfo;
811 if ((Address >= DriverInfo->ImageBase) &&
812 (Address < (DriverInfo->ImageBase + DriverInfo->ImageSize)))
814 return DriverInfoData;
841 PHYSICAL_ADDRESS ImageAddress;
842 VOID *EntryPointInImage;
844 if (!IS_UEFI_MEMORY_PROFILE_ENABLED) {
845 return EFI_UNSUPPORTED;
849 return EFI_UNSUPPORTED;
853 if (ContextData ==
NULL) {
854 return EFI_UNSUPPORTED;
857 DriverInfoData =
NULL;
859 ImageAddress =
DriverEntry->ImageContext.ImageAddress;
867 ImageAddress = ImageAddress + (
UINTN)
DriverEntry->ImageContext.EntryPoint - (
UINTN)EntryPointInImage;
870 if (FileName !=
NULL) {
874 if (DriverInfoData ==
NULL) {
878 if (DriverInfoData ==
NULL) {
879 return EFI_NOT_FOUND;
882 ContextData->Context.TotalImageSize -= DriverInfoData->DriverInfo.ImageSize;
886 DriverInfoData->DriverInfo.ImageSize = 0;
888 if (DriverInfoData->DriverInfo.PeakUsage == 0) {
889 ContextData->Context.ImageCount--;
919 if ((UINT32)MemoryType >= MEMORY_TYPE_OS_RESERVED_MIN) {
921 }
else if ((UINT32)MemoryType >= MEMORY_TYPE_OEM_RESERVED_MIN) {
927 if ((
PcdGet64 (PcdMemoryProfileMemoryType) & TestBit) != 0) {
950 if ((UINT32)MemoryType >= MEMORY_TYPE_OS_RESERVED_MIN) {
951 return EfiMaxMemoryType;
952 }
else if ((UINT32)MemoryType >= MEMORY_TYPE_OEM_RESERVED_MIN) {
953 return EfiMaxMemoryType + 1;
977 IN PHYSICAL_ADDRESS CallerAddress,
978 IN MEMORY_PROFILE_ACTION Action,
982 IN CHAR8 *ActionString OPTIONAL
992 UINTN ProfileMemoryIndex;
993 MEMORY_PROFILE_ACTION BasicAction;
994 UINTN ActionStringSize;
995 UINTN ActionStringOccupiedSize;
997 BasicAction = Action & MEMORY_PROFILE_ACTION_BASIC_MASK;
1000 if (ContextData ==
NULL) {
1001 return EFI_UNSUPPORTED;
1005 if (DriverInfoData ==
NULL) {
1006 return EFI_UNSUPPORTED;
1009 ActionStringSize = 0;
1010 ActionStringOccupiedSize = 0;
1011 if (ActionString !=
NULL) {
1013 ActionStringOccupiedSize = GET_OCCUPIED_SIZE (ActionStringSize,
sizeof (UINT64));
1019 AllocInfoData =
NULL;
1022 sizeof (*AllocInfoData) + ActionStringSize,
1023 (VOID **)&AllocInfoData
1025 if (EFI_ERROR (Status)) {
1026 return EFI_OUT_OF_RESOURCES;
1029 ASSERT (AllocInfoData !=
NULL);
1034 if (Action == BasicAction) {
1035 ContextData->Context.SequenceCount++;
1038 AllocInfo = &AllocInfoData->AllocInfo;
1039 AllocInfoData->Signature = MEMORY_PROFILE_ALLOC_INFO_SIGNATURE;
1040 AllocInfo->Header.Signature = MEMORY_PROFILE_ALLOC_INFO_SIGNATURE;
1042 AllocInfo->Header.Revision = MEMORY_PROFILE_ALLOC_INFO_REVISION;
1043 AllocInfo->CallerAddress = CallerAddress;
1044 AllocInfo->SequenceId = ContextData->Context.SequenceCount;
1045 AllocInfo->Action = Action;
1046 AllocInfo->MemoryType = MemoryType;
1047 AllocInfo->Buffer = (PHYSICAL_ADDRESS)(
UINTN)Buffer;
1048 AllocInfo->Size = Size;
1049 if (ActionString !=
NULL) {
1051 AllocInfoData->ActionString = (CHAR8 *)(AllocInfoData + 1);
1052 CopyMem (AllocInfoData->ActionString, ActionString, ActionStringSize);
1054 AllocInfo->ActionStringOffset = 0;
1055 AllocInfoData->ActionString =
NULL;
1058 InsertTailList (DriverInfoData->AllocInfoList, &AllocInfoData->Link);
1060 Context = &ContextData->Context;
1061 DriverInfo = &DriverInfoData->DriverInfo;
1062 DriverInfo->AllocRecordCount++;
1067 if (Action == BasicAction) {
1070 DriverInfo->CurrentUsage += Size;
1071 if (DriverInfo->PeakUsage < DriverInfo->CurrentUsage) {
1072 DriverInfo->PeakUsage = DriverInfo->CurrentUsage;
1075 DriverInfo->CurrentUsageByType[ProfileMemoryIndex] += Size;
1076 if (DriverInfo->PeakUsageByType[ProfileMemoryIndex] < DriverInfo->CurrentUsageByType[ProfileMemoryIndex]) {
1077 DriverInfo->PeakUsageByType[ProfileMemoryIndex] = DriverInfo->CurrentUsageByType[ProfileMemoryIndex];
1080 Context->CurrentTotalUsage += Size;
1081 if (Context->PeakTotalUsage < Context->CurrentTotalUsage) {
1082 Context->PeakTotalUsage = Context->CurrentTotalUsage;
1085 Context->CurrentTotalUsageByType[ProfileMemoryIndex] += Size;
1086 if (Context->PeakTotalUsageByType[ProfileMemoryIndex] < Context->CurrentTotalUsageByType[ProfileMemoryIndex]) {
1087 Context->PeakTotalUsageByType[ProfileMemoryIndex] = Context->CurrentTotalUsageByType[ProfileMemoryIndex];
1108 IN MEMORY_PROFILE_ACTION BasicAction,
1118 AllocInfoList = DriverInfoData->AllocInfoList;
1120 for (AllocLink = AllocInfoList->ForwardLink;
1121 AllocLink != AllocInfoList;
1122 AllocLink = AllocLink->ForwardLink)
1124 AllocInfoData =
CR (
1128 MEMORY_PROFILE_ALLOC_INFO_SIGNATURE
1130 AllocInfo = &AllocInfoData->AllocInfo;
1131 if ((AllocInfo->Action & MEMORY_PROFILE_ACTION_BASIC_MASK) != BasicAction) {
1135 switch (BasicAction) {
1136 case MemoryProfileActionAllocatePages:
1137 if ((AllocInfo->Buffer <= (PHYSICAL_ADDRESS)(
UINTN)Buffer) &&
1138 ((AllocInfo->Buffer + AllocInfo->Size) >= ((PHYSICAL_ADDRESS)(
UINTN)Buffer + Size)))
1140 return AllocInfoData;
1144 case MemoryProfileActionAllocatePool:
1145 if (AllocInfo->Buffer == (PHYSICAL_ADDRESS)(
UINTN)Buffer) {
1146 return AllocInfoData;
1174 IN PHYSICAL_ADDRESS CallerAddress,
1175 IN MEMORY_PROFILE_ACTION Action,
1189 UINTN ProfileMemoryIndex;
1190 MEMORY_PROFILE_ACTION BasicAction;
1193 BasicAction = Action & MEMORY_PROFILE_ACTION_BASIC_MASK;
1196 if (ContextData ==
NULL) {
1197 return EFI_UNSUPPORTED;
1212 AllocInfoData =
NULL;
1214 if (DriverInfoData !=
NULL) {
1215 switch (BasicAction) {
1216 case MemoryProfileActionFreePages:
1219 case MemoryProfileActionFreePool:
1224 AllocInfoData =
NULL;
1229 if (AllocInfoData ==
NULL) {
1233 DriverInfoList = ContextData->DriverInfoList;
1235 for (DriverLink = DriverInfoList->ForwardLink;
1236 DriverLink != DriverInfoList;
1237 DriverLink = DriverLink->ForwardLink)
1239 ThisDriverInfoData =
CR (
1243 MEMORY_PROFILE_DRIVER_INFO_SIGNATURE
1245 switch (BasicAction) {
1246 case MemoryProfileActionFreePages:
1249 case MemoryProfileActionFreePool:
1254 AllocInfoData =
NULL;
1258 if (AllocInfoData !=
NULL) {
1259 DriverInfoData = ThisDriverInfoData;
1264 if (AllocInfoData ==
NULL) {
1277 ASSERT (DriverInfoData !=
NULL);
1278 ASSERT (AllocInfoData !=
NULL);
1282 Context = &ContextData->Context;
1283 DriverInfo = &DriverInfoData->DriverInfo;
1284 AllocInfo = &AllocInfoData->AllocInfo;
1286 DriverInfo->AllocRecordCount--;
1290 if (AllocInfo->Action == (AllocInfo->Action & MEMORY_PROFILE_ACTION_BASIC_MASK)) {
1293 Context->CurrentTotalUsage -= AllocInfo->Size;
1294 Context->CurrentTotalUsageByType[ProfileMemoryIndex] -= AllocInfo->Size;
1296 DriverInfo->CurrentUsage -= AllocInfo->Size;
1297 DriverInfo->CurrentUsageByType[ProfileMemoryIndex] -= AllocInfo->Size;
1302 if (BasicAction == MemoryProfileActionFreePages) {
1303 if (AllocInfo->Buffer != (PHYSICAL_ADDRESS)(
UINTN)Buffer) {
1305 AllocInfo->CallerAddress,
1307 AllocInfo->MemoryType,
1308 (
UINTN)((PHYSICAL_ADDRESS)(
UINTN)Buffer - AllocInfo->Buffer),
1309 (VOID *)(
UINTN)AllocInfo->Buffer,
1310 AllocInfoData->ActionString
1314 if (AllocInfo->Buffer + AllocInfo->Size != ((PHYSICAL_ADDRESS)(
UINTN)Buffer + Size)) {
1316 AllocInfo->CallerAddress,
1318 AllocInfo->MemoryType,
1319 (
UINTN)((AllocInfo->Buffer + AllocInfo->Size) - ((PHYSICAL_ADDRESS)(
UINTN)Buffer + Size)),
1320 (VOID *)((
UINTN)Buffer + Size),
1321 AllocInfoData->ActionString
1358 IN PHYSICAL_ADDRESS CallerAddress,
1359 IN MEMORY_PROFILE_ACTION Action,
1363 IN CHAR8 *ActionString OPTIONAL
1368 MEMORY_PROFILE_ACTION BasicAction;
1370 if (!IS_UEFI_MEMORY_PROFILE_ENABLED) {
1371 return EFI_UNSUPPORTED;
1374 if (mMemoryProfileGettingStatus) {
1375 return EFI_ACCESS_DENIED;
1378 if (!mMemoryProfileRecordingEnable) {
1385 BasicAction = Action & MEMORY_PROFILE_ACTION_BASIC_MASK;
1390 if (MemoryType != EfiMaxMemoryType) {
1395 return EFI_UNSUPPORTED;
1400 if (ContextData ==
NULL) {
1401 return EFI_UNSUPPORTED;
1405 switch (BasicAction) {
1406 case MemoryProfileActionAllocatePages:
1409 case MemoryProfileActionFreePages:
1412 case MemoryProfileActionAllocatePool:
1415 case MemoryProfileActionFreePool:
1420 Status = EFI_UNSUPPORTED;
1452 if (ContextData ==
NULL) {
1458 DriverInfoList = ContextData->DriverInfoList;
1459 for (DriverLink = DriverInfoList->ForwardLink;
1460 DriverLink != DriverInfoList;
1461 DriverLink = DriverLink->ForwardLink)
1463 DriverInfoData =
CR (
1467 MEMORY_PROFILE_DRIVER_INFO_SIGNATURE
1469 TotalSize += DriverInfoData->DriverInfo.Header.Length;
1471 AllocInfoList = DriverInfoData->AllocInfoList;
1472 for (AllocLink = AllocInfoList->ForwardLink;
1473 AllocLink != AllocInfoList;
1474 AllocLink = AllocLink->ForwardLink)
1476 AllocInfoData =
CR (
1480 MEMORY_PROFILE_ALLOC_INFO_SIGNATURE
1482 TotalSize += AllocInfoData->AllocInfo.Header.Length;
1497 IN VOID *ProfileBuffer
1511 UINTN ActionStringSize;
1514 if (ContextData ==
NULL) {
1518 Context = ProfileBuffer;
1522 DriverInfoList = ContextData->DriverInfoList;
1523 for (DriverLink = DriverInfoList->ForwardLink;
1524 DriverLink != DriverInfoList;
1525 DriverLink = DriverLink->ForwardLink)
1527 DriverInfoData =
CR (
1531 MEMORY_PROFILE_DRIVER_INFO_SIGNATURE
1534 if (DriverInfo->PdbStringOffset != 0) {
1536 CopyMem ((VOID *)((
UINTN)DriverInfo + DriverInfo->PdbStringOffset), DriverInfoData->PdbString, PdbSize);
1541 AllocInfoList = DriverInfoData->AllocInfoList;
1542 for (AllocLink = AllocInfoList->ForwardLink;
1543 AllocLink != AllocInfoList;
1544 AllocLink = AllocLink->ForwardLink)
1546 AllocInfoData =
CR (
1550 MEMORY_PROFILE_ALLOC_INFO_SIGNATURE
1553 if (AllocInfo->ActionStringOffset != 0) {
1554 ActionStringSize =
AsciiStrSize (AllocInfoData->ActionString);
1555 CopyMem ((VOID *)((
UINTN)AllocInfo + AllocInfo->ActionStringOffset), AllocInfoData->ActionString, ActionStringSize);
1583 IN OUT UINT64 *ProfileSize,
1584 OUT VOID *ProfileBuffer
1589 BOOLEAN MemoryProfileGettingStatus;
1592 if (ContextData ==
NULL) {
1593 return EFI_UNSUPPORTED;
1596 MemoryProfileGettingStatus = mMemoryProfileGettingStatus;
1597 mMemoryProfileGettingStatus =
TRUE;
1601 if (*ProfileSize < Size) {
1602 *ProfileSize = Size;
1603 mMemoryProfileGettingStatus = MemoryProfileGettingStatus;
1604 return EFI_BUFFER_TOO_SMALL;
1607 *ProfileSize = Size;
1610 mMemoryProfileGettingStatus = MemoryProfileGettingStatus;
1634 IN PHYSICAL_ADDRESS ImageBase,
1635 IN UINT64 ImageSize,
1636 IN EFI_FV_FILETYPE FileType
1641 VOID *EntryPointInImage;
1645 DriverEntry.ImageContext.ImageAddress = ImageBase;
1649 DriverEntry.ImageContext.EntryPoint = (PHYSICAL_ADDRESS)(
UINTN)EntryPointInImage;
1674 IN PHYSICAL_ADDRESS ImageBase,
1680 VOID *EntryPointInImage;
1684 DriverEntry.ImageContext.ImageAddress = ImageBase;
1688 DriverEntry.ImageContext.EntryPoint = (PHYSICAL_ADDRESS)(
UINTN)EntryPointInImage;
1708 OUT BOOLEAN *RecordingState
1714 if (ContextData ==
NULL) {
1715 return EFI_UNSUPPORTED;
1718 if (RecordingState ==
NULL) {
1719 return EFI_INVALID_PARAMETER;
1722 *RecordingState = mMemoryProfileRecordingEnable;
1740 IN BOOLEAN RecordingState
1746 if (ContextData ==
NULL) {
1747 return EFI_UNSUPPORTED;
1750 mMemoryProfileRecordingEnable = RecordingState;
1781 IN PHYSICAL_ADDRESS CallerAddress,
1782 IN MEMORY_PROFILE_ACTION Action,
1786 IN CHAR8 *ActionString OPTIONAL
1789 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.