ReactOS 0.4.15-dev-7934-g1dc8d80
fxrelateddevicelist.cpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation. All rights reserved.
4
5Module Name:
6
7 FxDependentList.cpp
8
9Abstract:
10 This object derives from the transactioned list and provides a unique
11 object check during the addition of an item.
12
13Author:
14
15
16
17Environment:
18
19 Kernel mode only
20
21Revision History:
22
23--*/
24
25#include "fxsupportpch.hpp"
26
30 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
32 )
33{
34 return FxSpinLockTransactionedList::Add(FxDriverGlobals,
35 &Entry->m_TransactionedEntry);
36}
37
38VOID
40 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
42 )
43{
44 SearchForAndRemove(FxDriverGlobals, (PVOID) Device);
45}
46
51 )
52{
54
55 if (Entry == NULL) {
56 pEntry = NULL;
57 }
58 else {
59 pEntry = &Entry->m_TransactionedEntry;
60 }
61
63
64 if (pReturn != NULL) {
65 return CONTAINING_RECORD(pReturn, FxRelatedDevice, m_TransactionedEntry);
66 }
67 else {
68 return NULL;
69 }
70}
71
76 )
77{
78 FxRelatedDevice* pNew, *pInList;
81
82 pNew = CONTAINING_RECORD(NewEntry, FxRelatedDevice, m_TransactionedEntry);
83
84 pEntry = NULL;
85
86 //
87 // Go over the transactions first because the device could be in the real
88 // list with a transaction to remove it, so we catch first here instead
89 // of adding complexity to the iteration of the already inserted list.
90 //
93 ple = ple->Flink) {
95 pInList = CONTAINING_RECORD(pEntry, FxRelatedDevice, m_TransactionedEntry);
96
97 if (pInList->m_DeviceObject == pNew->m_DeviceObject) {
98 if (pEntry->GetTransactionAction() == FxTransactionActionAdd) {
99 //
100 // An additional add, failure
101 //
103 }
104
105
106 // Removal is OK b/c our add will be right behind it
107 //
108 ASSERT(pEntry->GetTransactionAction() == FxTransactionActionRemove);
109 return STATUS_SUCCESS;
110 }
111 }
112
113 pEntry = NULL;
114 while ((pEntry = FxSpinLockTransactionedList::GetNextEntryLocked(pEntry)) != NULL) { // __super call
115 pInList = CONTAINING_RECORD(pEntry, FxRelatedDevice, m_TransactionedEntry);
116
117 if (pInList->m_DeviceObject == pNew->m_DeviceObject) {
119 }
120 }
121
122 return STATUS_SUCCESS;
123}
124
129 )
130{
131 FxRelatedDevice *pRelated;
132
133 pRelated = CONTAINING_RECORD(Entry, FxRelatedDevice, m_TransactionedEntry);
134
135 return pRelated->GetDevice() == (PDEVICE_OBJECT) Data ? TRUE : FALSE;
136}
137
138VOID
141 )
142{
143 FxRelatedDevice *pRelated;
144
145 pRelated = CONTAINING_RECORD(Entry, FxRelatedDevice, m_TransactionedEntry);
146
149 }
150}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ NTSTATUS Add(__in PFX_DRIVER_GLOBALS Globals, __inout FxRelatedDevice *Entry)
VOID Remove(__in PFX_DRIVER_GLOBALS Globals, __in MdDeviceObject Device)
virtual BOOLEAN Compare(__in FxTransactionedEntry *Entry, __in PVOID Data)
_Must_inspect_result_ FxRelatedDevice * GetNextEntry(__in_opt FxRelatedDevice *Entry)
virtual _Must_inspect_result_ NTSTATUS ProcessAdd(__in FxTransactionedEntry *Entry)
virtual VOID EntryRemoved(__in FxTransactionedEntry *Entry)
MdDeviceObject m_DeviceObject
MdDeviceObject GetDevice(VOID)
FxRelatedDeviceState m_State
_Must_inspect_result_ FxTransactionedEntry * GetNextEntryLocked(__in_opt FxTransactionedEntry *Entry)
_Must_inspect_result_ FxTransactionedEntry * GetNextEntry(__in_opt FxTransactionedEntry *Entry)
VOID SearchForAndRemove(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PVOID EntryData)
NTSTATUS Add(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxTransactionedEntry *Entry)
#define __in
Definition: dbghelp.h:35
#define __inout
Definition: dbghelp.h:50
#define __in_opt
Definition: dbghelp.h:38
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
struct _DEVICE_OBJECT * PDEVICE_OBJECT
PSINGLE_LIST_ENTRY ple
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
@ RelatedDeviceStateReportedPresent
@ FxTransactionActionAdd
@ FxTransactionActionRemove
#define ASSERT(a)
Definition: mode.c:44
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define STATUS_DUPLICATE_OBJECTID
Definition: ntstatus.h:686
#define STATUS_SUCCESS
Definition: shellext.h:65
base of all file and directory entries
Definition: entries.h:83
static FxTransactionedEntry * _FromEntry(__in PLIST_ENTRY Entry)
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474