mirror of
https://github.com/acidanthera/OpenCorePkg.git
synced 2025-12-08 19:25:01 +00:00
OcMemoryLib: Add counting split descriptors
This commit is contained in:
parent
763cab2140
commit
98f17b671d
@ -24,7 +24,6 @@
|
||||
#define PREV_MEMORY_DESCRIPTOR(MemoryDescriptor, Size) \
|
||||
((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) - (Size)))
|
||||
|
||||
|
||||
/**
|
||||
Get last descriptor address.
|
||||
It is assumed that the descriptor contains pages.
|
||||
@ -266,6 +265,16 @@ OcUpdateAttributes (
|
||||
IN UINT64 DropAttributes
|
||||
);
|
||||
|
||||
/**
|
||||
Count upper bound of split runtime descriptors.
|
||||
|
||||
@retval amount of runtime descriptors.
|
||||
**/
|
||||
UINTN
|
||||
OcCountSplitDescritptors (
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Return pointer to PML4 table in PageTable and PWT and PCD flags in Flags.
|
||||
|
||||
|
||||
@ -540,3 +540,36 @@ OcUpdateAttributes (
|
||||
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
UINTN
|
||||
OcCountSplitDescritptors (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN DescriptorCount;
|
||||
CONST EFI_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable;
|
||||
EFI_MEMORY_DESCRIPTOR *MemoryAttributesEntry;
|
||||
|
||||
DescriptorCount = 0;
|
||||
|
||||
for (Index = 0; Index < gST->NumberOfTableEntries; ++Index) {
|
||||
if (CompareGuid (&gST->ConfigurationTable[Index].VendorGuid, &gEfiMemoryAttributesTableGuid)) {
|
||||
MemoryAttributesTable = (CONST EFI_MEMORY_ATTRIBUTES_TABLE *) gST->ConfigurationTable[Index].VendorTable;
|
||||
MemoryAttributesEntry = (EFI_MEMORY_DESCRIPTOR *) (MemoryAttributesTable + 1);
|
||||
for (Index = 0; Index < MemoryAttributesTable->NumberOfEntries; ++Index) {
|
||||
if (MemoryAttributesEntry->Type == EfiRuntimeServicesCode
|
||||
|| MemoryAttributesEntry->Type == EfiRuntimeServicesData) {
|
||||
++DescriptorCount;
|
||||
}
|
||||
|
||||
MemoryAttributesEntry = NEXT_MEMORY_DESCRIPTOR (
|
||||
MemoryAttributesEntry,
|
||||
MemoryAttributesTable->DescriptorSize
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return DescriptorCount;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user