mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
[BOOTMGFW]
- Start implementing MmMdRemoveRegionFromMdlEx. The 3 cases are detected and print right now. svn path=/trunk/; revision=69057
This commit is contained in:
parent
cdd381d869
commit
7bc39e5dae
3 changed files with 122 additions and 3 deletions
|
@ -37,7 +37,7 @@ EarlyPrint(_In_ PWCHAR Format, ...)
|
|||
g_SystemTable->ConOut->OutputString(g_SystemTable->ConOut, L"\r");
|
||||
g_SystemTable->ConOut->OutputString(g_SystemTable->ConOut, buffer);
|
||||
|
||||
g_SystemTable->BootServices->Stall(1000000);
|
||||
g_SystemTable->BootServices->Stall(200000);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
|
|
@ -476,6 +476,14 @@ MmMdAddDescriptorToList (
|
|||
}
|
||||
}
|
||||
|
||||
typedef enum _BL_MEMORY_DESCRIPTOR_TYPE
|
||||
{
|
||||
BlMdPhysical,
|
||||
BlMdVirtual,
|
||||
} BL_MEMORY_DESCRIPTOR_TYPE;
|
||||
|
||||
#define BL_MM_REMOVE_VIRTUAL_REGION_FLAG 0x80000000
|
||||
|
||||
NTSTATUS
|
||||
MmMdRemoveRegionFromMdlEx (
|
||||
__in PBL_MEMORY_DESCRIPTOR_LIST MdList,
|
||||
|
@ -485,7 +493,118 @@ MmMdRemoveRegionFromMdlEx (
|
|||
__in PBL_MEMORY_DESCRIPTOR_LIST NewMdList
|
||||
)
|
||||
{
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
BOOLEAN HaveNewList, UseVirtualPage;
|
||||
NTSTATUS Status;
|
||||
PLIST_ENTRY ListHead, NextEntry;
|
||||
PBL_MEMORY_DESCRIPTOR Descriptor;
|
||||
BL_MEMORY_DESCRIPTOR NewDescriptor;
|
||||
ULONGLONG FoundBasePage, FoundEndPage, FoundPageCount, EndPage;
|
||||
|
||||
/* Check if removed descriptors should go into a new list */
|
||||
if (NewMdList != NULL)
|
||||
{
|
||||
/* Initialize it */
|
||||
MmMdInitializeListHead(NewMdList);
|
||||
NewMdList->Type = MdList->Type;
|
||||
|
||||
/* Remember for later */
|
||||
HaveNewList = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For later */
|
||||
HaveNewList = FALSE;
|
||||
}
|
||||
|
||||
/* Is the region being removed physical? */
|
||||
UseVirtualPage = FALSE;
|
||||
if (!(Flags & BL_MM_REMOVE_VIRTUAL_REGION_FLAG))
|
||||
{
|
||||
/* Is this a list of virtual descriptors? */
|
||||
if (MdList->Type == BlMdVirtual)
|
||||
{
|
||||
/* Request is nonsensical, fail */
|
||||
Status = STATUS_INVALID_PARAMETER;
|
||||
goto Quickie;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Is this a list of physical descriptors? */
|
||||
if (MdList->Type == BlMdPhysical)
|
||||
{
|
||||
/* We'll have to use the virtual page instead */
|
||||
UseVirtualPage = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Loop the list*/
|
||||
ListHead = MdList->First;
|
||||
NextEntry = ListHead->Flink;
|
||||
while (NextEntry != ListHead)
|
||||
{
|
||||
/* Get the descriptor */
|
||||
Descriptor = CONTAINING_RECORD(NextEntry, BL_MEMORY_DESCRIPTOR, ListEntry);
|
||||
|
||||
/* Extract range details */
|
||||
FoundBasePage = UseVirtualPage ? Descriptor->VirtualPage : Descriptor->BasePage;
|
||||
FoundPageCount = Descriptor->PageCount;
|
||||
FoundEndPage = FoundBasePage + FoundPageCount;
|
||||
EndPage = PageCount + BasePage;
|
||||
EarlyPrint(L"Looking for Region 0x%08I64X-0x%08I64X in 0x%08I64X-0x%08I64X\n", BasePage, EndPage, FoundBasePage, FoundEndPage);
|
||||
|
||||
/* Make a copy of the original descriptor */
|
||||
RtlCopyMemory(&NewDescriptor, NextEntry, sizeof(NewDescriptor));
|
||||
|
||||
/* Check if the region to be removed starts after the found region starts */
|
||||
if ((BasePage > FoundBasePage) || (FoundBasePage >= EndPage))
|
||||
{
|
||||
/* Check if the region ends after the found region */
|
||||
if ((BasePage >= FoundEndPage) || (FoundEndPage > EndPage))
|
||||
{
|
||||
/* Check if the found region starts after the region or ends before the region */
|
||||
if ((FoundBasePage >= BasePage) || (EndPage >= FoundEndPage))
|
||||
{
|
||||
/* This descriptor doesn't cover any part of the range */
|
||||
EarlyPrint(L"No part of this descriptor contains the region\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This descriptor covers the head of the allocation */
|
||||
EarlyPrint(L"Descriptor covers the head of the region\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This descriptor contains the entire allocation */
|
||||
EarlyPrint(L"Descriptor contains the entire region\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This descriptor covers the end of the allocation */
|
||||
EarlyPrint(L"Descriptor covers the end of the region\n");
|
||||
}
|
||||
|
||||
/* Keep going */
|
||||
NextEntry = NextEntry->Flink;
|
||||
}
|
||||
|
||||
Quickie:
|
||||
/* Check for failure cleanup */
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Did we have to build a new list? */
|
||||
if (HaveNewList)
|
||||
{
|
||||
/* Free and re-initialize it */
|
||||
MmMdFreeList(NewMdList);
|
||||
MmMdInitializeListHead(NewMdList);
|
||||
NewMdList->Type = MdList->Type;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
VOID
|
||||
|
|
|
@ -85,7 +85,7 @@ MmPaInitialize (
|
|||
{
|
||||
Descriptor = CONTAINING_RECORD(nextEntry, BL_MEMORY_DESCRIPTOR, ListEntry);
|
||||
|
||||
EarlyPrint(L"Type: %lX Flags: %lX Start: 0x%I64X End: 0x%I64X\n",
|
||||
EarlyPrint(L"Type: %08lX Flags: %08lX Base: 0x%016I64X End: 0x%016I64X\n",
|
||||
Descriptor->Type,
|
||||
Descriptor->Flags,
|
||||
Descriptor->BasePage << PAGE_SHIFT,
|
||||
|
|
Loading…
Reference in a new issue