mirror of
https://github.com/reactos/reactos.git
synced 2025-05-29 14:08:22 +00:00
- 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:
parent
c9e1e6a6ad
commit
37f8eef287
4 changed files with 828 additions and 878 deletions
|
@ -1076,6 +1076,7 @@ toupper
|
||||||
towlower
|
towlower
|
||||||
towupper
|
towupper
|
||||||
vsprintf
|
vsprintf
|
||||||
|
vDbgPrintExWithPrefix
|
||||||
wcscat
|
wcscat
|
||||||
wcschr
|
wcschr
|
||||||
wcscmp
|
wcscmp
|
||||||
|
|
|
@ -2378,20 +2378,23 @@ typedef struct _MDL {
|
||||||
ULONG ByteOffset;
|
ULONG ByteOffset;
|
||||||
} MDL, *PMDL;
|
} MDL, *PMDL;
|
||||||
|
|
||||||
#define MDL_MAPPED_TO_SYSTEM_VA 0x0001
|
#define MDL_MAPPED_TO_SYSTEM_VA 0x0001
|
||||||
#define MDL_PAGES_LOCKED 0x0002
|
#define MDL_PAGES_LOCKED 0x0002
|
||||||
#define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
|
#define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
|
||||||
#define MDL_ALLOCATED_FIXED_SIZE 0x0008
|
#define MDL_ALLOCATED_FIXED_SIZE 0x0008
|
||||||
#define MDL_PARTIAL 0x0010
|
#define MDL_PARTIAL 0x0010
|
||||||
#define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
|
#define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
|
||||||
#define MDL_IO_PAGE_READ 0x0040
|
#define MDL_IO_PAGE_READ 0x0040
|
||||||
#define MDL_WRITE_OPERATION 0x0080
|
#define MDL_WRITE_OPERATION 0x0080
|
||||||
#define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
|
#define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
|
||||||
#define MDL_FREE_EXTRA_PTES 0x0200
|
#define MDL_FREE_EXTRA_PTES 0x0200
|
||||||
#define MDL_IO_SPACE 0x0800
|
#define MDL_DESCRIBES_AWE 0x0400
|
||||||
#define MDL_NETWORK_HEADER 0x1000
|
#define MDL_IO_SPACE 0x0800
|
||||||
#define MDL_MAPPING_CAN_FAIL 0x2000
|
#define MDL_NETWORK_HEADER 0x1000
|
||||||
#define MDL_ALLOCATED_MUST_SUCCEED 0x4000
|
#define MDL_MAPPING_CAN_FAIL 0x2000
|
||||||
|
#define MDL_ALLOCATED_MUST_SUCCEED 0x4000
|
||||||
|
#define MDL_INTERNAL 0x8000
|
||||||
|
|
||||||
|
|
||||||
#define MDL_MAPPING_FLAGS ( \
|
#define MDL_MAPPING_FLAGS ( \
|
||||||
MDL_MAPPED_TO_SYSTEM_VA | \
|
MDL_MAPPED_TO_SYSTEM_VA | \
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -125,6 +125,17 @@ static BOOLEAN MmSwapSpaceMessage = FALSE;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* 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
|
BOOLEAN
|
||||||
STDCALL
|
STDCALL
|
||||||
MmIsFileAPagingFile(PFILE_OBJECT FileObject)
|
MmIsFileAPagingFile(PFILE_OBJECT FileObject)
|
||||||
|
@ -247,6 +258,7 @@ MmWriteToSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page)
|
||||||
|
|
||||||
MmInitializeMdl(Mdl, NULL, PAGE_SIZE);
|
MmInitializeMdl(Mdl, NULL, PAGE_SIZE);
|
||||||
MmBuildMdlFromPages(Mdl, &Page);
|
MmBuildMdlFromPages(Mdl, &Page);
|
||||||
|
Mdl->MdlFlags |= MDL_PAGES_LOCKED;
|
||||||
|
|
||||||
file_offset.QuadPart = offset * PAGE_SIZE;
|
file_offset.QuadPart = offset * PAGE_SIZE;
|
||||||
file_offset = MmGetOffsetPageFile(PagingFileList[i]->RetrievalPointers, file_offset);
|
file_offset = MmGetOffsetPageFile(PagingFileList[i]->RetrievalPointers, file_offset);
|
||||||
|
@ -262,7 +274,11 @@ MmWriteToSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page)
|
||||||
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
||||||
Status = Iosb.Status;
|
Status = Iosb.Status;
|
||||||
}
|
}
|
||||||
MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);
|
|
||||||
|
if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
|
||||||
|
{
|
||||||
|
MmUnmapLockedPages (Mdl->MappedSystemVa, Mdl);
|
||||||
|
}
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,6 +319,7 @@ MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page)
|
||||||
|
|
||||||
MmInitializeMdl(Mdl, NULL, PAGE_SIZE);
|
MmInitializeMdl(Mdl, NULL, PAGE_SIZE);
|
||||||
MmBuildMdlFromPages(Mdl, &Page);
|
MmBuildMdlFromPages(Mdl, &Page);
|
||||||
|
Mdl->MdlFlags |= MDL_PAGES_LOCKED;
|
||||||
|
|
||||||
file_offset.QuadPart = offset * PAGE_SIZE;
|
file_offset.QuadPart = offset * PAGE_SIZE;
|
||||||
file_offset = MmGetOffsetPageFile(PagingFileList[i]->RetrievalPointers, file_offset);
|
file_offset = MmGetOffsetPageFile(PagingFileList[i]->RetrievalPointers, file_offset);
|
||||||
|
@ -318,7 +335,10 @@ MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page)
|
||||||
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
||||||
Status = Iosb.Status;
|
Status = Iosb.Status;
|
||||||
}
|
}
|
||||||
MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);
|
if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
|
||||||
|
{
|
||||||
|
MmUnmapLockedPages (Mdl->MappedSystemVa, Mdl);
|
||||||
|
}
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue