Implement FsRtlMdlRead, FsRtlMdlReadComplete, FsMdlReadCompleteDev,
FsRtlMdlWRiteComplete, FsRtlMdlWriteCompleteDev, FsRtlPrepareMdlWrite,
CcMdlReadCompleted, CcMdlWriteComplete, CcMdlReadCompleteDev
Modified: trunk/reactos/ntoskrnl/cc/mdl.c
Modified: trunk/reactos/ntoskrnl/fs/mdl.c
Modified: trunk/reactos/ntoskrnl/include/internal/cc.h
Modified: trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S
_____
Modified: trunk/reactos/ntoskrnl/cc/mdl.c
--- trunk/reactos/ntoskrnl/cc/mdl.c 2005-05-07 12:04:59 UTC (rev
15078)
+++ trunk/reactos/ntoskrnl/cc/mdl.c 2005-05-07 15:19:33 UTC (rev
15079)
@@ -1,4 +1,4 @@
-/* $Id:$
+/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -17,11 +17,11 @@
/* FUNCTIONS
*****************************************************************/
/*
- * @unimplemented
+ * @implemented
*/
VOID
STDCALL
-CcMdlRead (
+CcMdlRead(
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
@@ -32,73 +32,119 @@
UNIMPLEMENTED;
}
-/**********************************************************************
+/*
* NAME INTERNAL
- * CcMdlReadCompleteDev@8
+ * CcMdlReadCompleteDev@8
*
* DESCRIPTION
*
* ARGUMENTS
- * MdlChain
- * DeviceObject
- *
+ * MdlChain
+ * DeviceObject
+ *
* RETURN VALUE
- * None.
+ * None.
*
* NOTE
* Used by CcMdlReadComplete@8 and FsRtl
*
*/
-VOID STDCALL
-CcMdlReadCompleteDev (IN PMDL MdlChain,
- IN PDEVICE_OBJECT DeviceObject)
+VOID
+STDCALL
+CcMdlReadCompleteDev(IN PMDL MdlChain,
+ IN PFILE_OBJECT FileObject)
{
- UNIMPLEMENTED;
+ PMDL Mdl;
+
+ /* Free MDLs */
+ while ((Mdl = MdlChain))
+ {
+ MdlChain = Mdl->Next;
+ MmUnlockPages(Mdl);
+ IoFreeMdl(Mdl);
+ }
}
-
-/**********************************************************************
- * NAME EXPORTED
- * CcMdlReadComplete@8
+/*
+ * NAME EXPORTED
+ * CcMdlReadComplete@8
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
- * None.
+ * None.
*
* NOTE
- * From Bo Branten's ntifs.h v13.
+ * From Bo Branten's ntifs.h v13.
*
- * @unimplemented
+ * @implemented
*/
-VOID STDCALL
-CcMdlReadComplete (IN PFILE_OBJECT FileObject,
- IN PMDL MdlChain)
+VOID
+STDCALL
+CcMdlReadComplete(IN PFILE_OBJECT FileObject,
+ IN PMDL MdlChain)
{
- PDEVICE_OBJECT DeviceObject = NULL;
+ PDEVICE_OBJECT DeviceObject = NULL;
+ PFAST_IO_DISPATCH FastDispatch;
- DeviceObject = IoGetRelatedDeviceObject (FileObject);
- /* FIXME: try fast I/O first */
- CcMdlReadCompleteDev (MdlChain,
- DeviceObject);
+ /* Get Fast Dispatch Data */
+ DeviceObject = IoGetRelatedDeviceObject(FileObject);
+ FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
+
+ /* Check if we support Fast Calls, and check this one */
+ if (FastDispatch && FastDispatch->MdlReadComplete)
+ {
+ /* Use the fast path */
+ FastDispatch->MdlReadComplete(FileObject,
+ MdlChain,
+ DeviceObject);
+ }
+
+ /* Use slow path */
+ CcMdlReadCompleteDev(MdlChain, FileObject);
}
/*
- * @unimplemented
+ * @implemented
*/
VOID
STDCALL
-CcMdlWriteComplete (
- IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER FileOffset,
- IN PMDL MdlChain
- )
+CcMdlWriteComplete(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN PMDL MdlChain)
{
- UNIMPLEMENTED;
+ PDEVICE_OBJECT DeviceObject = NULL;
+ PFAST_IO_DISPATCH FastDispatch;
+
+ /* Get Fast Dispatch Data */
+ DeviceObject = IoGetRelatedDeviceObject(FileObject);
+ FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
+
+ /* Check if we support Fast Calls, and check this one */
+ if (FastDispatch && FastDispatch->MdlWriteComplete)
+ {
+ /* Use the fast path */
+ FastDispatch->MdlWriteComplete(FileObject,
+ FileOffset,
+ MdlChain,
+ DeviceObject);
+ }
+
+ /* Use slow path */
+ CcMdlWriteCompleteDev(FileOffset, MdlChain, FileObject);
}
+VOID
+STDCALL
+CcMdlWriteCompleteDev(IN PLARGE_INTEGER FileOffset,
+ IN PMDL MdlChain,
+ IN PFILE_OBJECT FileObject)
+{
+ UNIMPLEMENTED;
+}
+
/*
* @unimplemented
*/
_____
Modified: trunk/reactos/ntoskrnl/fs/mdl.c
--- trunk/reactos/ntoskrnl/fs/mdl.c 2005-05-07 12:04:59 UTC (rev
15078)
+++ trunk/reactos/ntoskrnl/fs/mdl.c 2005-05-07 15:19:33 UTC (rev
15079)
@@ -1,19 +1,25 @@
-/* $Id$
- *
+/*
* COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
+ * PROJECT: ReactOS Kernel
* FILE: ntoskrnl/fs/mdl.c
- * PURPOSE: No purpose listed.
+ * PURPOSE: Cached MDL Access Helper Routines for File System
Drivers
*
- * PROGRAMMERS: No programmer listed.
+ * PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net)
*/
+/* INCLUDES
****************************************************************/
+
#include <ntoskrnl.h>
+#define NDEBUG
#include <internal/debug.h>
+/* GLOBALS
*******************************************************************/
+
extern ULONG CcFastReadResourceMiss;
extern ULONG CcFastReadNoWait;
+/* FUNCTIONS
*****************************************************************/
+
/*
* @implemented
*/
@@ -54,150 +60,150 @@
CcFastReadNoWait++;
}
-
-/**********************************************************************
- * NAME EXPORTED
- * FsRtlMdlRead@24
+/*
+ * NAME EXPORTED
+ * FsRtlMdlRead@24
*
* DESCRIPTION
- *
+ *
* ARGUMENTS
*
* RETURN VALUE
*
- * @unimplemented
+ * @implemented
*/
BOOLEAN
STDCALL
-FsRtlMdlRead (
- IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER FileOffset,
- IN ULONG Length,
- IN ULONG LockKey,
- OUT PMDL *MdlChain,
- OUT PIO_STATUS_BLOCK IoStatus
- )
+FsRtlMdlRead(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ IN ULONG LockKey,
+ OUT PMDL *MdlChain,
+ OUT PIO_STATUS_BLOCK IoStatus)
{
- return FALSE; /* FIXME: call FsRtlMdlReadDev ? */
+ PDEVICE_OBJECT DeviceObject, BaseDeviceObject;
+ PFAST_IO_DISPATCH FastDispatch;
+
+ /* Get Device Object and Fast Calls */
+ DeviceObject = IoGetRelatedDeviceObject(FileObject);
+ FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
+
+ /* Check if we support Fast Calls, and check this one */
+ if (FastDispatch && FastDispatch->MdlRead)
+ {
+ /* Use the fast path */
+ return FastDispatch->MdlRead(FileObject,
+ FileOffset,
+ Length,
+ LockKey,
+ MdlChain,
+ IoStatus,
+ DeviceObject);
+ }
+
+ /* Get the Base File System (Volume) and Fast Calls */
+ BaseDeviceObject = IoGetBaseFileSystemDeviceObject(FileObject);
+ FastDispatch = BaseDeviceObject->DriverObject->FastIoDispatch;
+
+ /* If the Base Device Object has its own FastDispatch Routine, fail
*/
+ if (FastDispatch && FastDispatch->MdlRead &&
+ BaseDeviceObject != DeviceObject)
+ {
+ return FALSE;
+ }
+
+ /* No fast path, use slow path */
+ return FsRtlMdlReadDev(FileObject,
+ FileOffset,
+ Length,
+ LockKey,
+ MdlChain,
+ IoStatus,
+ DeviceObject);
}
-
-/**********************************************************************
- * NAME EXPORTED
- * FsRtlMdlReadComplete@8
+/*
+ * NAME EXPORTED
+ * FsRtlMdlReadComplete@8
*
* DESCRIPTION
- *
+ *
* ARGUMENTS
*
* RETURN VALUE
*
- * @unimplemented
+ * @implemented
*/
-BOOLEAN STDCALL
+BOOLEAN
+STDCALL
FsRtlMdlReadComplete(IN PFILE_OBJECT FileObject,
- IN OUT PMDL Mdl)
+ IN OUT PMDL MdlChain)
{
- PDEVICE_OBJECT DeviceObject [2] = {NULL};
- PDRIVER_OBJECT DriverObject = NULL;
-
- /*
- * Try fast I/O first
- */
- DeviceObject [0] = IoGetRelatedDeviceObject (FileObject);
- DriverObject = DeviceObject [0]->DriverObject;
- if (NULL != DriverObject->FastIoDispatch)
- {
-#if 0
- if (IRP_MJ_READ <= DriverObject->FastIoDispatch->Count)
- {
- return FALSE;
- }
- if (NULL == DriverObject->FastIoDispatch->Dispatch
[IRP_MJ_READ])
- {
- return FALSE;
- }
- return DriverObject->FastIoDispatch->Dispatch
- [IRP_MJ_READ] (
- Mdl,
- NULL /* FIXME: how to get the IRP? */
- );
-#endif
- }
- /*
- * Default I/O path
- */
- DeviceObject [1] = IoGetBaseFileSystemDeviceObject (FileObject);
- /*
- * Did IoGetBaseFileSystemDeviceObject ()
- * returned the same device
- * IoGetRelatedDeviceObject () returned?
- */
- if (DeviceObject [1] != DeviceObject [0])
- {
-#if 0
- DriverObject = DeviceObject [1]->DriverObject;
- if (NULL != DriverObject->FastIoDispatch)
- {
- /*
- * Check if the driver provides
- * IRP_MJ_READ.
- */
- if (IRP_MJ_READ <=
DriverObject->FastIoDispatch->Count)
- {
- if (NULL ==
DriverObject->FastIoDispatch->Dispatch [IRP_MJ_READ])
- {
- return FALSE;
- }
- }
- }
-#endif
- DeviceObject [0] = DeviceObject [1];
- }
- return FsRtlMdlReadCompleteDev (
- FileObject,
- Mdl,
- DeviceObject [0]
- );
+ PDEVICE_OBJECT DeviceObject, BaseDeviceObject;
+ PFAST_IO_DISPATCH FastDispatch;
+
+ /* Get Device Object and Fast Calls */
+ DeviceObject = IoGetRelatedDeviceObject(FileObject);
+ FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
+
+ /* Check if we support Fast Calls, and check this one */
+ if (FastDispatch && FastDispatch->MdlReadComplete)
+ {
+ /* Use the fast path */
+ return FastDispatch->MdlReadComplete(FileObject,
+ MdlChain,
+ DeviceObject);
+ }
+
+ /* Get the Base File System (Volume) and Fast Calls */
+ BaseDeviceObject = IoGetBaseFileSystemDeviceObject(FileObject);
+ FastDispatch = BaseDeviceObject->DriverObject->FastIoDispatch;
+
+ /* If the Base Device Object has its own FastDispatch Routine, fail
*/
+ if (FastDispatch && FastDispatch->MdlReadComplete &&
+ BaseDeviceObject != DeviceObject)
+ {
+ return FALSE;
+ }
+
+ /* No fast path, use slow path */
+ return FsRtlMdlReadCompleteDev(FileObject, MdlChain, DeviceObject);
}
-/**********************************************************************
- * NAME EXPORTED
- * FsRtlMdlReadCompleteDev@12
+/*
+ * NAME EXPORTED
+ * FsRtlMdlReadCompleteDev@12
*
* DESCRIPTION
- *
+ *
* ARGUMENTS
*
* RETURN VALUE
*
* NOTE
- * From Bo Branten's ntifs.h v13.
- * (CcMdlReadCompleteDev declared in internal/cc.h)
+ * From Bo Branten's ntifs.h v13.
+ * (CcMdlReadCompleteDev declared in internal/cc.h)
*
* @implemented
*/
BOOLEAN
STDCALL
-FsRtlMdlReadCompleteDev (
- IN PFILE_OBJECT FileObject,
- IN PMDL MdlChain,
- IN PDEVICE_OBJECT DeviceObject
- )
+FsRtlMdlReadCompleteDev(IN PFILE_OBJECT FileObject,
+ IN PMDL MdlChain,
+ IN PDEVICE_OBJECT DeviceObject)
{
- FileObject = FileObject; /* unused parameter */
- CcMdlReadCompleteDev (MdlChain, DeviceObject);
- return TRUE;
+ /* Call the Cache Manager */
+ CcMdlReadCompleteDev(MdlChain, FileObject);
+ return TRUE;
}
-
-/**********************************************************************
- * NAME EXPORTED
- * FsRtlMdlReadDev@28
+/*
+ * NAME EXPORTED
+ * FsRtlMdlReadDev@28
*
* DESCRIPTION
- *
+ *
* ARGUMENTS
*
* RETURN VALUE
@@ -206,99 +212,162 @@
*/
BOOLEAN
STDCALL
-FsRtlMdlReadDev (
- IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER FileOffset,
- IN ULONG Length,
- IN ULONG LockKey,
- OUT PMDL *MdlChain,
- OUT PIO_STATUS_BLOCK IoStatus,
- IN PDEVICE_OBJECT DeviceObject
- )
+FsRtlMdlReadDev(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ IN ULONG LockKey,
+ OUT PMDL *MdlChain,
+ OUT PIO_STATUS_BLOCK IoStatus,
+ IN PDEVICE_OBJECT DeviceObject)
{
- return FALSE;
+ UNIMPLEMENTED;
+ return FALSE;
}
-/**********************************************************************
- * NAME EXPORTED
- * FsRtlMdlWriteComplete@12
+/*
+ * NAME EXPORTED
+ * FsRtlMdlWriteComplete@12
*
* DESCRIPTION
- *
+ *
* ARGUMENTS
*
* RETURN VALUE
*
- * @unimplemented
+ * @implemented
*/
BOOLEAN
STDCALL
-FsRtlMdlWriteComplete (
- IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER FileOffset,
- IN PMDL MdlChain
- )
+FsRtlMdlWriteComplete(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN PMDL MdlChain)
{
- return FALSE; /* FIXME: call FsRtlMdlWriteCompleteDev ? */
+ PDEVICE_OBJECT DeviceObject, BaseDeviceObject;
+ PFAST_IO_DISPATCH FastDispatch;
+
+ /* Get Device Object and Fast Calls */
+ DeviceObject = IoGetRelatedDeviceObject(FileObject);
+ FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
+
+ /* Check if we support Fast Calls, and check this one */
+ if (FastDispatch && FastDispatch->MdlWriteComplete)
+ {
+ /* Use the fast path */
+ return FastDispatch->MdlWriteComplete(FileObject,
+ FileOffset,
+ MdlChain,
+ DeviceObject);
+ }
+
+ /* Get the Base File System (Volume) and Fast Calls */
+ BaseDeviceObject = IoGetBaseFileSystemDeviceObject(FileObject);
+ FastDispatch = BaseDeviceObject->DriverObject->FastIoDispatch;
+
+ /* If the Base Device Object has its own FastDispatch Routine, fail
*/
+ if (FastDispatch && FastDispatch->MdlWriteComplete &&
+ BaseDeviceObject != DeviceObject)
+ {
+ return FALSE;
+ }
+
+ /* No fast path, use slow path */
+ return FsRtlMdlWriteCompleteDev(FileObject,
+ FileOffset,
+ MdlChain,
+ DeviceObject);
}
-
-/**********************************************************************
- * NAME EXPORTED
- * FsRtlMdlWriteCompleteDev@16
+/*
+ * NAME EXPORTED
+ * FsRtlMdlWriteCompleteDev@16
*
* DESCRIPTION
- *
+ *
* ARGUMENTS
*
* RETURN VALUE
*
- * @unimplemented
+ * @implemented
*/
BOOLEAN
STDCALL
-FsRtlMdlWriteCompleteDev (
- IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER FileOffset,
- IN PMDL MdlChain,
- IN PDEVICE_OBJECT DeviceObject
- )
+FsRtlMdlWriteCompleteDev(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN PMDL MdlChain,
+ IN PDEVICE_OBJECT DeviceObject)
{
- return FALSE;
+ /* Call the Cache Manager */
+ CcMdlWriteCompleteDev(FileOffset, MdlChain, FileObject);
+ return TRUE;
}
-/**********************************************************************
- * NAME EXPORTED
- * FsRtlPrepareMdlWrite@24
+/*
+ * NAME EXPORTED
+ * FsRtlPrepareMdlWrite@24
*
* DESCRIPTION
- *
+ *
* ARGUMENTS
*
* RETURN VALUE
*
- * @unimplemented
+ * @implemented
*/
BOOLEAN
STDCALL
-FsRtlPrepareMdlWrite (
- IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER FileOffset,
- IN ULONG Length,
- IN ULONG LockKey,
- OUT PMDL *MdlChain,
- OUT PIO_STATUS_BLOCK IoStatus
- )
+FsRtlPrepareMdlWrite(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ IN ULONG LockKey,
+ OUT PMDL *MdlChain,
+ OUT PIO_STATUS_BLOCK IoStatus)
{
- return FALSE; /* call FsRtlPrepareMdlWriteDev ? */
+ PDEVICE_OBJECT DeviceObject, BaseDeviceObject;
+ PFAST_IO_DISPATCH FastDispatch;
+
+ /* Get Device Object and Fast Calls */
+ DeviceObject = IoGetRelatedDeviceObject(FileObject);
+ FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
+
+ /* Check if we support Fast Calls, and check this one */
+ if (FastDispatch && FastDispatch->PrepareMdlWrite)
+ {
+ /* Use the fast path */
+ return FastDispatch->PrepareMdlWrite(FileObject,
+ FileOffset,
+ Length,
+ LockKey,
+ MdlChain,
+ IoStatus,
+ DeviceObject);
+ }
+
+ /* Get the Base File System (Volume) and Fast Calls */
+ BaseDeviceObject = IoGetBaseFileSystemDeviceObject(FileObject);
+ FastDispatch = BaseDeviceObject->DriverObject->FastIoDispatch;
+
+ /* If the Base Device Object has its own FastDispatch Routine, fail
*/
+ if (FastDispatch && FastDispatch->PrepareMdlWrite &&
+ BaseDeviceObject != DeviceObject)
+ {
+ return FALSE;
+ }
+
+ /* No fast path, use slow path */
+ return FsRtlPrepareMdlWriteDev(FileObject,
+ FileOffset,
+ Length,
+ LockKey,
+ MdlChain,
+ IoStatus,
+ DeviceObject);
}
-
-/**********************************************************************
- * NAME EXPORTED
- * FsRtlPrepareMdlWriteDev@28
+/*
+ * NAME EXPORTED
+ * FsRtlPrepareMdlWriteDev@28
*
* DESCRIPTION
*
@@ -310,17 +379,16 @@
*/
BOOLEAN
STDCALL
-FsRtlPrepareMdlWriteDev (
- IN PFILE_OBJECT FileObject,
- IN PLARGE_INTEGER FileOffset,
- IN ULONG Length,
- IN ULONG LockKey,
- OUT PMDL *MdlChain,
- OUT PIO_STATUS_BLOCK IoStatus,
- IN PDEVICE_OBJECT DeviceObject
- )
+FsRtlPrepareMdlWriteDev(IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ IN ULONG LockKey,
+ OUT PMDL *MdlChain,
+ OUT PIO_STATUS_BLOCK IoStatus,
+ IN PDEVICE_OBJECT DeviceObject)
{
- return FALSE;
+ UNIMPLEMENTED;
+ return FALSE;
}
_____
Modified: trunk/reactos/ntoskrnl/include/internal/cc.h
--- trunk/reactos/ntoskrnl/include/internal/cc.h 2005-05-07
12:04:59 UTC (rev 15078)
+++ trunk/reactos/ntoskrnl/include/internal/cc.h 2005-05-07
15:19:33 UTC (rev 15079)
@@ -62,9 +62,16 @@
CSHORT RefCount; /* (At offset 0x34 on WinNT4) */
} INTERNAL_BCB, *PINTERNAL_BCB;
-VOID STDCALL
-CcMdlReadCompleteDev (IN PMDL MdlChain,
- IN PDEVICE_OBJECT DeviceObject);
+VOID
+STDCALL
+CcMdlReadCompleteDev(IN PMDL MdlChain,
+ IN PFILE_OBJECT FileObject);
+
+VOID
+STDCALL
+CcMdlWriteCompleteDev(IN PLARGE_INTEGER FileOffset,
+ IN PMDL MdlChain,
+ IN PFILE_OBJECT FileObject);
NTSTATUS
CcRosFlushCacheSegment(PCACHE_SEGMENT CacheSegment);
_____
Modified: trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S
--- trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S 2005-05-07 12:04:59 UTC
(rev 15078)
+++ trunk/reactos/ntoskrnl/ke/i386/ctxswitch.S 2005-05-07 15:19:33 UTC
(rev 15079)
@@ -157,7 +157,10 @@
mov [edi+KTHREAD_KERNEL_STACK], esp
mov esp, [esi+KTHREAD_KERNEL_STACK]
- /* Change the address space */
+ /*
+ * Sadly, ROS memory management is screwed up, so
+ * we must change the address space here.
+ */
mov eax, [esi+KTHREAD_APCSTATE_PROCESS]
mov eax, [eax+KPROCESS_DIRECTORY_TABLE_BASE]
mov cr3, eax
@@ -200,10 +203,6 @@
/* Set current IOPM offset in the TSS */
mov [ebp+KTSS_IOMAPBASE], cx
-
- /* Change the address space */
- mov eax, [edi+KPROCESS_DIRECTORY_TABLE_BASE]
- mov cr3, eax
SameProcess: