forked from xt-sys/exectos
Cleanup hardware allocation memory pool related code
This commit is contained in:
parent
abb65b99fe
commit
6176ca38a8
@ -45,13 +45,13 @@
|
|||||||
#define MM_DEFAULT_SECONDARY_COLORS 64
|
#define MM_DEFAULT_SECONDARY_COLORS 64
|
||||||
|
|
||||||
/* Number of HAL allocation descriptors */
|
/* Number of HAL allocation descriptors */
|
||||||
#define MM_HAL_ALLOCATION_DESCRIPTORS 64
|
#define MM_HARDWARE_ALLOCATION_DESCRIPTORS 64
|
||||||
|
|
||||||
/* Kernel HAL heap initial start address */
|
/* Kernel HAL heap initial start address */
|
||||||
#define MM_HAL_HEAP_START_ADDRESS ((PVOID)(((ULONG_PTR)MM_HAL_VA_START) + 1024 * 1024))
|
#define MM_HARDWARE_HEAP_START_ADDRESS ((PVOID)(((ULONG_PTR)MM_HARDWARE_VA_START) + 1024 * 1024))
|
||||||
|
|
||||||
/* HAL memory pool virtual address start */
|
/* HAL memory pool virtual address start */
|
||||||
#define MM_HAL_VA_START 0xFFFFFFFFFFC00000ULL
|
#define MM_HARDWARE_VA_START 0xFFFFFFFFFFC00000ULL
|
||||||
|
|
||||||
/* Maximum physical address used by HAL allocations */
|
/* Maximum physical address used by HAL allocations */
|
||||||
#define MM_MAXIMUM_PHYSICAL_ADDRESS 0x00000000FFFFFFFF
|
#define MM_MAXIMUM_PHYSICAL_ADDRESS 0x00000000FFFFFFFF
|
||||||
|
@ -38,13 +38,13 @@
|
|||||||
#define MM_DEFAULT_SECONDARY_COLORS 64
|
#define MM_DEFAULT_SECONDARY_COLORS 64
|
||||||
|
|
||||||
/* Number of HAL allocation descriptors */
|
/* Number of HAL allocation descriptors */
|
||||||
#define MM_HAL_ALLOCATION_DESCRIPTORS 64
|
#define MM_HARDWARE_ALLOCATION_DESCRIPTORS 64
|
||||||
|
|
||||||
/* Kernel HAL heap initial start address */
|
/* Kernel HAL heap initial start address */
|
||||||
#define MM_HAL_HEAP_START_ADDRESS ((PVOID)(((ULONG_PTR)MM_HAL_VA_START) + 1024 * 1024))
|
#define MM_HARDWARE_HEAP_START_ADDRESS ((PVOID)(((ULONG_PTR)MM_HARDWARE_VA_START) + 1024 * 1024))
|
||||||
|
|
||||||
/* HAL memory pool virtual address start */
|
/* HAL memory pool virtual address start */
|
||||||
#define MM_HAL_VA_START 0xFFC00000
|
#define MM_HARDWARE_VA_START 0xFFC00000
|
||||||
|
|
||||||
/* Maximum physical address used by HAL allocations */
|
/* Maximum physical address used by HAL allocations */
|
||||||
#define MM_MAXIMUM_PHYSICAL_ADDRESS 0xFFFFFFFF
|
#define MM_MAXIMUM_PHYSICAL_ADDRESS 0xFFFFFFFF
|
||||||
|
@ -48,7 +48,7 @@ typedef enum _LOADER_MEMORY_TYPE
|
|||||||
LoaderBBTMemory,
|
LoaderBBTMemory,
|
||||||
LoaderReserve,
|
LoaderReserve,
|
||||||
LoaderXIPRom,
|
LoaderXIPRom,
|
||||||
LoaderHALCachedMemory,
|
LoaderHardwareCachedMemory,
|
||||||
LoaderMaximum
|
LoaderMaximum
|
||||||
} LOADER_MEMORY_TYPE, *PLOADER_MEMORY_TYPE;
|
} LOADER_MEMORY_TYPE, *PLOADER_MEMORY_TYPE;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ XtMapHalMemory(IN PXTBL_PAGE_MAPPING PageMap)
|
|||||||
PxeBase = ((PHARDWARE_PTE)(PageMap->PtePointer));
|
PxeBase = ((PHARDWARE_PTE)(PageMap->PtePointer));
|
||||||
|
|
||||||
/* Check if PXE entry already exists */
|
/* Check if PXE entry already exists */
|
||||||
if(!PxeBase[(MM_HAL_VA_START >> MM_PXI_SHIFT) & 0x1FF].Valid)
|
if(!PxeBase[(MM_HARDWARE_VA_START >> MM_PXI_SHIFT) & 0x1FF].Valid)
|
||||||
{
|
{
|
||||||
/* No valid PXE, allocate memory */
|
/* No valid PXE, allocate memory */
|
||||||
Status = XtLdrProtocol->Memory.AllocatePages(1, &Address);
|
Status = XtLdrProtocol->Memory.AllocatePages(1, &Address);
|
||||||
@ -52,9 +52,9 @@ XtMapHalMemory(IN PXTBL_PAGE_MAPPING PageMap)
|
|||||||
RtlZeroMemory((PVOID)Address, EFI_PAGE_SIZE);
|
RtlZeroMemory((PVOID)Address, EFI_PAGE_SIZE);
|
||||||
|
|
||||||
/* Make PXE valid */
|
/* Make PXE valid */
|
||||||
PxeBase[(MM_HAL_VA_START >> MM_PXI_SHIFT) & 0x1FF].Valid = 1;
|
PxeBase[(MM_HARDWARE_VA_START >> MM_PXI_SHIFT) & 0x1FF].Valid = 1;
|
||||||
PxeBase[(MM_HAL_VA_START >> MM_PXI_SHIFT) & 0x1FF].PageFrameNumber = Address / EFI_PAGE_SIZE;
|
PxeBase[(MM_HARDWARE_VA_START >> MM_PXI_SHIFT) & 0x1FF].PageFrameNumber = Address / EFI_PAGE_SIZE;
|
||||||
PxeBase[(MM_HAL_VA_START >> MM_PXI_SHIFT) & 0x1FF].Writable = 1;
|
PxeBase[(MM_HARDWARE_VA_START >> MM_PXI_SHIFT) & 0x1FF].Writable = 1;
|
||||||
|
|
||||||
/* Set PPE base address */
|
/* Set PPE base address */
|
||||||
PpeBase = (PHARDWARE_PTE)(UINT_PTR)Address;
|
PpeBase = (PHARDWARE_PTE)(UINT_PTR)Address;
|
||||||
@ -62,11 +62,11 @@ XtMapHalMemory(IN PXTBL_PAGE_MAPPING PageMap)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Set PPE base address based on existing PXE */
|
/* Set PPE base address based on existing PXE */
|
||||||
PpeBase = (PHARDWARE_PTE)((PxeBase[(MM_HAL_VA_START >> MM_PXI_SHIFT) & 0x1FF].PageFrameNumber) << EFI_PAGE_SHIFT);
|
PpeBase = (PHARDWARE_PTE)((PxeBase[(MM_HARDWARE_VA_START >> MM_PXI_SHIFT) & 0x1FF].PageFrameNumber) << EFI_PAGE_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if PPE entry already exists */
|
/* Check if PPE entry already exists */
|
||||||
if(!PpeBase[(MM_HAL_VA_START >> MM_PPI_SHIFT) & 0x1FF].Valid)
|
if(!PpeBase[(MM_HARDWARE_VA_START >> MM_PPI_SHIFT) & 0x1FF].Valid)
|
||||||
{
|
{
|
||||||
/* No valid PPE, allocate memory */
|
/* No valid PPE, allocate memory */
|
||||||
Status = XtLdrProtocol->Memory.AllocatePages(1, &Address);
|
Status = XtLdrProtocol->Memory.AllocatePages(1, &Address);
|
||||||
@ -80,9 +80,9 @@ XtMapHalMemory(IN PXTBL_PAGE_MAPPING PageMap)
|
|||||||
RtlZeroMemory((PVOID)Address, EFI_PAGE_SIZE);
|
RtlZeroMemory((PVOID)Address, EFI_PAGE_SIZE);
|
||||||
|
|
||||||
/* Make PPE valid */
|
/* Make PPE valid */
|
||||||
PpeBase[(MM_HAL_VA_START >> MM_PPI_SHIFT) & 0x1FF].Valid = 1;
|
PpeBase[(MM_HARDWARE_VA_START >> MM_PPI_SHIFT) & 0x1FF].Valid = 1;
|
||||||
PpeBase[(MM_HAL_VA_START >> MM_PPI_SHIFT) & 0x1FF].PageFrameNumber = Address / EFI_PAGE_SIZE;
|
PpeBase[(MM_HARDWARE_VA_START >> MM_PPI_SHIFT) & 0x1FF].PageFrameNumber = Address / EFI_PAGE_SIZE;
|
||||||
PpeBase[(MM_HAL_VA_START >> MM_PPI_SHIFT) & 0x1FF].Writable = 1;
|
PpeBase[(MM_HARDWARE_VA_START >> MM_PPI_SHIFT) & 0x1FF].Writable = 1;
|
||||||
|
|
||||||
/* Set PDE base address */
|
/* Set PDE base address */
|
||||||
PdeBase = (PHARDWARE_PTE)Address;
|
PdeBase = (PHARDWARE_PTE)Address;
|
||||||
@ -90,14 +90,14 @@ XtMapHalMemory(IN PXTBL_PAGE_MAPPING PageMap)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Set PDE base address, based on existing PPE */
|
/* Set PDE base address, based on existing PPE */
|
||||||
PdeBase = (PHARDWARE_PTE)((PpeBase[(MM_HAL_VA_START >> MM_PPI_SHIFT) & 0x1FF].PageFrameNumber) << EFI_PAGE_SHIFT);
|
PdeBase = (PHARDWARE_PTE)((PpeBase[(MM_HARDWARE_VA_START >> MM_PPI_SHIFT) & 0x1FF].PageFrameNumber) << EFI_PAGE_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Loop through 2 PDE entries */
|
/* Loop through 2 PDE entries */
|
||||||
for(UINT Index = 0 ; Index < 2 ; Index++)
|
for(UINT Index = 0 ; Index < 2 ; Index++)
|
||||||
{
|
{
|
||||||
/* Check if PDE entry already exists */
|
/* Check if PDE entry already exists */
|
||||||
if(!PdeBase[((MM_HAL_VA_START >> MM_PDI_SHIFT) & 0x1FF) + Index].Valid)
|
if(!PdeBase[((MM_HARDWARE_VA_START >> MM_PDI_SHIFT) & 0x1FF) + Index].Valid)
|
||||||
{
|
{
|
||||||
/* No valid PDE, allocate memory */
|
/* No valid PDE, allocate memory */
|
||||||
Status = XtLdrProtocol->Memory.AllocatePages(1, &Address);
|
Status = XtLdrProtocol->Memory.AllocatePages(1, &Address);
|
||||||
@ -111,9 +111,9 @@ XtMapHalMemory(IN PXTBL_PAGE_MAPPING PageMap)
|
|||||||
RtlZeroMemory((PVOID)Address, EFI_PAGE_SIZE);
|
RtlZeroMemory((PVOID)Address, EFI_PAGE_SIZE);
|
||||||
|
|
||||||
/* Make PDE valid */
|
/* Make PDE valid */
|
||||||
PdeBase[((MM_HAL_VA_START >> MM_PDI_SHIFT) & 0x1FF) + Index].Valid = 1;
|
PdeBase[((MM_HARDWARE_VA_START >> MM_PDI_SHIFT) & 0x1FF) + Index].Valid = 1;
|
||||||
PdeBase[((MM_HAL_VA_START >> MM_PDI_SHIFT) & 0x1FF) + Index].PageFrameNumber = Address / EFI_PAGE_SIZE;
|
PdeBase[((MM_HARDWARE_VA_START >> MM_PDI_SHIFT) & 0x1FF) + Index].PageFrameNumber = Address / EFI_PAGE_SIZE;
|
||||||
PdeBase[((MM_HAL_VA_START >> MM_PDI_SHIFT) & 0x1FF) + Index].Writable = 1;
|
PdeBase[((MM_HARDWARE_VA_START >> MM_PDI_SHIFT) & 0x1FF) + Index].Writable = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,16 +69,16 @@ EXTERN ULONG MmPageMapLevel;
|
|||||||
/* Processor structures data (THIS IS A TEMPORARY HACK) */
|
/* Processor structures data (THIS IS A TEMPORARY HACK) */
|
||||||
EXTERN UCHAR MmProcessorStructuresData[MAXIMUM_PROCESSORS][KPROCESSOR_STRUCTURES_SIZE];
|
EXTERN UCHAR MmProcessorStructuresData[MAXIMUM_PROCESSORS][KPROCESSOR_STRUCTURES_SIZE];
|
||||||
|
|
||||||
/* Allocation descriptors dedicated for HAL */
|
/* Allocation descriptors dedicated for hardware layer */
|
||||||
EXTERN LOADER_MEMORY_DESCRIPTOR MmpHalAllocationDescriptors[MM_HAL_ALLOCATION_DESCRIPTORS];
|
EXTERN LOADER_MEMORY_DESCRIPTOR MmpHardwareAllocationDescriptors[MM_HARDWARE_ALLOCATION_DESCRIPTORS];
|
||||||
|
|
||||||
/* Live address of kernel HAL heap */
|
/* Live address of kernel's hardware heap */
|
||||||
EXTERN PVOID MmpHalHeapStart;
|
EXTERN PVOID MmpHardwareHeapStart;
|
||||||
|
|
||||||
/* Architecture-specific memory extension */
|
/* Architecture-specific memory extension */
|
||||||
EXTERN BOOLEAN MmpMemoryExtension;
|
EXTERN BOOLEAN MmpMemoryExtension;
|
||||||
|
|
||||||
/* Number of used HAL allocation descriptors */
|
/* Number of used hardware allocation descriptors */
|
||||||
EXTERN ULONG MmpUsedHalAllocationDescriptors;
|
EXTERN ULONG MmpUsedHardwareAllocationDescriptors;
|
||||||
|
|
||||||
#endif /* __XTOSKRNL_GLOBALS_H */
|
#endif /* __XTOSKRNL_GLOBALS_H */
|
||||||
|
@ -30,14 +30,14 @@ ULONG MmPageMapLevel;
|
|||||||
/* Processor structures data (THIS IS A TEMPORARY HACK) */
|
/* Processor structures data (THIS IS A TEMPORARY HACK) */
|
||||||
UCHAR MmProcessorStructuresData[MAXIMUM_PROCESSORS][KPROCESSOR_STRUCTURES_SIZE] = {0};
|
UCHAR MmProcessorStructuresData[MAXIMUM_PROCESSORS][KPROCESSOR_STRUCTURES_SIZE] = {0};
|
||||||
|
|
||||||
/* Allocation descriptors dedicated for HAL */
|
/* Allocation descriptors dedicated for hardware layer */
|
||||||
LOADER_MEMORY_DESCRIPTOR MmpHalAllocationDescriptors[MM_HAL_ALLOCATION_DESCRIPTORS];
|
LOADER_MEMORY_DESCRIPTOR MmpHardwareAllocationDescriptors[MM_HARDWARE_ALLOCATION_DESCRIPTORS];
|
||||||
|
|
||||||
/* Live address of kernel HAL heap */
|
/* Live address of kernel's hardware heap */
|
||||||
PVOID MmpHalHeapStart = MM_HAL_HEAP_START_ADDRESS;
|
PVOID MmpHardwareHeapStart = MM_HARDWARE_HEAP_START_ADDRESS;
|
||||||
|
|
||||||
/* Architecture-specific memory extension */
|
/* Architecture-specific memory extension */
|
||||||
BOOLEAN MmpMemoryExtension;
|
BOOLEAN MmpMemoryExtension;
|
||||||
|
|
||||||
/* Number of used HAL allocation descriptors */
|
/* Number of used hardware allocation descriptors */
|
||||||
ULONG MmpUsedHalAllocationDescriptors = 0;
|
ULONG MmpUsedHardwareAllocationDescriptors = 0;
|
||||||
|
@ -31,7 +31,7 @@ MmAllocateHardwareMemory(IN PFN_NUMBER PageCount,
|
|||||||
IN BOOLEAN Aligned,
|
IN BOOLEAN Aligned,
|
||||||
OUT PULONG_PTR Buffer)
|
OUT PULONG_PTR Buffer)
|
||||||
{
|
{
|
||||||
PLOADER_MEMORY_DESCRIPTOR Descriptor, ExtraDescriptor, HalDescriptor;
|
PLOADER_MEMORY_DESCRIPTOR Descriptor, ExtraDescriptor, HardwareDescriptor;
|
||||||
PFN_NUMBER Alignment, MaxPage;
|
PFN_NUMBER Alignment, MaxPage;
|
||||||
ULONGLONG PhysicalAddress;
|
ULONGLONG PhysicalAddress;
|
||||||
PLIST_ENTRY ListEntry;
|
PLIST_ENTRY ListEntry;
|
||||||
@ -43,7 +43,7 @@ MmAllocateHardwareMemory(IN PFN_NUMBER PageCount,
|
|||||||
MaxPage = MM_MAXIMUM_PHYSICAL_ADDRESS >> MM_PAGE_SHIFT;
|
MaxPage = MM_MAXIMUM_PHYSICAL_ADDRESS >> MM_PAGE_SHIFT;
|
||||||
|
|
||||||
/* Make sure there are at least 2 descriptors available */
|
/* Make sure there are at least 2 descriptors available */
|
||||||
if((MmpUsedHalAllocationDescriptors + 2) > MM_HAL_ALLOCATION_DESCRIPTORS)
|
if((MmpUsedHardwareAllocationDescriptors + 2) > MM_HARDWARE_ALLOCATION_DESCRIPTORS)
|
||||||
{
|
{
|
||||||
/* Not enough descriptors, return error */
|
/* Not enough descriptors, return error */
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
@ -84,13 +84,13 @@ MmAllocateHardwareMemory(IN PFN_NUMBER PageCount,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate new descriptor */
|
/* Allocate new descriptor */
|
||||||
HalDescriptor = &MmpHalAllocationDescriptors[MmpUsedHalAllocationDescriptors];
|
HardwareDescriptor = &MmpHardwareAllocationDescriptors[MmpUsedHardwareAllocationDescriptors];
|
||||||
HalDescriptor->BasePage = Descriptor->BasePage + Alignment;
|
HardwareDescriptor->BasePage = Descriptor->BasePage + Alignment;
|
||||||
HalDescriptor->MemoryType = LoaderHALCachedMemory;
|
HardwareDescriptor->MemoryType = LoaderHardwareCachedMemory;
|
||||||
HalDescriptor->PageCount = PageCount;
|
HardwareDescriptor->PageCount = PageCount;
|
||||||
|
|
||||||
/* Update HAL allocation descriptors count */
|
/* Update hardware allocation descriptors count */
|
||||||
MmpUsedHalAllocationDescriptors++;
|
MmpUsedHardwareAllocationDescriptors++;
|
||||||
|
|
||||||
/* Check if alignment was done */
|
/* Check if alignment was done */
|
||||||
if(Alignment)
|
if(Alignment)
|
||||||
@ -99,13 +99,13 @@ MmAllocateHardwareMemory(IN PFN_NUMBER PageCount,
|
|||||||
if(Descriptor->PageCount > (PageCount + Alignment))
|
if(Descriptor->PageCount > (PageCount + Alignment))
|
||||||
{
|
{
|
||||||
/* Initialize extra descriptor */
|
/* Initialize extra descriptor */
|
||||||
ExtraDescriptor = &MmpHalAllocationDescriptors[MmpUsedHalAllocationDescriptors];
|
ExtraDescriptor = &MmpHardwareAllocationDescriptors[MmpUsedHardwareAllocationDescriptors];
|
||||||
ExtraDescriptor->BasePage = Descriptor->BasePage + Alignment + (ULONG)PageCount;
|
ExtraDescriptor->BasePage = Descriptor->BasePage + Alignment + (ULONG)PageCount;
|
||||||
ExtraDescriptor->MemoryType = LoaderFree;
|
ExtraDescriptor->MemoryType = LoaderFree;
|
||||||
ExtraDescriptor->PageCount = Descriptor->PageCount - (Alignment + (ULONG)PageCount);
|
ExtraDescriptor->PageCount = Descriptor->PageCount - (Alignment + (ULONG)PageCount);
|
||||||
|
|
||||||
/* Update HAL allocation descriptors count */
|
/* Update hardware allocation descriptors count */
|
||||||
MmpUsedHalAllocationDescriptors++;
|
MmpUsedHardwareAllocationDescriptors++;
|
||||||
|
|
||||||
/* Insert extra descriptor in the list */
|
/* Insert extra descriptor in the list */
|
||||||
RtlInsertHeadList(&Descriptor->ListEntry, &ExtraDescriptor->ListEntry);
|
RtlInsertHeadList(&Descriptor->ListEntry, &ExtraDescriptor->ListEntry);
|
||||||
@ -115,7 +115,7 @@ MmAllocateHardwareMemory(IN PFN_NUMBER PageCount,
|
|||||||
Descriptor->PageCount = Alignment;
|
Descriptor->PageCount = Alignment;
|
||||||
|
|
||||||
/* Insert new descriptor in the list */
|
/* Insert new descriptor in the list */
|
||||||
RtlInsertHeadList(&Descriptor->ListEntry, &HalDescriptor->ListEntry);
|
RtlInsertHeadList(&Descriptor->ListEntry, &HardwareDescriptor->ListEntry);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -124,7 +124,7 @@ MmAllocateHardwareMemory(IN PFN_NUMBER PageCount,
|
|||||||
Descriptor->PageCount -= (ULONG)PageCount;
|
Descriptor->PageCount -= (ULONG)PageCount;
|
||||||
|
|
||||||
/* Insert new descriptor in the list */
|
/* Insert new descriptor in the list */
|
||||||
RtlInsertTailList(&Descriptor->ListEntry, &HalDescriptor->ListEntry);
|
RtlInsertTailList(&Descriptor->ListEntry, &HardwareDescriptor->ListEntry);
|
||||||
|
|
||||||
/* Check if source descriptor is fully consumed */
|
/* Check if source descriptor is fully consumed */
|
||||||
if(Descriptor->PageCount == 0)
|
if(Descriptor->PageCount == 0)
|
||||||
@ -140,7 +140,7 @@ MmAllocateHardwareMemory(IN PFN_NUMBER PageCount,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps physical address to the virtual memory area used by kernel hardware layer (HAL).
|
* Maps physical address to the virtual memory area used by kernel hardware layer.
|
||||||
*
|
*
|
||||||
* @param PhysicalAddress
|
* @param PhysicalAddress
|
||||||
* Supplies the physical address to map.
|
* Supplies the physical address to map.
|
||||||
@ -170,7 +170,7 @@ MmMapHardwareMemory(IN PHYSICAL_ADDRESS PhysicalAddress,
|
|||||||
PHARDWARE_PTE PtePointer;
|
PHARDWARE_PTE PtePointer;
|
||||||
|
|
||||||
/* Initialize variables */
|
/* Initialize variables */
|
||||||
BaseAddress = MmpHalHeapStart;
|
BaseAddress = MmpHardwareHeapStart;
|
||||||
MappedPages = 0;
|
MappedPages = 0;
|
||||||
ReturnAddress = BaseAddress;
|
ReturnAddress = BaseAddress;
|
||||||
*VirtualAddress = NULL;
|
*VirtualAddress = NULL;
|
||||||
@ -206,10 +206,10 @@ MmMapHardwareMemory(IN PHYSICAL_ADDRESS PhysicalAddress,
|
|||||||
ReturnAddress = (PVOID)(ULONG_PTR)(BaseAddress + PAGE_OFFSET(PhysicalAddress.LowPart));
|
ReturnAddress = (PVOID)(ULONG_PTR)(BaseAddress + PAGE_OFFSET(PhysicalAddress.LowPart));
|
||||||
|
|
||||||
/* Check if base address starts at the beginning of the heap */
|
/* Check if base address starts at the beginning of the heap */
|
||||||
if(BaseAddress == MmpHalHeapStart)
|
if(BaseAddress == MmpHardwareHeapStart)
|
||||||
{
|
{
|
||||||
/* Move heap beyond base address */
|
/* Move heap beyond base address */
|
||||||
MmpHalHeapStart = (PVOID)((ULONG_PTR)BaseAddress + ((ULONG_PTR)PageCount << MM_PAGE_SHIFT));
|
MmpHardwareHeapStart = (PVOID)((ULONG_PTR)BaseAddress + ((ULONG_PTR)PageCount << MM_PAGE_SHIFT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Iterate through mapped pages */
|
/* Iterate through mapped pages */
|
||||||
@ -339,8 +339,8 @@ MmUnmapHardwareMemory(IN PVOID VirtualAddress,
|
|||||||
PHARDWARE_PTE PtePointer;
|
PHARDWARE_PTE PtePointer;
|
||||||
PFN_NUMBER Page;
|
PFN_NUMBER Page;
|
||||||
|
|
||||||
/* Check if address is valid HAL memory */
|
/* Check if address is valid hardware memory */
|
||||||
if(VirtualAddress < (PVOID)MM_HAL_VA_START)
|
if(VirtualAddress < (PVOID)MM_HARDWARE_VA_START)
|
||||||
{
|
{
|
||||||
/* Invalid address, return error */
|
/* Invalid address, return error */
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
@ -372,10 +372,10 @@ MmUnmapHardwareMemory(IN PVOID VirtualAddress,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check if heap can be reused */
|
/* Check if heap can be reused */
|
||||||
if(MmpHalHeapStart > VirtualAddress)
|
if(MmpHardwareHeapStart > VirtualAddress)
|
||||||
{
|
{
|
||||||
/* Free VA space */
|
/* Free VA space */
|
||||||
MmpHalHeapStart = VirtualAddress;
|
MmpHardwareHeapStart = VirtualAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return success */
|
/* Return success */
|
||||||
|
@ -65,7 +65,7 @@ MmpScanMemoryDescriptors(VOID)
|
|||||||
|
|
||||||
/* Check if memory type is invisible or cached */
|
/* Check if memory type is invisible or cached */
|
||||||
if(MmpVerifyMemoryTypeInvisible(MemoryDescriptor->MemoryType) ||
|
if(MmpVerifyMemoryTypeInvisible(MemoryDescriptor->MemoryType) ||
|
||||||
(MemoryDescriptor->MemoryType == LoaderHALCachedMemory))
|
(MemoryDescriptor->MemoryType == LoaderHardwareCachedMemory))
|
||||||
{
|
{
|
||||||
/* Skip this mapping */
|
/* Skip this mapping */
|
||||||
MemoryMappings = MemoryMappings->Flink;
|
MemoryMappings = MemoryMappings->Flink;
|
||||||
|
Loading…
Reference in New Issue
Block a user