Parameterize maximum allocation address in hardware pool and scan memory descriptors in reverse
All checks were successful
All checks were successful
This commit is contained in:
@@ -496,7 +496,7 @@ HL::Acpi::InitializeAcpiSystemStructure(VOID)
|
||||
PageCount = SIZE_TO_PAGES(CpuCount * sizeof(PROCESSOR_IDENTITY));
|
||||
|
||||
/* Allocate memory for CPU information */
|
||||
Status = MM::HardwarePool::AllocateHardwareMemory(PageCount, TRUE, &PhysicalAddress);
|
||||
Status = MM::HardwarePool::AllocateHardwareMemory(PageCount, TRUE, MM_MAXIMUM_PHYSICAL_ADDRESS, &PhysicalAddress);
|
||||
if(Status != STATUS_SUCCESS)
|
||||
{
|
||||
/* Failed to allocate memory, return error */
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace MM
|
||||
public:
|
||||
STATIC XTAPI XTSTATUS AllocateHardwareMemory(IN PFN_NUMBER PageCount,
|
||||
IN BOOLEAN Aligned,
|
||||
IN ULONGLONG MaximumAddress,
|
||||
OUT PPHYSICAL_ADDRESS Buffer);
|
||||
STATIC XTAPI XTSTATUS MapHardwareMemory(IN PHYSICAL_ADDRESS PhysicalAddress,
|
||||
IN PFN_NUMBER PageCount,
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
* @param Aligned
|
||||
* Specifies whether allocated memory should be aligned to 64k boundary or not.
|
||||
*
|
||||
* @param MaximumAddress
|
||||
* Supplies the maximum acceptable physical address for the allocation.
|
||||
*
|
||||
* @param Buffer
|
||||
* Supplies a buffer that receives the physical address.
|
||||
*
|
||||
@@ -29,18 +32,19 @@ XTAPI
|
||||
XTSTATUS
|
||||
MM::HardwarePool::AllocateHardwareMemory(IN PFN_NUMBER PageCount,
|
||||
IN BOOLEAN Aligned,
|
||||
IN ULONGLONG MaximumAddress,
|
||||
OUT PPHYSICAL_ADDRESS Buffer)
|
||||
{
|
||||
PLOADER_MEMORY_DESCRIPTOR Descriptor, ExtraDescriptor, HardwareDescriptor;
|
||||
PLIST_ENTRY ListEntry, LoaderMemoryDescriptors;
|
||||
PFN_NUMBER Alignment, MaxPage;
|
||||
ULONGLONG PhysicalAddress;
|
||||
PLIST_ENTRY ListEntry, LoaderMemoryDescriptors;
|
||||
|
||||
/* Assume failure */
|
||||
(*Buffer).QuadPart = 0;
|
||||
|
||||
/* Calculate maximum page address */
|
||||
MaxPage = MM_MAXIMUM_PHYSICAL_ADDRESS >> MM_PAGE_SHIFT;
|
||||
/* Calculate maximum page address based on the requested limit */
|
||||
MaxPage = MaximumAddress >> MM_PAGE_SHIFT;
|
||||
|
||||
/* Make sure there are at least 2 descriptors available */
|
||||
if((UsedHardwareAllocationDescriptors + 2) > MM_HARDWARE_ALLOCATION_DESCRIPTORS)
|
||||
@@ -53,7 +57,7 @@ MM::HardwarePool::AllocateHardwareMemory(IN PFN_NUMBER PageCount,
|
||||
LoaderMemoryDescriptors = KE::BootInformation::GetMemoryDescriptors();
|
||||
|
||||
/* Scan memory descriptors provided by the boot loader */
|
||||
ListEntry = LoaderMemoryDescriptors->Flink;
|
||||
ListEntry = LoaderMemoryDescriptors->Blink;
|
||||
while(ListEntry != LoaderMemoryDescriptors)
|
||||
{
|
||||
Descriptor = CONTAIN_RECORD(ListEntry, LOADER_MEMORY_DESCRIPTOR, ListEntry);
|
||||
@@ -75,8 +79,8 @@ MM::HardwarePool::AllocateHardwareMemory(IN PFN_NUMBER PageCount,
|
||||
}
|
||||
}
|
||||
|
||||
/* Move to next descriptor */
|
||||
ListEntry = ListEntry->Flink;
|
||||
/* Move to previous descriptor */
|
||||
ListEntry = ListEntry->Blink;
|
||||
}
|
||||
|
||||
/* Make sure we found a descriptor */
|
||||
|
||||
@@ -298,7 +298,7 @@ MM::Manager::MapKernelSharedData(VOID)
|
||||
XTSTATUS Status;
|
||||
|
||||
/* Allocate one physical page from the hardware pool for the shared data */
|
||||
Status = MM::HardwarePool::AllocateHardwareMemory(1, FALSE, &PhysAddr);
|
||||
Status = MM::HardwarePool::AllocateHardwareMemory(1, FALSE, MM_MAXIMUM_PHYSICAL_ADDRESS, &PhysAddr);
|
||||
if(Status != STATUS_SUCCESS)
|
||||
{
|
||||
/* Memory allocation failed, return error code */
|
||||
|
||||
Reference in New Issue
Block a user