[ros-kernel] MmMapLockedPages patch review
Casper Hornstrup
chorns at users.sourceforge.net
Sat Mar 6 22:08:19 CET 2004
Hi all.
I'm trying to implement the last case of MmMapLockedPages. Hartmut, David,
other developers
with knowledge of the memory manager, could you please comment on this
patch? Will it do the
job it is supposed to?
Casper
Index: ntoskrnl/mm/mdl.c
===================================================================
RCS file: /CVS/ReactOS/reactos/ntoskrnl/mm/mdl.c,v
retrieving revision 1.58
diff -u -r1.58 mdl.c
--- ntoskrnl/mm/mdl.c 15 Feb 2004 17:04:52 -0000 1.58
+++ ntoskrnl/mm/mdl.c 5 Mar 2004 20:12:04 -0000
@@ -152,7 +152,9 @@
KIRQL oldIrql;
ULONG RegionSize;
ULONG StartingOffset;
-
+ PEPROCESS CurrentProcess;
+ KPROCESSOR_MODE Mode;
+
DPRINT("MmMapLockedPages(Mdl %x, AccessMode %x)\n", Mdl, AccessMode);
if (Mdl->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL)
@@ -160,10 +162,19 @@
return(Mdl->MappedSystemVa);
}
- if (AccessMode == UserMode)
+ if (Mdl->StartVa >= (PVOID)KERNEL_BASE)
+ {
+ Mode = KernelMode;
+ CurrentProcess = NULL;
+ }
+ else
{
- DPRINT1("MDL mapping to user-mode not yet handled.\n");
- KEBUGCHECK(0);
+ Mode = UserMode;
+ CurrentProcess = PsGetCurrentProcess();
+ if (Mdl->Process != CurrentProcess)
+ {
+ KeAttachProcess(Mdl->Process);
+ }
}
/* Calculate the number of pages required. */
@@ -198,7 +209,7 @@
PHYSICAL_ADDRESS dummyJunkNeeded;
dummyJunkNeeded.QuadPart = MdlPages[i];
#endif
- Status = MmCreateVirtualMapping(NULL,
+ Status = MmCreateVirtualMapping(CurrentProcess,
(PVOID)((ULONG)Base+(i*PAGE_SIZE)),
PAGE_READWRITE,
#if defined(__GNUC__)
@@ -214,6 +225,11 @@
}
}
+ if (Mode == UserMode && Mdl->Process != CurrentProcess)
+ {
+ KeDetachProcess();
+ }
+
/* Mark the MDL has having being mapped. */
Mdl->MdlFlags = Mdl->MdlFlags | MDL_MAPPED_TO_SYSTEM_VA;
Mdl->MappedSystemVa = (char*)Base + Mdl->ByteOffset;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://reactos.com:8080/pipermail/ros-kernel/attachments/20040306/6c34799c/attachment.htm
More information about the Ros-kernel
mailing list