ReactOS 0.4.15-dev-7924-g5949c20
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
9static
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
33static
34__inline
35VOID
37{
38 /* Unlock the FO and wake any waiters up */
40 if (FileObject->Waiters)
41 {
43 }
45}
46
48VOID
50{
51 PETHREAD Thread = Irp->Tail.Overlay.Thread;
52
53 /* Disable special kernel APCs so we can't race with IopCompleteRequest.
54 * IRP's thread must be the current thread */
56
57 /* Insert it into the list */
58 InsertHeadList(&Thread->IrpList, &Irp->ThreadListEntry);
59
60 /* Leave the guarded region */
62}
63
65VOID
67{
68 /* Special kernel APCs must be disabled so we can't race with
69 * IopCompleteRequest (or because we are called from there) */
71
72 /* Remove it from the list and reset it */
73 if (IsListEmpty(&Irp->ThreadListEntry))
74 return;
75 RemoveEntryList(&Irp->ThreadListEntry);
76 InitializeListHead(&Irp->ThreadListEntry);
77}
78
79static
80__inline
81VOID
83{
84 PLARGE_INTEGER CountToChange;
85
86 /* Make sure I/O operations are being counted */
88 {
89 if (Type == IopReadTransfer)
90 {
91 /* Increase read count */
93 CountToChange = &PsGetCurrentProcess()->ReadOperationCount;
94 }
95 else if (Type == IopWriteTransfer)
96 {
97 /* Increase write count */
99 CountToChange = &PsGetCurrentProcess()->WriteOperationCount;
100 }
101 else
102 {
103 /* Increase other count */
105 CountToChange = &PsGetCurrentProcess()->OtherOperationCount;
106 }
107
108 /* Increase the process-wide count */
109 ExInterlockedAddLargeStatistic(CountToChange, 1);
110 }
111}
112
113static
114__inline
115VOID
117{
118 PLARGE_INTEGER CountToChange;
119 PLARGE_INTEGER TransferToChange;
120
121 /* Make sure I/O operations are being counted */
123 {
124 if (Type == IopReadTransfer)
125 {
126 /* Increase read count */
127 CountToChange = &PsGetCurrentProcess()->ReadTransferCount;
128 TransferToChange = &IoReadTransferCount;
129 }
130 else if (Type == IopWriteTransfer)
131 {
132 /* Increase write count */
133 CountToChange = &PsGetCurrentProcess()->WriteTransferCount;
134 TransferToChange = &IoWriteTransferCount;
135 }
136 else
137 {
138 /* Increase other count */
139 CountToChange = &PsGetCurrentProcess()->OtherTransferCount;
140 TransferToChange = &IoOtherTransferCount;
141 }
142
143 /* Increase the process-wide count */
144 ExInterlockedAddLargeStatistic(CountToChange, TransferCount);
145
146 /* Increase global count */
147 ExInterlockedAddLargeStatistic(TransferToChange, TransferCount);
148 }
149}
150
151static
152__inline
155{
156 /* Validate the packet */
157 if (!(OpenPacket) ||
158 (OpenPacket->Type != IO_TYPE_OPEN_PACKET) ||
159 (OpenPacket->Size != sizeof(OPEN_PACKET)))
160 {
161 /* Fail */
162 return FALSE;
163 }
164
165 /* Good packet */
166 return TRUE;
167}
unsigned char BOOLEAN
Type
Definition: Type.h:7
#define InterlockedExchange
Definition: armddk.h:54
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertHeadList(ListHead, Entry)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
static __inline NTSTATUS IopLockFileObject(_In_ PFILE_OBJECT FileObject, _In_ KPROCESSOR_MODE WaitMode)
Definition: io_x.h:12
static __inline BOOLEAN IopValidateOpenPacket(IN POPEN_PACKET OpenPacket)
Definition: io_x.h:154
FORCEINLINE VOID IopQueueIrpToThread(IN PIRP Irp)
Definition: io_x.h:49
static __inline VOID IopUpdateTransferCount(IN IOP_TRANSFER_TYPE Type, IN ULONG TransferCount)
Definition: io_x.h:116
static __inline VOID IopUpdateOperationCount(IN IOP_TRANSFER_TYPE Type)
Definition: io_x.h:82
static __inline VOID IopUnlockFileObject(IN PFILE_OBJECT FileObject)
Definition: io_x.h:36
FORCEINLINE VOID IopUnQueueIrpFromThread(IN PIRP Irp)
Definition: io_x.h:66
ULONG IoWriteOperationCount
Definition: iomgr.c:41
LARGE_INTEGER IoReadTransferCount
Definition: iomgr.c:40
LARGE_INTEGER IoWriteTransferCount
Definition: iomgr.c:42
ULONG IoOtherOperationCount
Definition: iomgr.c:43
LARGE_INTEGER IoOtherTransferCount
Definition: iomgr.c:44
ULONG IoReadOperationCount
Definition: iomgr.c:39
#define KeEnterGuardedRegionThread(_Thread)
Definition: ke_x.h:27
#define KeLeaveGuardedRegionThread(_Thread)
Definition: ke_x.h:48
#define ASSERT(a)
Definition: mode.c:44
#define _In_
Definition: ms_sal.h:308
enum _IOP_TRANSFER_TYPE IOP_TRANSFER_TYPE
@ IopWriteTransfer
Definition: io.h:262
@ IopReadTransfer
Definition: io.h:261
NTSTATUS NTAPI IopAcquireFileObjectLock(_In_ PFILE_OBJECT FileObject, _In_ KPROCESSOR_MODE AccessMode, _In_ BOOLEAN Alertable, _Out_ PBOOLEAN LockFailed)
Definition: file.c:2450
BOOLEAN NTAPI KeAreAllApcsDisabled(VOID)
Definition: apc.c:985
BOOLEAN IoCountOperations
Definition: iomgr.c:38
#define STATUS_SUCCESS
Definition: shellext.h:65
KTHREAD Tcb
Definition: pstypes.h:1103
LIST_ENTRY IrpList
Definition: pstypes.h:1144
#define IN
Definition: typedefs.h:39
int32_t * PLONG
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
#define FORCEINLINE
Definition: wdftypes.h:67
#define ExInterlockedAddLargeStatistic(Addend, Increment)
Definition: exfuncs.h:850
#define FO_ALERTABLE_IO
Definition: iotypes.h:1777
#define IO_NO_INCREMENT
Definition: iotypes.h:598
* PFILE_OBJECT
Definition: iotypes.h:1998
#define IO_TYPE_OPEN_PACKET
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
#define ObDereferenceObject
Definition: obfuncs.h:203
#define ObReferenceObject
Definition: obfuncs.h:204
#define PsGetCurrentProcess
Definition: psfuncs.h:17
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3287