- Add more MDL flags.

- Reformat MDL implementation (mdlsup.c) to make it readable, and add comments.
- Add a couple dozen assertions to validate that MDL flags, state and addresses.
- Use ADDRESS_AND_SIZE_TO_SPAN_PAGES macro for nice MDL calculations.
- Set Mdl->Process only when required, and set/unset various MDL flags which were being ignored/incorrectly manipulated.
- Keep track of Process->NumberOfLockedPages during MDL lock/unlock.
- Don't return the base address of the MDL allocation when mapping locked pages - MDLs have a byte offset which was being ignored.
- Fix incorrect usage of MDLs found in the kernel (thanks to the new assertions).
- Split kernel vs. user mode MDL requests in a much more organized and optimized fashion.
- Fix a number of smaller bugs throughout the code.

svn path=/trunk/; revision=33139
This commit is contained in:
Aleksey Bragin 2008-04-25 07:55:12 +00:00
parent c9e1e6a6ad
commit 37f8eef287
4 changed files with 828 additions and 878 deletions

View file

@ -1076,6 +1076,7 @@ toupper
towlower
towupper
vsprintf
vDbgPrintExWithPrefix
wcscat
wcschr
wcscmp

View file

@ -2388,10 +2388,13 @@ typedef struct _MDL {
#define MDL_WRITE_OPERATION 0x0080
#define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
#define MDL_FREE_EXTRA_PTES 0x0200
#define MDL_DESCRIBES_AWE 0x0400
#define MDL_IO_SPACE 0x0800
#define MDL_NETWORK_HEADER 0x1000
#define MDL_MAPPING_CAN_FAIL 0x2000
#define MDL_ALLOCATED_MUST_SUCCEED 0x4000
#define MDL_INTERNAL 0x8000
#define MDL_MAPPING_FLAGS ( \
MDL_MAPPED_TO_SYSTEM_VA | \

File diff suppressed because it is too large Load diff

View file

@ -125,6 +125,17 @@ static BOOLEAN MmSwapSpaceMessage = FALSE;
/* FUNCTIONS *****************************************************************/
VOID
NTAPI
MmBuildMdlFromPages(PMDL Mdl, PPFN_TYPE Pages)
{
memcpy(Mdl + 1, Pages, sizeof(PFN_TYPE) * (PAGE_ROUND_UP(Mdl->ByteOffset+Mdl->ByteCount)/PAGE_SIZE));
/* FIXME: this flag should be set by the caller perhaps? */
Mdl->MdlFlags |= MDL_IO_PAGE_READ;
}
BOOLEAN
STDCALL
MmIsFileAPagingFile(PFILE_OBJECT FileObject)
@ -247,6 +258,7 @@ MmWriteToSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page)
MmInitializeMdl(Mdl, NULL, PAGE_SIZE);
MmBuildMdlFromPages(Mdl, &Page);
Mdl->MdlFlags |= MDL_PAGES_LOCKED;
file_offset.QuadPart = offset * PAGE_SIZE;
file_offset = MmGetOffsetPageFile(PagingFileList[i]->RetrievalPointers, file_offset);
@ -262,7 +274,11 @@ MmWriteToSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page)
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
Status = Iosb.Status;
}
if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
{
MmUnmapLockedPages (Mdl->MappedSystemVa, Mdl);
}
return(Status);
}
@ -303,6 +319,7 @@ MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page)
MmInitializeMdl(Mdl, NULL, PAGE_SIZE);
MmBuildMdlFromPages(Mdl, &Page);
Mdl->MdlFlags |= MDL_PAGES_LOCKED;
file_offset.QuadPart = offset * PAGE_SIZE;
file_offset = MmGetOffsetPageFile(PagingFileList[i]->RetrievalPointers, file_offset);
@ -318,7 +335,10 @@ MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page)
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
Status = Iosb.Status;
}
if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
{
MmUnmapLockedPages (Mdl->MappedSystemVa, Mdl);
}
return(Status);
}