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,11 +17,11 @@
/* FUNCTIONS *****************************************************************/
/*
* @unimplemented
* @implemented
*/
VOID
STDCALL
CcMdlRead (
CcMdlRead(
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
@ -32,71 +32,117 @@ CcMdlRead (
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
*/
VOID STDCALL
CcMdlReadComplete (IN PFILE_OBJECT FileObject,
IN PMDL MdlChain)
{
PDEVICE_OBJECT DeviceObject = NULL;
DeviceObject = IoGetRelatedDeviceObject (FileObject);
/* FIXME: try fast I/O first */
CcMdlReadCompleteDev (MdlChain,
DeviceObject);
}
/*
* @unimplemented
* @implemented
*/
VOID
STDCALL
CcMdlWriteComplete (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain
)
CcMdlReadComplete(IN PFILE_OBJECT FileObject,
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->MdlReadComplete)
{
/* Use the fast path */
FastDispatch->MdlReadComplete(FileObject,
MdlChain,
DeviceObject);
}
/* Use slow path */
CcMdlReadCompleteDev(MdlChain, FileObject);
}
/*
* @implemented
*/
VOID
STDCALL
CcMdlWriteComplete(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
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,147 +60,314 @@ FsRtlIncrementCcFastReadNoWait( VOID )
CcFastReadNoWait++;
}
/**********************************************************************
* NAME EXPORTED
* FsRtlMdlRead@24
/*
* NAME EXPORTED
* FsRtlMdlRead@24
*
* DESCRIPTION
*
*
* ARGUMENTS
*
* RETURN VALUE
*
* @unimplemented
*/
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
)
{
return FALSE; /* FIXME: call FsRtlMdlReadDev ? */
}
/**********************************************************************
* NAME EXPORTED
* FsRtlMdlReadComplete@8
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* @unimplemented
*/
BOOLEAN STDCALL
FsRtlMdlReadComplete(IN PFILE_OBJECT FileObject,
IN OUT PMDL Mdl)
{
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]
);
}
/**********************************************************************
* NAME EXPORTED
* FsRtlMdlReadCompleteDev@12
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* NOTE
* 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
)
FsRtlMdlRead(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN ULONG LockKey,
OUT PMDL *MdlChain,
OUT PIO_STATUS_BLOCK IoStatus)
{
FileObject = FileObject; /* unused parameter */
CcMdlReadCompleteDev (MdlChain, DeviceObject);
return TRUE;
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
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* @implemented
*/
BOOLEAN
STDCALL
FsRtlMdlReadComplete(IN PFILE_OBJECT FileObject,
IN OUT PMDL MdlChain)
{
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
* FsRtlMdlReadDev@28
/*
* NAME EXPORTED
* FsRtlMdlReadCompleteDev@12
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* NOTE
* 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)
{
/* Call the Cache Manager */
CcMdlReadCompleteDev(MdlChain, FileObject);
return TRUE;
}
/*
* NAME EXPORTED
* FsRtlMdlReadDev@28
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* @unimplemented
*/
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)
{
UNIMPLEMENTED;
return FALSE;
}
/*
* NAME EXPORTED
* FsRtlMdlWriteComplete@12
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* @implemented
*/
BOOLEAN
STDCALL
FsRtlMdlWriteComplete(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain)
{
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
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* @implemented
*/
BOOLEAN
STDCALL
FsRtlMdlWriteCompleteDev(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain,
IN PDEVICE_OBJECT DeviceObject)
{
/* Call the Cache Manager */
CcMdlWriteCompleteDev(FileOffset, MdlChain, FileObject);
return TRUE;
}
/*
* NAME EXPORTED
* FsRtlPrepareMdlWrite@24
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* @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)
{
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
*
* DESCRIPTION
*
@ -206,121 +379,16 @@ FsRtlMdlReadCompleteDev (
*/
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
)
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;
}
/**********************************************************************
* NAME EXPORTED
* FsRtlMdlWriteComplete@12
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* @unimplemented
*/
BOOLEAN
STDCALL
FsRtlMdlWriteComplete (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain
)
{
return FALSE; /* FIXME: call FsRtlMdlWriteCompleteDev ? */
}
/**********************************************************************
* NAME EXPORTED
* FsRtlMdlWriteCompleteDev@16
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* @unimplemented
*/
BOOLEAN
STDCALL
FsRtlMdlWriteCompleteDev (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain,
IN PDEVICE_OBJECT DeviceObject
)
{
return FALSE;
}
/**********************************************************************
* NAME EXPORTED
* FsRtlPrepareMdlWrite@24
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* @unimplemented
*/
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
)
{
return FALSE; /* call FsRtlPrepareMdlWriteDev ? */
}
/**********************************************************************
* NAME EXPORTED
* FsRtlPrepareMdlWriteDev@28
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* @unimplemented
*/
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
)
{
return FALSE;
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
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);

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
@ -200,10 +203,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: