Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenio_x.h
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Kernel 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: ntoskrnl/include/io_x.h 00005 * PURPOSE: Internal Inlined Functions for the I/O Manager 00006 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) 00007 */ 00008 00009 static 00010 __inline 00011 VOID 00012 IopLockFileObject(IN PFILE_OBJECT FileObject) 00013 { 00014 /* Lock the FO and check for contention */ 00015 InterlockedIncrement((PLONG)&FileObject->Waiters); 00016 while (InterlockedCompareExchange((PLONG)&FileObject->Busy, TRUE, FALSE) != FALSE) 00017 { 00018 /* FIXME - pause for a little while? */ 00019 } 00020 InterlockedDecrement((PLONG)&FileObject->Waiters); 00021 } 00022 00023 static 00024 __inline 00025 VOID 00026 IopUnlockFileObject(IN PFILE_OBJECT FileObject) 00027 { 00028 /* Unlock the FO and wake any waiters up */ 00029 InterlockedExchange((PLONG)&FileObject->Busy, FALSE); 00030 if (FileObject->Waiters) KeSetEvent(&FileObject->Lock, 0, FALSE); 00031 } 00032 00033 FORCEINLINE 00034 VOID 00035 IopQueueIrpToThread(IN PIRP Irp) 00036 { 00037 KIRQL OldIrql; 00038 00039 /* Raise to APC Level */ 00040 KeRaiseIrql(APC_LEVEL, &OldIrql); 00041 00042 /* Insert it into the list */ 00043 InsertHeadList(&Irp->Tail.Overlay.Thread->IrpList, &Irp->ThreadListEntry); 00044 00045 /* Lower irql */ 00046 KeLowerIrql(OldIrql); 00047 } 00048 00049 FORCEINLINE 00050 VOID 00051 IopUnQueueIrpFromThread(IN PIRP Irp) 00052 { 00053 /* Remove it from the list and reset it */ 00054 RemoveEntryList(&Irp->ThreadListEntry); 00055 InitializeListHead(&Irp->ThreadListEntry); 00056 } 00057 00058 static 00059 __inline 00060 VOID 00061 IopUpdateOperationCount(IN IOP_TRANSFER_TYPE Type) 00062 { 00063 PLARGE_INTEGER CountToChange; 00064 00065 /* Make sure I/O operations are being counted */ 00066 if (IoCountOperations) 00067 { 00068 if (Type == IopReadTransfer) 00069 { 00070 /* Increase read count */ 00071 IoReadOperationCount++; 00072 CountToChange = &PsGetCurrentProcess()->ReadOperationCount; 00073 } 00074 else if (Type == IopWriteTransfer) 00075 { 00076 /* Increase write count */ 00077 IoWriteOperationCount++; 00078 CountToChange = &PsGetCurrentProcess()->WriteOperationCount; 00079 } 00080 else 00081 { 00082 /* Increase other count */ 00083 IoOtherOperationCount++; 00084 CountToChange = &PsGetCurrentProcess()->OtherOperationCount; 00085 } 00086 00087 /* Increase the process-wide count */ 00088 ExInterlockedAddLargeStatistic(CountToChange, 1); 00089 } 00090 } 00091 00092 static 00093 __inline 00094 VOID 00095 IopUpdateTransferCount(IN IOP_TRANSFER_TYPE Type, IN ULONG TransferCount) 00096 { 00097 PLARGE_INTEGER CountToChange; 00098 PLARGE_INTEGER TransferToChange; 00099 00100 /* Make sure I/O operations are being counted */ 00101 if (IoCountOperations) 00102 { 00103 if (Type == IopReadTransfer) 00104 { 00105 /* Increase read count */ 00106 CountToChange = &PsGetCurrentProcess()->ReadTransferCount; 00107 TransferToChange = &IoReadTransferCount; 00108 } 00109 else if (Type == IopWriteTransfer) 00110 { 00111 /* Increase write count */ 00112 CountToChange = &PsGetCurrentProcess()->WriteTransferCount; 00113 TransferToChange = &IoWriteTransferCount; 00114 } 00115 else 00116 { 00117 /* Increase other count */ 00118 CountToChange = &PsGetCurrentProcess()->OtherTransferCount; 00119 TransferToChange = &IoOtherTransferCount; 00120 } 00121 00122 /* Increase the process-wide count */ 00123 ExInterlockedAddLargeStatistic(CountToChange, TransferCount); 00124 00125 /* Increase global count */ 00126 ExInterlockedAddLargeStatistic(TransferToChange, TransferCount); 00127 } 00128 } 00129 00130 static 00131 __inline 00132 BOOLEAN 00133 IopValidateOpenPacket(IN POPEN_PACKET OpenPacket) 00134 { 00135 /* Validate the packet */ 00136 if (!(OpenPacket) || 00137 (OpenPacket->Type != IO_TYPE_OPEN_PACKET) || 00138 (OpenPacket->Size != sizeof(OPEN_PACKET))) 00139 { 00140 /* Fail */ 00141 return FALSE; 00142 } 00143 00144 /* Good packet */ 00145 return TRUE; 00146 } Generated on Sun May 27 2012 04:37:14 for ReactOS by
1.7.6.1
|