ReactOS  0.4.13-dev-73-gcfe54aa
io_x.h
Go to the documentation of this file.
1 /*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/include/internal/io_x.h
5 * PURPOSE: Internal Inlined Functions for the I/O Manager
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8 
9 static
10 __inline
14  _In_ KPROCESSOR_MODE WaitMode)
15 {
16  BOOLEAN LockFailed;
17 
18  /* Lock the FO and check for contention */
20  {
22  return STATUS_SUCCESS;
23  }
24  else
25  {
27  WaitMode,
29  &LockFailed);
30  }
31 }
32 
33 static
34 __inline
35 VOID
37 {
38  /* Unlock the FO and wake any waiters up */
40  if (FileObject->Waiters)
41  {
43  }
45 }
46 
48 VOID
50 {
51  KIRQL OldIrql;
52 
53  /* Raise to APC Level */
55 
56  /* Insert it into the list */
57  InsertHeadList(&Irp->Tail.Overlay.Thread->IrpList, &Irp->ThreadListEntry);
58 
59  /* Lower irql */
61 }
62 
64 VOID
66 {
67  /* Remove it from the list and reset it */
68  if (IsListEmpty(&Irp->ThreadListEntry))
69  return;
70  RemoveEntryList(&Irp->ThreadListEntry);
71  InitializeListHead(&Irp->ThreadListEntry);
72 }
73 
74 static
75 __inline
76 VOID
78 {
79  PLARGE_INTEGER CountToChange;
80 
81  /* Make sure I/O operations are being counted */
83  {
84  if (Type == IopReadTransfer)
85  {
86  /* Increase read count */
88  CountToChange = &PsGetCurrentProcess()->ReadOperationCount;
89  }
90  else if (Type == IopWriteTransfer)
91  {
92  /* Increase write count */
94  CountToChange = &PsGetCurrentProcess()->WriteOperationCount;
95  }
96  else
97  {
98  /* Increase other count */
100  CountToChange = &PsGetCurrentProcess()->OtherOperationCount;
101  }
102 
103  /* Increase the process-wide count */
104  ExInterlockedAddLargeStatistic(CountToChange, 1);
105  }
106 }
107 
108 static
109 __inline
110 VOID
112 {
113  PLARGE_INTEGER CountToChange;
114  PLARGE_INTEGER TransferToChange;
115 
116  /* Make sure I/O operations are being counted */
117  if (IoCountOperations)
118  {
119  if (Type == IopReadTransfer)
120  {
121  /* Increase read count */
122  CountToChange = &PsGetCurrentProcess()->ReadTransferCount;
123  TransferToChange = &IoReadTransferCount;
124  }
125  else if (Type == IopWriteTransfer)
126  {
127  /* Increase write count */
128  CountToChange = &PsGetCurrentProcess()->WriteTransferCount;
129  TransferToChange = &IoWriteTransferCount;
130  }
131  else
132  {
133  /* Increase other count */
134  CountToChange = &PsGetCurrentProcess()->OtherTransferCount;
135  TransferToChange = &IoOtherTransferCount;
136  }
137 
138  /* Increase the process-wide count */
139  ExInterlockedAddLargeStatistic(CountToChange, TransferCount);
140 
141  /* Increase global count */
142  ExInterlockedAddLargeStatistic(TransferToChange, TransferCount);
143  }
144 }
145 
146 static
147 __inline
148 BOOLEAN
150 {
151  /* Validate the packet */
152  if (!(OpenPacket) ||
153  (OpenPacket->Type != IO_TYPE_OPEN_PACKET) ||
154  (OpenPacket->Size != sizeof(OPEN_PACKET)))
155  {
156  /* Fail */
157  return FALSE;
158  }
159 
160  /* Good packet */
161  return TRUE;
162 }
#define IN
Definition: typedefs.h:38
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
LARGE_INTEGER IoWriteTransferCount
Definition: iomgr.c:42
Type
Definition: Type.h:6
static __inline VOID IopUpdateTransferCount(IN IOP_TRANSFER_TYPE Type, IN ULONG TransferCount)
Definition: io_x.h:111
static __inline BOOLEAN IopValidateOpenPacket(IN POPEN_PACKET OpenPacket)
Definition: io_x.h:149
_In_ PIRP Irp
Definition: csq.h:116
LARGE_INTEGER IoReadTransferCount
Definition: iomgr.c:40
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
#define IO_TYPE_OPEN_PACKET
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3289
NTKERNELAPI VOID FASTCALL ExInterlockedAddLargeStatistic(IN PLARGE_INTEGER Addend, IN ULONG Increment)
Definition: interlocked.c:103
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
ULONG IoWriteOperationCount
Definition: iomgr.c:41
ULONG IoReadOperationCount
Definition: iomgr.c:39
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
static __inline NTSTATUS IopLockFileObject(_In_ PFILE_OBJECT FileObject, _In_ KPROCESSOR_MODE WaitMode)
Definition: io_x.h:12
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define PsGetCurrentProcess
Definition: psfuncs.h:17
unsigned char BOOLEAN
#define FORCEINLINE
Definition: ntbasedef.h:221
FORCEINLINE VOID IopQueueIrpToThread(IN PIRP Irp)
Definition: io_x.h:49
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
enum _IOP_TRANSFER_TYPE IOP_TRANSFER_TYPE
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
* PFILE_OBJECT
Definition: iotypes.h:1954
LARGE_INTEGER IoOtherTransferCount
Definition: iomgr.c:44
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
BOOLEAN IoCountOperations
Definition: iomgr.c:38
#define InterlockedExchange
Definition: armddk.h:54
#define _In_
Definition: no_sal2.h:204
FORCEINLINE VOID IopUnQueueIrpFromThread(IN PIRP Irp)
Definition: io_x.h:65
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define FO_ALERTABLE_IO
Definition: iotypes.h:1733
static __inline VOID IopUnlockFileObject(IN PFILE_OBJECT FileObject)
Definition: io_x.h:36
#define ObReferenceObject
Definition: obfuncs.h:204
static __inline VOID IopUpdateOperationCount(IN IOP_TRANSFER_TYPE Type)
Definition: io_x.h:77
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:565
NTSTATUS NTAPI IopAcquireFileObjectLock(_In_ PFILE_OBJECT FileObject, _In_ KPROCESSOR_MODE AccessMode, _In_ BOOLEAN Alertable, _Out_ PBOOLEAN LockFailed)
Definition: file.c:2449
ULONG IoOtherOperationCount
Definition: iomgr.c:43
return STATUS_SUCCESS
Definition: btrfs.c:2725
signed int * PLONG
Definition: retypes.h:5
#define APC_LEVEL
Definition: env_spec_w32.h:695