Implement FsRtlMdlRead, FsRtlMdlReadComplete, FsMdlReadCompleteDev, FsRtlMdlWRiteComplete, FsRtlMdlWriteCompleteDev, FsRtlPrepareMdlWrite, CcMdlReadCompleted, CcMdlWriteComplete, CcMdlReadCompleteDev

svn path=/trunk/; revision=15079
This commit is contained in:
Alex Ionescu 2005-05-07 15:19:33 +00:00
parent e18192ed67
commit 0abe7f6039
4 changed files with 415 additions and 295 deletions

View file

@ -1,4 +1,4 @@
/* $Id:$
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -17,7 +17,7 @@
/* FUNCTIONS *****************************************************************/
/*
* @unimplemented
* @implemented
*/
VOID
STDCALL
@ -32,7 +32,7 @@ CcMdlRead (
UNIMPLEMENTED;
}
/**********************************************************************
/*
* NAME INTERNAL
* CcMdlReadCompleteDev@8
*
@ -49,15 +49,23 @@ CcMdlRead (
* Used by CcMdlReadComplete@8 and FsRtl
*
*/
VOID STDCALL
VOID
STDCALL
CcMdlReadCompleteDev(IN PMDL MdlChain,
IN PDEVICE_OBJECT DeviceObject)
IN PFILE_OBJECT FileObject)
{
UNIMPLEMENTED;
PMDL Mdl;
/* Free MDLs */
while ((Mdl = MdlChain))
{
MdlChain = Mdl->Next;
MmUnlockPages(Mdl);
IoFreeMdl(Mdl);
}
}
/**********************************************************************
/*
* NAME EXPORTED
* CcMdlReadComplete@8
*
@ -71,30 +79,68 @@ CcMdlReadCompleteDev (IN PMDL MdlChain,
* NOTE
* From Bo Branten's ntifs.h v13.
*
* @unimplemented
* @implemented
*/
VOID STDCALL
VOID
STDCALL
CcMdlReadComplete(IN PFILE_OBJECT FileObject,
IN PMDL MdlChain)
{
PDEVICE_OBJECT DeviceObject = NULL;
PFAST_IO_DISPATCH FastDispatch;
/* Get Fast Dispatch Data */
DeviceObject = IoGetRelatedDeviceObject(FileObject);
/* FIXME: try fast I/O first */
CcMdlReadCompleteDev (MdlChain,
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,
CcMdlWriteComplete(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain
)
IN PMDL MdlChain)
{
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;
}

View file

@ -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@relsoft.net)
*/
/* INCLUDES ****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* GLOBALS *******************************************************************/
extern ULONG CcFastReadResourceMiss;
extern ULONG CcFastReadNoWait;
/* FUNCTIONS *****************************************************************/
/*
* @implemented
*/
@ -54,8 +60,7 @@ FsRtlIncrementCcFastReadNoWait( VOID )
CcFastReadNoWait++;
}
/**********************************************************************
/*
* NAME EXPORTED
* FsRtlMdlRead@24
*
@ -65,24 +70,59 @@ FsRtlIncrementCcFastReadNoWait( VOID )
*
* RETURN VALUE
*
* @unimplemented
* @implemented
*/
BOOLEAN
STDCALL
FsRtlMdlRead (
IN PFILE_OBJECT FileObject,
FsRtlMdlRead(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN ULONG LockKey,
OUT PMDL *MdlChain,
OUT PIO_STATUS_BLOCK IoStatus
)
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
*
@ -92,77 +132,46 @@ FsRtlMdlRead (
*
* 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;
PDEVICE_OBJECT DeviceObject, BaseDeviceObject;
PFAST_IO_DISPATCH FastDispatch;
/*
* Try fast I/O first
*/
DeviceObject [0] = IoGetRelatedDeviceObject (FileObject);
DriverObject = DeviceObject [0]->DriverObject;
if (NULL != DriverObject->FastIoDispatch)
/* 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)
{
#if 0
if (IRP_MJ_READ <= DriverObject->FastIoDispatch->Count)
/* 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;
}
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]
);
/* No fast path, use slow path */
return FsRtlMdlReadCompleteDev(FileObject, MdlChain, DeviceObject);
}
/**********************************************************************
/*
* NAME EXPORTED
* FsRtlMdlReadCompleteDev@12
*
@ -180,19 +189,16 @@ FsRtlMdlReadComplete(IN PFILE_OBJECT FileObject,
*/
BOOLEAN
STDCALL
FsRtlMdlReadCompleteDev (
IN PFILE_OBJECT FileObject,
FsRtlMdlReadCompleteDev(IN PFILE_OBJECT FileObject,
IN PMDL MdlChain,
IN PDEVICE_OBJECT DeviceObject
)
IN PDEVICE_OBJECT DeviceObject)
{
FileObject = FileObject; /* unused parameter */
CcMdlReadCompleteDev (MdlChain, DeviceObject);
/* Call the Cache Manager */
CcMdlReadCompleteDev(MdlChain, FileObject);
return TRUE;
}
/**********************************************************************
/*
* NAME EXPORTED
* FsRtlMdlReadDev@28
*
@ -206,21 +212,20 @@ FsRtlMdlReadCompleteDev (
*/
BOOLEAN
STDCALL
FsRtlMdlReadDev (
IN PFILE_OBJECT FileObject,
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
)
IN PDEVICE_OBJECT DeviceObject)
{
UNIMPLEMENTED;
return FALSE;
}
/**********************************************************************
/*
* NAME EXPORTED
* FsRtlMdlWriteComplete@12
*
@ -230,21 +235,50 @@ FsRtlMdlReadDev (
*
* RETURN VALUE
*
* @unimplemented
* @implemented
*/
BOOLEAN
STDCALL
FsRtlMdlWriteComplete (
IN PFILE_OBJECT FileObject,
FsRtlMdlWriteComplete(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain
)
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
*
@ -254,22 +288,22 @@ FsRtlMdlWriteComplete (
*
* RETURN VALUE
*
* @unimplemented
* @implemented
*/
BOOLEAN
STDCALL
FsRtlMdlWriteCompleteDev (
IN PFILE_OBJECT FileObject,
FsRtlMdlWriteCompleteDev(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain,
IN PDEVICE_OBJECT DeviceObject
)
IN PDEVICE_OBJECT DeviceObject)
{
return FALSE;
/* Call the Cache Manager */
CcMdlWriteCompleteDev(FileOffset, MdlChain, FileObject);
return TRUE;
}
/**********************************************************************
/*
* NAME EXPORTED
* FsRtlPrepareMdlWrite@24
*
@ -279,24 +313,59 @@ FsRtlMdlWriteCompleteDev (
*
* RETURN VALUE
*
* @unimplemented
* @implemented
*/
BOOLEAN
STDCALL
FsRtlPrepareMdlWrite (
IN PFILE_OBJECT FileObject,
FsRtlPrepareMdlWrite(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN ULONG LockKey,
OUT PMDL *MdlChain,
OUT PIO_STATUS_BLOCK IoStatus
)
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
*
@ -310,16 +379,15 @@ FsRtlPrepareMdlWrite (
*/
BOOLEAN
STDCALL
FsRtlPrepareMdlWriteDev (
IN PFILE_OBJECT FileObject,
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
)
IN PDEVICE_OBJECT DeviceObject)
{
UNIMPLEMENTED;
return FALSE;
}

View file

@ -62,9 +62,16 @@ typedef struct _INTERNAL_BCB
CSHORT RefCount; /* (At offset 0x34 on WinNT4) */
} INTERNAL_BCB, *PINTERNAL_BCB;
VOID STDCALL
VOID
STDCALL
CcMdlReadCompleteDev(IN PMDL MdlChain,
IN PDEVICE_OBJECT DeviceObject);
IN PFILE_OBJECT FileObject);
VOID
STDCALL
CcMdlWriteCompleteDev(IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain,
IN PFILE_OBJECT FileObject);
NTSTATUS
CcRosFlushCacheSegment(PCACHE_SEGMENT CacheSegment);

View file

@ -157,7 +157,10 @@ SaveTrapFrameForKDB_Return:
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
@ -201,10 +204,6 @@ NoLdt:
/* 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:
/* Set the TEB */