Merge freeldr from amd64 branch:
[reactos.git] / reactos / drivers / ksfilter / ks / device.c
1 #include "priv.h"
2
3 typedef struct
4 {
5 IKsDeviceVtbl *lpVtbl;
6
7 LONG ref;
8 KSDEVICE KsDevice;
9
10 }IKsDeviceImpl;
11
12
13 NTSTATUS
14 NTAPI
15 IKsDevice_fnQueryInterface(
16 IN IKsDevice * iface,
17 REFIID InterfaceId,
18 PVOID* Interface)
19 {
20 IKsDeviceImpl * This = (IKsDeviceImpl*)iface;
21
22 DPRINT1("IKsDevice_fnQueryInterface %p\n", This);
23 return STATUS_NOT_IMPLEMENTED;
24 }
25
26 ULONG
27 NTAPI
28 IKsDevice_fnAddRef(
29 IN IKsDevice * iface)
30 {
31 IKsDeviceImpl * This = (IKsDeviceImpl*)iface;
32
33 return InterlockedIncrement(&This->ref);
34 }
35
36 ULONG
37 NTAPI
38 IKsDevice_fnRelease(
39 IN IKsDevice * iface)
40 {
41 IKsDeviceImpl * This = (IKsDeviceImpl*)iface;
42
43 InterlockedDecrement(&This->ref);
44
45 if (This->ref == 0)
46 {
47 ExFreePoolWithTag(This, TAG_KSDEVICE);
48 return 0;
49 }
50
51 return This->ref;
52 }
53
54
55
56 KSDEVICE *
57 NTAPI
58 IKsDevice_fnGetStruct(
59 IN IKsDevice * iface)
60 {
61 IKsDeviceImpl * This = (IKsDeviceImpl*)iface;
62
63 return &This->KsDevice;
64 }
65
66 NTSTATUS
67 NTAPI
68 IKsDevice_fnInitializeObjectBag(
69 IN IKsDevice * iface,
70 IN struct KSIOBJECTBAG *Bag,
71 IN KMUTANT * Mutant)
72 {
73 IKsDeviceImpl * This = (IKsDeviceImpl*)iface;
74
75 DPRINT1("IKsDevice_fnInitializeObjectBag %p\n", This);
76 return STATUS_NOT_IMPLEMENTED;
77 }
78
79 NTSTATUS
80 NTAPI
81 IKsDevice_fnAcquireDevice(
82 IN IKsDevice * iface)
83 {
84 IKsDeviceImpl * This = (IKsDeviceImpl*)iface;
85
86 DPRINT1("IKsDevice_fnAcquireDevice %p\n", This);
87 return STATUS_NOT_IMPLEMENTED;
88 }
89
90 NTSTATUS
91 NTAPI
92 IKsDevice_fnReleaseDevice(
93 IN IKsDevice * iface)
94 {
95 IKsDeviceImpl * This = (IKsDeviceImpl*)iface;
96
97 DPRINT1("IKsDevice_fnReleaseDevice %p\n", This);
98 return STATUS_NOT_IMPLEMENTED;
99 }
100
101 NTSTATUS
102 NTAPI
103 IKsDevice_fnGetAdapterObject(
104 IN IKsDevice * iface,
105 IN PADAPTER_OBJECT Object,
106 IN PULONG Unknown1,
107 IN PULONG Unknown2)
108 {
109 IKsDeviceImpl * This = (IKsDeviceImpl*)iface;
110
111 DPRINT1("IKsDevice_fnGetAdapterObject %p\n", This);
112 return STATUS_NOT_IMPLEMENTED;
113
114 }
115
116 NTSTATUS
117 NTAPI
118 IKsDevice_fnAddPowerEntry(
119 IN IKsDevice * iface,
120 IN struct KSPOWER_ENTRY * Entry,
121 IN IKsPowerNotify* Notify)
122 {
123 IKsDeviceImpl * This = (IKsDeviceImpl*)iface;
124
125 DPRINT1("IKsDevice_fnAddPowerEntry %p\n", This);
126 return STATUS_NOT_IMPLEMENTED;
127 }
128
129 NTSTATUS
130 NTAPI
131 IKsDevice_fnRemovePowerEntry(
132 IN IKsDevice * iface,
133 IN struct KSPOWER_ENTRY * Entry)
134 {
135 IKsDeviceImpl * This = (IKsDeviceImpl*)iface;
136
137 DPRINT1("IKsDevice_fnRemovePowerEntry %p\n", This);
138 return STATUS_NOT_IMPLEMENTED;
139
140 }
141
142 NTSTATUS
143 NTAPI
144 IKsDevice_fnPinStateChange(
145 IN IKsDevice * iface,
146 IN KSPIN Pin,
147 IN PIRP Irp,
148 IN KSSTATE OldState,
149 IN KSSTATE NewState)
150 {
151 IKsDeviceImpl * This = (IKsDeviceImpl*)iface;
152
153 DPRINT1("IKsDevice_fnPinStateChange %p\n", This);
154 return STATUS_NOT_IMPLEMENTED;
155
156 }
157
158 NTSTATUS
159 NTAPI
160 IKsDevice_fnArbitrateAdapterChannel(
161 IN IKsDevice * iface,
162 IN ULONG ControlCode,
163 IN IO_ALLOCATION_ACTION Action,
164 IN PVOID Context)
165 {
166 IKsDeviceImpl * This = (IKsDeviceImpl*)iface;
167
168 DPRINT1("IKsDevice_fnArbitrateAdapterChannel %p\n", This);
169 return STATUS_NOT_IMPLEMENTED;
170
171 }
172
173 NTSTATUS
174 NTAPI
175 IKsDevice_fnCheckIoCapability(
176 IN IKsDevice * iface,
177 IN ULONG Unknown)
178 {
179 IKsDeviceImpl * This = (IKsDeviceImpl*)iface;
180
181 DPRINT1("IKsDevice_fnCheckIoCapability %p\n", This);
182 return STATUS_NOT_IMPLEMENTED;
183 }
184
185 static IKsDeviceVtbl vt_IKsDevice =
186 {
187 IKsDevice_fnQueryInterface,
188 IKsDevice_fnAddRef,
189 IKsDevice_fnRelease,
190 IKsDevice_fnGetStruct,
191 IKsDevice_fnInitializeObjectBag,
192 IKsDevice_fnAcquireDevice,
193 IKsDevice_fnReleaseDevice,
194 IKsDevice_fnGetAdapterObject,
195 IKsDevice_fnAddPowerEntry,
196 IKsDevice_fnRemovePowerEntry,
197 IKsDevice_fnPinStateChange,
198 IKsDevice_fnArbitrateAdapterChannel,
199 IKsDevice_fnCheckIoCapability
200 };
201
202
203
204 NTSTATUS
205 NTAPI
206 NewIKsDevice(IKsDevice** OutDevice)
207 {
208 IKsDeviceImpl * This;
209
210 This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IKsDeviceImpl), TAG_KSDEVICE);
211 if (!This)
212 return STATUS_INSUFFICIENT_RESOURCES;
213
214 This->ref = 1;
215 This->lpVtbl = &vt_IKsDevice;
216
217 *OutDevice = (IKsDevice*)This;
218 return STATUS_SUCCESS;
219 }
220