-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
#include <AmiDxeLib.h> | ||
#include <PiDxe.h> | ||
#include <Library/BaseLib.h> | ||
#include <Library/BaseMemoryLib.h> | ||
#include <Library/MemoryAllocationLib.h> | ||
#include <Library/UefiBootServicesTableLib.h> | ||
#include <Library/DebugLib.h> | ||
#include <Library/PrintLib.h> | ||
#include <Library/UefiLib.h> | ||
|
||
#include <Guid/MemoryAttributesTable.h> | ||
|
||
CHAR16 *mMemoryTypeShortName[] = { | ||
L"Reserved", | ||
L"LoaderCode", | ||
L"LoaderData", | ||
L"BS_Code", | ||
L"BS_Data", | ||
L"RT_Code", | ||
L"RT_Data", | ||
L"Available", | ||
L"Unusable", | ||
L"ACPI_Recl", | ||
L"ACPI_NVS", | ||
L"MMIO", | ||
L"MMIO_Port", | ||
L"PalCode", | ||
L"Persistent", | ||
}; | ||
|
||
CHAR16 mUnknownStr[11]; | ||
|
||
CHAR16 * | ||
ShortNameOfMemoryType( | ||
IN UINT32 Type | ||
) | ||
{ | ||
if (Type < sizeof(mMemoryTypeShortName) / sizeof(mMemoryTypeShortName[0])) { | ||
return mMemoryTypeShortName[Type]; | ||
} else { | ||
UnicodeSPrint(mUnknownStr, sizeof(mUnknownStr), L"%08x", Type); | ||
return mUnknownStr; | ||
} | ||
} | ||
|
||
|
||
VOID | ||
DumpMemoryAttributesTable ( | ||
IN EFI_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable | ||
) | ||
{ | ||
UINTN Index; | ||
EFI_MEMORY_DESCRIPTOR *Entry; | ||
UINT64 RTDataPages; | ||
UINT64 RTCodePages; | ||
|
||
RTDataPages = 0; | ||
RTCodePages = 0; | ||
|
||
|
||
Print (L"MemoryAttributesTable - %016LX\n", MemoryAttributesTable); | ||
Print (L"Version - 0x%08x\n", MemoryAttributesTable->Version); | ||
Print (L"NumberOfEntries - 0x%08x\n", MemoryAttributesTable->NumberOfEntries); | ||
Print (L"DescriptorSize - 0x%08x\n", MemoryAttributesTable->DescriptorSize); | ||
Print (L"\n"); | ||
Entry = (EFI_MEMORY_DESCRIPTOR *)(MemoryAttributesTable + 1); | ||
Print (L"Type Start End # Pages Attributes\n"); | ||
for (Index = 0; Index < MemoryAttributesTable->NumberOfEntries; Index++) { | ||
Print(L"% -10s %016LX-%016LX %016LX %016LX\n", | ||
ShortNameOfMemoryType(Entry->Type), | ||
Entry->PhysicalStart, | ||
Entry->PhysicalStart + EFI_PAGES_TO_SIZE((UINTN)Entry->NumberOfPages) - 1, | ||
Entry->NumberOfPages, | ||
Entry->Attribute | ||
); | ||
switch (Entry->Type) { | ||
case EfiRuntimeServicesCode: | ||
RTCodePages += Entry->NumberOfPages; | ||
break; | ||
case EfiRuntimeServicesData: | ||
RTDataPages += Entry->NumberOfPages; | ||
break; | ||
default: | ||
break; | ||
} | ||
Entry = NEXT_MEMORY_DESCRIPTOR (Entry, MemoryAttributesTable->DescriptorSize); | ||
} | ||
|
||
Print (L"\n"); | ||
Print (L" RT_Code : %,16ld Pages (%,ld Bytes)\n", RTCodePages, MultU64x64(SIZE_4KB, RTCodePages)); | ||
Print (L" RT_Data : %,16ld Pages (%,ld Bytes)\n", RTDataPages, MultU64x64(SIZE_4KB, RTDataPages)); | ||
|
||
} | ||
|
||
EFI_STATUS | ||
EFIAPI | ||
DumpMemoryAttributesTableEntryPoint ( | ||
IN EFI_HANDLE ImageHandle, | ||
IN EFI_SYSTEM_TABLE *SystemTable | ||
) | ||
{ | ||
EFI_STATUS Status; | ||
VOID *MemoryAttributesTable; | ||
|
||
Status = EfiGetSystemConfigurationTable (&gEfiMemoryAttributesTableGuid, &MemoryAttributesTable); | ||
if (!EFI_ERROR (Status)) { | ||
DumpMemoryAttributesTable(MemoryAttributesTable); | ||
} | ||
|
||
return EFI_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<component> | ||
name = "DumpMemoryAttributesTable" | ||
category = ModulePart | ||
LocalRoot = "DumpToolPkg\DumpMemoryAttributesTable\" | ||
RefName = "DumpMemoryAttributesTable" | ||
[INF] | ||
"DumpMemoryAttributesTable.inf" | ||
[files] | ||
"DumpMemoryAttributesTable.sdl" | ||
<endComponent> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[Defines] | ||
INF_VERSION = 0x00010015 | ||
VERSION_STRING = 1.0 | ||
BASE_NAME = DumpMemoryAttributesTable | ||
MODULE_TYPE = UEFI_APPLICATION | ||
FILE_GUID = 57d203e7-4fdb-472e-9c1b-a60a02da8c7f | ||
ENTRY_POINT = DumpMemoryAttributesTableEntryPoint | ||
|
||
[Sources] | ||
DumpMemoryAttributesTable.c | ||
|
||
[Packages] | ||
MdePkg/MdePkg.dec | ||
AmiCompatibilityPkg/AmiCompatibilityPkg.dec | ||
AmiModulePkg/AmiModulePkg.dec | ||
DumpToolPkg/DumpToolPkg.dec | ||
AmiTsePkg/AmiTsePkg.dec | ||
|
||
[LibraryClasses] | ||
UefiApplicationEntryPoint | ||
UefiBootServicesTableLib | ||
AmiDxeLib | ||
UefiLib | ||
DebugLib | ||
MemoryAllocationLib | ||
BaseMemoryLib | ||
PrintLib | ||
BaseLib | ||
|
||
[Guids] | ||
gEfiMemoryAttributesTableGuid | ||
|
||
[Depex] | ||
TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
TOKEN | ||
Name = "DumpMemoryAttributesTable_INF_SUPPORT" | ||
Value = "1" | ||
Help = "Main switch to enable DumpMemoryAttributesTable support in Project" | ||
TokenType = Boolean | ||
TargetMAK = Yes | ||
Master = Yes | ||
End | ||
|
||
INFComponent | ||
Name = "DumpMemoryAttributesTable" | ||
File = "DumpMemoryAttributesTable.inf" | ||
Package = "DumpMemoryAttributesTable" | ||
ModuleTypes = "UEFI_APPLICATION" | ||
Token = "DumpMemoryAttributesTable_INF_SUPPORT" "=" "1" | ||
End | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<component> | ||
name = "DumpToolPkg" | ||
category = Flavor | ||
LocalRoot = "DumpToolPkg\" | ||
RefName = "DumpToolPkg" | ||
[files] | ||
"DumpToolPkg.sdl" | ||
"DumpToolPkg.dec" | ||
[parts] | ||
"DumpMemoryAttributesTable" | ||
<endComponent> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[Defines] | ||
DEC_SPECIFICATION = 0x00010005 | ||
PACKAGE_NAME = DumpToolPkg | ||
PACKAGE_GUID = 9C52A38A-5BF4-4af8-BB04-2F85C4EFDD06 | ||
PACKAGE_VERSION = 0.1 | ||
|
||
|
||
[Includes] | ||
|
||
|
||
[LibraryClasses] | ||
|
||
|
||
[Protocols] | ||
|
||
|
||
[Ppis] | ||
|
||
|
||
[Guids] | ||
|
||
[PcdsFixedAtBuild] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
TOKEN | ||
Name = "DumpToolPkg_SUPPORT" | ||
Value = "1" | ||
Help = "Main switch to enable DumpToolPkg support in Project" | ||
TokenType = Boolean | ||
TargetMAK = Yes | ||
Master = Yes | ||
End |