xref: /reactos/sdk/include/ddk/portcls.h (revision c2c66aff)
1 /*
2     ReactOS Kernel Streaming
3     Port Class
4 
5     This file is in the public domain.
6 
7     Andrew Greenwood
8 
9     NOTES:
10     Does not support PC_OLD_NAMES (which is required for backwards-compatibility
11     with older code)
12 
13     Obsolete macros are not implemented. For more info:
14     http://www.osronline.com/ddkx/stream/audpc-struct_167n.htm
15 
16 
17     == EXPORTS ==
18     DRM (new in XP):
19     * PcAddContentHandlers
20     * PcCreateContentMixed
21     * PcDestroyContent
22     * PcForwardContentToDeviceObject
23     * PcForwardContentToFileObject
24     * PcForwardContentToInterface
25     * PcGetContentRights
26 
27     IRP HANDLING:
28     * PcCompleteIrp
29     * PcDispatchIrp
30     * PcForwardIrpSynchronous
31 
32     ADAPTER:
33     * PcAddAdapterDevice
34     * PcInitializeAdapterDriver
35 
36     FACTORIES:
37     * PcNewDmaChannel
38     * PcNewInterruptSync
39     * PcNewMiniport
40     * PcNewPort
41     * PcNewRegistryKey
42     * PcNewResourceList
43     * PcNewResourceSublist
44     * PcNewServiceGroup
45 
46     POWER MANAGEMENT:
47     * PcRegisterAdapterPowerManagement
48     * PcRequestNewPowerState
49 
50     PROPERTIES:
51     * PcCompletePendingPropertyRequest
52     * PcGetDeviceProperty
53 
54     IO TIMEOUTS:
55     * PcRegisterIoTimeout
56     * PcUnregisterIoTimeout
57 
58     PHYSICAL CONNECTIONS:
59     * PcRegisterPhysicalConnection
60     * PcRegisterPhysicalConnectionFromExternal
61     * PcRegisterPhysicalConnectionToExternal
62 
63     MISC:
64     * PcGetTimeInterval
65     * PcRegisterSubdevice
66 
67 
68     == AUDIO HELPER OBJECT INTERFACES ==
69     IDmaChannel
70     IDmaChannelSlave
71     IDmaOperations
72     IDrmPort                        (XP)
73     IDrmPort2                       (XP)
74     IInterruptSync
75     IMasterClock
76     IPortClsVersion                 (XP)
77     IPortEvents
78     IPreFetchOffset                 (XP)
79     IRegistryKey
80     IResourceList
81     IServiceGroup
82     IServiceSink
83     IUnregisterPhysicalConnection   (Vista)
84     IUnregisterSubdevice            (Vista)
85 
86     == AUDIO PORT OBJECT INTERFACES ==
87     IPort
88     IPortDMus
89     IPortMidi
90     IPortTopology
91     IPortWaveCyclic
92     IPortWavePci
93 
94     == AUDIO MINIPORT OBJECT INTERFACES ==
95     IMiniport
96     IMiniportDMus
97     IMiniportMidi
98     IMiniportTopology
99     IMiniportWaveCyclic
100     IMiniportWavePci
101 
102     == AUDIO MINIPORT AUXILIARY INTERFACES ==
103     IMusicTechnology                (XP)
104     IPinCount                       (XP)
105 
106     == AUDIO STREAM OBJECT INTERFACES ==
107     IAllocatorMXF
108     IDrmAudioStream                 (XP)
109     IMiniportMidiStream
110     IMiniportWaveCyclicStream
111     IMiniportWavePciStream
112     IMXF
113     IPortWavePciStream
114     ISynthSinkDMus
115 
116     == DIRECTMUSIC USERMODE SYNTH AND SYNTH SINK INTERFACES ==
117     IDirectMusicSynth
118     IDirectMusicSynthSink
119 
120     == AUDIO POWER MANAGEMENT INTERFACES ==
121     IAdapterPowerManagement
122     IPowerNotify
123 */
124 
125 #ifndef PORTCLS_H
126 #define PORTCLS_H
127 
128 #ifdef __cplusplus
129 extern "C" {
130 #include <wdm.h>
131 }
132 #else
133 #include <wdm.h>
134 #endif
135 
136 #include <windef.h>
137 
138 #define NOBITMAP
139 #include <mmreg.h>
140 #undef NOBITMAP
141 
142 #include <punknown.h>
143 #include <ks.h>
144 #include <ksmedia.h>
145 #include <drmk.h>
146 
147 #ifndef PC_NO_IMPORTS
148 #define PORTCLASSAPI EXTERN_C __declspec(dllimport)
149 #else
150 #define PORTCLASSAPI EXTERN_C
151 #endif
152 
153 /* TODO */
154 #define PCFILTER_NODE ((ULONG) -1)
155 
156 /* HACK */
157 /* typedef PVOID CM_RESOURCE_TYPE; */
158 
159 #define _100NS_UNITS_PER_SECOND 10000000L
160 #define PORT_CLASS_DEVICE_EXTENSION_SIZE ( 64 * sizeof(ULONG_PTR) )
161 
162 
163 DEFINE_GUID(CLSID_MiniportDriverFmSynth, 0xb4c90ae0L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
164 DEFINE_GUID(CLSID_MiniportDriverFmSynthWithVol, 0xe5a3c139L, 0xf0f2, 0x11d1, 0x81, 0xaf, 0x00, 0x60, 0x08, 0x33, 0x16, 0xc1);
165 
166 /* ===============================================================
167     Event Item Flags - TODO
168 */
169 #define PCEVENT_ITEM_FLAG_ENABLE            KSEVENT_TYPE_ENABLE
170 #define PCEVENT_ITEM_FLAG_ONESHOT           KSEVENT_TYPE_ONESHOT
171 #define PCEVENT_ITEM_FLAG_BASICSUPPORT      KSEVENT_TYPE_BASICSUPPORT
172 
173 
174 /* ===============================================================
175     Event Verbs - TODO
176 */
177 #define PCEVENT_VERB_NONE       0
178 #define PCEVENT_VERB_ADD        1
179 #define PCEVENT_VERB_REMOVE     2
180 #define PCEVENT_VERB_SUPPORT    4
181 
182 
183 /* ===============================================================
184     Method Item Flags - TODO
185 */
186 #define PCMETHOD_ITEM_FLAG_NONE             KSMETHOD_TYPE_NONE
187 #define PCMETHOD_ITEM_FLAG_READ             KSMETHOD_TYPE_READ
188 #define PCMETHOD_ITEM_FLAG_WRITE            KSMETHOD_TYPE_WRITE
189 #define PCMETHOD_ITEM_FLAG_MODIFY           KSMETHOD_TYPE_MODIFY
190 #define PCMETHOD_ITEM_FLAG_SOURCE           KSMETHOD_TYPE_SOURCE
191 
192 
193 /* ===============================================================
194     Method Verbs - TODO
195 */
196 #define PCMETHOD_ITEM_FLAG_BASICSUPPORT     KSMETHOD_TYPE_BASICSUPPORT
197 #define PCMETHOD_ITEM_FLAG_SEND
198 #define PCMETHOD_ITEM_FLAG_SETSUPPORT
199 
200 
201 /* ===============================================================
202     Versions
203     IoIsWdmVersionAvailable may also be used by older drivers.
204 */
205 
206 enum {
207   kVersionInvalid = -1,
208   kVersionWin98,
209   kVersionWin98SE,
210   kVersionWin2K,
211   kVersionWin98SE_QFE2,
212   kVersionWin2K_SP2,
213   kVersionWinME,
214   kVersionWin98SE_QFE3,
215   kVersionWinME_QFE1,
216   kVersionWinXP,
217   kVersionWinXPSP1,
218   kVersionWinServer2003,
219   kVersionWin2K_UAAQFE,           /* These support IUnregister* interface */
220   kVersionWinXP_UAAQFE,
221   kVersionWinServer2003_UAAQFE
222 };
223 
224 /* ===============================================================
225     Properties
226 */
227 
228 struct _PCPROPERTY_REQUEST;
229 
230 typedef struct _PCPROPERTY_REQUEST PCPROPERTY_REQUEST, *PPCPROPERTY_REQUEST;
231 
232 typedef NTSTATUS
233 (NTAPI *PCPFNPROPERTY_HANDLER)(
234   IN  PPCPROPERTY_REQUEST PropertyRequest);
235 
236 typedef struct {
237   const GUID *Set;
238   ULONG Id;
239   ULONG Flags;
240 #define PCPROPERTY_ITEM_FLAG_GET            KSPROPERTY_TYPE_GET
241 #define PCPROPERTY_ITEM_FLAG_SET            KSPROPERTY_TYPE_SET
242 #define PCPROPERTY_ITEM_FLAG_BASICSUPPORT   KSPROPERTY_TYPE_BASICSUPPORT
243   //not supported #define PCPROPERTY_ITEM_FLAG_RELATIONS      KSPROPERTY_TYPE_RELATIONS
244 #define PCPROPERTY_ITEM_FLAG_SERIALIZERAW   KSPROPERTY_TYPE_SERIALIZERAW
245 #define PCPROPERTY_ITEM_FLAG_UNSERIALIZERAW KSPROPERTY_TYPE_UNSERIALIZERAW
246 #define PCPROPERTY_ITEM_FLAG_SERIALIZESIZE  KSPROPERTY_TYPE_SERIALIZESIZE
247 #define PCPROPERTY_ITEM_FLAG_SERIALIZE\
248   (PCPROPERTY_ITEM_FLAG_SERIALIZERAW\
249   |PCPROPERTY_ITEM_FLAG_UNSERIALIZERAW\
250   |PCPROPERTY_ITEM_FLAG_SERIALIZESIZE\
251   )
252 #define PCPROPERTY_ITEM_FLAG_DEFAULTVALUES  KSPROPERTY_TYPE_DEFAULTVALUES
253   PCPFNPROPERTY_HANDLER Handler;
254 }
255 PCPROPERTY_ITEM, *PPCPROPERTY_ITEM;
256 
257 struct _PCPROPERTY_REQUEST {
258   PUNKNOWN MajorTarget;
259   PUNKNOWN MinorTarget;
260   ULONG Node;
261   const PCPROPERTY_ITEM *PropertyItem;
262   ULONG Verb;
263   ULONG InstanceSize;
264   PVOID Instance;
265   ULONG ValueSize;
266   PVOID Value;
267   PIRP Irp;
268 };
269 
270 struct _PCEVENT_REQUEST;
271 
272 typedef NTSTATUS
273 (NTAPI *PCPFNEVENT_HANDLER)(
274   IN struct _PCEVENT_REQUEST* EventRequest);
275 
276 typedef struct _PCEVENT_ITEM {
277   const GUID* Set;
278   ULONG Id;
279   ULONG Flags;
280   PCPFNEVENT_HANDLER Handler;
281 } PCEVENT_ITEM, *PPCEVENT_ITEM;
282 
283 typedef struct _PCEVENT_REQUEST {
284   PUNKNOWN MajorTarget;
285   PUNKNOWN MinorTarget;
286   ULONG Node;
287   const PCEVENT_ITEM* EventItem;
288   PKSEVENT_ENTRY EventEntry;
289   ULONG Verb;
290   PIRP Irp;
291 } PCEVENT_REQUEST, *PPCEVENT_REQUEST;
292 
293 struct _PCMETHOD_REQUEST;
294 
295 typedef NTSTATUS
296 (NTAPI *PCPFNMETHOD_HANDLER)(
297   IN struct _PCMETHOD_REQUEST* MethodRequest);
298 
299 typedef struct _PCMETHOD_ITEM {
300   const GUID* Set;
301   ULONG Id;
302   ULONG Flags;
303   PCPFNMETHOD_HANDLER Handler;
304 } PCMETHOD_ITEM, *PPCMETHOD_ITEM;
305 
306 typedef struct _PCMETHOD_REQUEST {
307   PUNKNOWN MajorTarget;
308   PUNKNOWN MinorTarget;
309   ULONG Node;
310   const PCMETHOD_ITEM* MethodItem;
311   ULONG Verb;
312 } PCMETHOD_REQUEST, *PPCMETHOD_REQUEST;
313 
314 /* ===============================================================
315     Structures (unsorted)
316 */
317 
318 typedef struct {
319   ULONG PropertyItemSize;
320   ULONG PropertyCount;
321   const PCPROPERTY_ITEM* Properties;
322   ULONG MethodItemSize;
323   ULONG MethodCount;
324   const PCMETHOD_ITEM* Methods;
325   ULONG EventItemSize;
326   ULONG EventCount;
327   const PCEVENT_ITEM* Events;
328   ULONG Reserved;
329 } PCAUTOMATION_TABLE, *PPCAUTOMATION_TABLE;
330 
331 typedef struct {
332   ULONG FromNode;
333   ULONG FromNodePin;
334   ULONG ToNode;
335   ULONG ToNodePin;
336 } PCCONNECTION_DESCRIPTOR, *PPCCONNECTIONDESCRIPTOR;
337 
338 typedef struct {
339   ULONG MaxGlobalInstanceCount;
340   ULONG MaxFilterInstanceCount;
341   ULONG MinFilterInstanceCount;
342   const PCAUTOMATION_TABLE* AutomationTable;
343   KSPIN_DESCRIPTOR KsPinDescriptor;
344 } PCPIN_DESCRIPTOR, *PPCPIN_DESCRIPTOR;
345 
346 typedef struct {
347   ULONG Flags;
348   const PCAUTOMATION_TABLE* AutomationTable;
349   const GUID* Type;
350   const GUID* Name;
351 } PCNODE_DESCRIPTOR, *PPCNODE_DESCRIPTOR;
352 
353 typedef struct {
354   ULONG Version;
355   const PCAUTOMATION_TABLE* AutomationTable;
356   ULONG PinSize;
357   ULONG PinCount;
358   const PCPIN_DESCRIPTOR* Pins;
359   ULONG NodeSize;
360   ULONG NodeCount;
361   const PCNODE_DESCRIPTOR* Nodes;
362   ULONG ConnectionCount;
363   const PCCONNECTION_DESCRIPTOR* Connections;
364   ULONG CategoryCount;
365   const GUID* Categories;
366 } PCFILTER_DESCRIPTOR, *PPCFILTER_DESCRIPTOR;
367 
368 #define DEFINE_PCAUTOMATION_TABLE_PROP(AutomationTable,PropertyTable) \
369   const PCAUTOMATION_TABLE AutomationTable = {                        \
370     sizeof(PropertyTable[0]),                                         \
371     SIZEOF_ARRAY(PropertyTable),                                      \
372     (const PCPROPERTY_ITEM *) PropertyTable,                          \
373     0,0,NULL,                                                         \
374     0,0,NULL,                                                         \
375     0                                                                 \
376   }
377 
378 /* ===============================================================
379     IResourceList Interface
380 */
381 
382 #undef INTERFACE
383 #define INTERFACE IResourceList
384 
385 DEFINE_GUID(IID_IResourceList, 0x22C6AC60L, 0x851B, 0x11D0, 0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE);
386 
387 DECLARE_INTERFACE_(IResourceList, IUnknown) {
388   DEFINE_ABSTRACT_UNKNOWN()
389 
390   STDMETHOD_(ULONG, NumberOfEntries)( THIS ) PURE;
391 
392   STDMETHOD_(ULONG, NumberOfEntriesOfType)( THIS_
393     IN CM_RESOURCE_TYPE Type) PURE;
394 
395   STDMETHOD_(PCM_PARTIAL_RESOURCE_DESCRIPTOR, FindTranslatedEntry)( THIS_
396     IN CM_RESOURCE_TYPE Type,
397     IN ULONG Index) PURE;
398 
399   STDMETHOD_(PCM_PARTIAL_RESOURCE_DESCRIPTOR, FindUntranslatedEntry)( THIS_
400     IN CM_RESOURCE_TYPE Type,
401     IN ULONG Index) PURE;
402 
403   STDMETHOD_(NTSTATUS, AddEntry)( THIS_
404     IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Translated,
405     IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Untranslated) PURE;
406 
407   STDMETHOD_(NTSTATUS, AddEntryFromParent)( THIS_
408     IN IResourceList* Parent,
409     IN CM_RESOURCE_TYPE Type,
410     IN ULONG Index) PURE;
411 
412   STDMETHOD_(PCM_RESOURCE_LIST, TranslatedList)( THIS ) PURE;
413   STDMETHOD_(PCM_RESOURCE_LIST, UntranslatedList)( THIS ) PURE;
414 };
415 
416 #define IMP_IResourceList \
417     STDMETHODIMP_(ULONG) NumberOfEntries(void); \
418 \
419     STDMETHODIMP_(ULONG) NumberOfEntriesOfType( \
420         IN  CM_RESOURCE_TYPE Type); \
421 \
422     STDMETHODIMP_(PCM_PARTIAL_RESOURCE_DESCRIPTOR) FindTranslatedEntry( \
423         IN  CM_RESOURCE_TYPE Type, \
424         IN  ULONG Index); \
425 \
426     STDMETHODIMP_(PCM_PARTIAL_RESOURCE_DESCRIPTOR) FindUntranslatedEntry( \
427         IN  CM_RESOURCE_TYPE Type, \
428         IN  ULONG Index); \
429 \
430     STDMETHODIMP_(NTSTATUS) AddEntry( \
431         IN  PCM_PARTIAL_RESOURCE_DESCRIPTOR Translated, \
432         IN  PCM_PARTIAL_RESOURCE_DESCRIPTOR Untranslated); \
433 \
434     STDMETHODIMP_(NTSTATUS) AddEntryFromParent( \
435         IN  IResourceList* Parent, \
436         IN  CM_RESOURCE_TYPE Type, \
437         IN  ULONG Index); \
438 \
439     STDMETHODIMP_(PCM_RESOURCE_LIST) TranslatedList(void); \
440     STDMETHODIMP_(PCM_RESOURCE_LIST) UntranslatedList(void);
441 
442 typedef IResourceList *PRESOURCELIST;
443 
444 #define NumberOfPorts() \
445   NumberOfEntriesOfType(CmResourceTypePort)
446 
447 #define FindTranslatedPort(n) \
448   FindTranslatedEntry(CmResourceTypePort, (n))
449 
450 #define FindUntranslatedPort(n) \
451   FindUntranslatedEntry(CmResourceTypePort, (n))
452 
453 #define AddPortFromParent(p, n) \
454   AddEntryFromParent((p), CmResourceTypePort, (n))
455 
456 #define NumberOfInterrupts() \
457   NumberOfEntriesOfType(CmResourceTypeInterrupt)
458 
459 #define FindTranslatedInterrupt(n) \
460   FindTranslatedEntry(CmResourceTypeInterrupt, (n))
461 
462 #define FindUntranslatedInterrupt(n) \
463   FindUntranslatedEntry(CmResourceTypeInterrupt, (n))
464 
465 #define AddInterruptFromParent(p, n) \
466   AddEntryFromParent((p), CmResourceTypeInterrupt, (n))
467 
468 #define NumberOfMemories() \
469   NumberOfEntriesOfType(CmResourceTypeMemory)
470 
471 #define FindTranslatedMemory(n) \
472   FindTranslatedEntry(CmResourceTypeMemory, (n))
473 
474 #define FindUntranslatedMemory(n) \
475   FindUntranslatedEntry(CmResourceTypeMemory, (n))
476 
477 #define AddMemoryFromParent(p, n) \
478   AddEntryFromParent((p), CmResourceTypeMemory, (n))
479 
480 #define NumberOfDmas() \
481   NumberOfEntriesOfType(CmResourceTypeDma)
482 
483 #define FindTranslatedDma(n) \
484   FindTranslatedEntry(CmResourceTypeDma, (n))
485 
486 #define FindUntranslatedDma(n) \
487   FindUntranslatedEntry(CmResourceTypeDma, (n))
488 
489 #define AddDmaFromParent(p, n) \
490   AddEntryFromParent((p), CmResourceTypeInterrupt, (n))
491 
492 #define NumberOfDeviceSpecifics() \
493   NumberOfEntriesOfType(CmResourceTypeDeviceSpecific)
494 
495 #define FindTranslatedDeviceSpecific(n) \
496   FindTranslatedEntry(CmResourceTypeDeviceSpecific, (n))
497 
498 #define FindUntranslatedDeviceSpecific(n) \
499   FindUntranslatedEntry(CmResourceTypeDeviceSpecific, (n))
500 
501 #define AddDeviceSpecificFromParent(p, n) \
502   AddEntryFromParent((p), CmResourceTypeDeviceSpecific, (n))
503 
504 #define NumberOfBusNumbers() \
505   NumberOfEntriesOfType(CmResourceTypeBusNumber)
506 
507 #define FindTranslatedBusNumber(n) \
508   FindTranslatedEntry(CmResourceTypeBusNumber, (n))
509 
510 #define FindUntranslatedBusNumber(n) \
511   FindUntranslatedEntry(CmResourceTypeBusNumber, (n))
512 
513 #define AddBusNumberFromParent(p, n) \
514   AddEntryFromParent((p), CmResourceTypeBusNumber, (n))
515 
516 #define NumberOfDevicePrivates() \
517   NumberOfEntriesOfType(CmResourceTypeDevicePrivate)
518 
519 #define FindTranslatedDevicePrivate(n) \
520   FindTranslatedEntry(CmResourceTypeDevicePrivate, (n))
521 
522 #define FindUntranslatedDevicePrivate(n) \
523   FindUntranslatedEntry(CmResourceTypeDevicePrivate, (n))
524 
525 #define AddDevicePrivateFromParent(p, n) \
526   AddEntryFromParent((p), CmResourceTypeDevicePrivate, (n))
527 
528 #define NumberOfAssignedResources() \
529   NumberOfEntriesOfType(CmResourceTypeAssignedResource)
530 
531 #define FindTranslatedAssignedResource(n) \
532   FindTranslatedEntry(CmResourceTypeAssignedResource, (n))
533 
534 #define FindUntranslatedAssignedResource(n) \
535   FindUntranslatedEntry(CmResourceTypeAssignedResource, (n))
536 
537 #define AddAssignedResourceFromParent(p, n) \
538   AddEntryFromParent((p), CmResourceTypeAssignedResource, (n))
539 
540 #define NumberOfSubAllocateFroms() \
541   NumberOfEntriesOfType(CmResourceTypeSubAllocateFrom)
542 
543 #define FindTranslatedSubAllocateFrom(n) \
544   FindTranslatedEntry(CmResourceTypeSubAllocateFrom, (n))
545 
546 #define FindUntranslatedSubAllocateFrom(n) \
547   FindUntranslatedEntry(CmResourceTypeSubAllocateFrom, (n))
548 
549 #define AddSubAllocateFromFromParent(p, n) \
550   AddEntryFromParent((p), CmResourceTypeSubAllocateFrom, (n))
551 
552 #undef INTERFACE
553 
554 /* ===============================================================
555     IServiceSink Interface
556 */
557 #define INTERFACE IServiceSink
558 
559 DEFINE_GUID(IID_IServiceSink, 0x22C6AC64L, 0x851B, 0x11D0, 0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE);
560 
561 DECLARE_INTERFACE_(IServiceSink, IUnknown) {
562   DEFINE_ABSTRACT_UNKNOWN()
563   STDMETHOD_(void, RequestService)( THIS ) PURE;
564 };
565 
566 #define IMP_IServiceSink \
567   STDMETHODIMP_(void) RequestService(void);
568 
569 typedef IServiceSink *PSERVICESINK;
570 
571 /* ===============================================================
572     IServiceGroup Interface
573 */
574 #undef INTERFACE
575 #define INTERFACE IServiceGroup
576 
577 DEFINE_GUID(IID_IServiceGroup, 0x22C6AC65L, 0x851B, 0x11D0, 0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE);
578 
579 DECLARE_INTERFACE_(IServiceGroup, IServiceSink) {
580   DEFINE_ABSTRACT_UNKNOWN()
581 
582   STDMETHOD_(void, RequestService)( THIS ) PURE;  /* IServiceSink */
583 
584   STDMETHOD_(NTSTATUS, AddMember)( THIS_
585     IN PSERVICESINK pServiceSink) PURE;
586 
587   STDMETHOD_(void, RemoveMember)( THIS_
588     IN PSERVICESINK pServiceSink) PURE;
589 
590   STDMETHOD_(void, SupportDelayedService)( THIS ) PURE;
591 
592   STDMETHOD_(void, RequestDelayedService)( THIS_
593     IN ULONGLONG ullDelay) PURE;
594 
595   STDMETHOD_(void, CancelDelayedService)( THIS ) PURE;
596 };
597 
598 #define IMP_IServiceGroup \
599     IMP_IServiceSink; \
600 \
601     STDMETHODIMP_(NTSTATUS) AddMember( \
602         IN  PSERVICESINK pServiceSink); \
603 \
604     STDMETHODIMP_(void) RemoveMember( \
605         IN  PSERVICESINK pServiceSink); \
606 \
607     STDMETHODIMP_(void) SupportDelayedService(void); \
608 \
609     STDMETHODIMP_(void) RequestDelayedService( \
610         IN  ULONGLONG ullDelay); \
611 \
612     STDMETHODIMP_(void) CancelDelayedService(void);
613 
614 typedef IServiceGroup *PSERVICEGROUP;
615 
616 
617 #if (NTDDI_VERSION >= NTDDI_WS03)
618 /* ===============================================================
619     IUnregisterSubdevice Interface
620 */
621 
622 DEFINE_GUID(IID_IUnregisterSubdevice, 0x16738177L, 0xe199, 0x41f9, 0x9a, 0x87, 0xab, 0xb2, 0xa5, 0x43, 0x2f, 0x21);
623 
624 #undef INTERFACE
625 #define INTERFACE IUnregisterSubdevice
626 
627 DECLARE_INTERFACE_(IUnregisterSubdevice,IUnknown) {
628   DEFINE_ABSTRACT_UNKNOWN()
629 
630   STDMETHOD_(NTSTATUS,UnregisterSubdevice)(THIS_
631     IN PDEVICE_OBJECT DeviceObject,
632     IN PUNKNOWN Unknown) PURE;
633 };
634 
635 typedef IUnregisterSubdevice *PUNREGISTERSUBDEVICE;
636 
637 #define IMP_IUnregisterSubdevice                      \
638   STDMETHODIMP_(NTSTATUS) UnregisterSubdevice(THIS_   \
639     IN PDEVICE_OBJECT DeviceObject,                   \
640     IN PUNKNOWN Unknown)
641 
642 /* ===============================================================
643     IUnregisterPhysicalConnection Interface
644 */
645 
646 #undef INTERFACE
647 #define INTERFACE IUnregisterPhysicalConnection
648 
649 DEFINE_GUID(IID_IUnregisterPhysicalConnection, 0x6c38e231L, 0x2a0d, 0x428d, 0x81, 0xf8, 0x07, 0xcc, 0x42, 0x8b, 0xb9, 0xa4);
650 
651 DECLARE_INTERFACE_(IUnregisterPhysicalConnection,IUnknown)
652 {
653     DEFINE_ABSTRACT_UNKNOWN()
654 
655     STDMETHOD_(NTSTATUS,UnregisterPhysicalConnection)(THIS_
656         IN  PDEVICE_OBJECT  DeviceObject,
657         IN  PUNKNOWN        FromUnknown,
658         IN  ULONG           FromPin,
659         IN  PUNKNOWN        ToUnknown,
660         IN  ULONG           ToPin)PURE;
661 
662     STDMETHOD_(NTSTATUS,UnregisterPhysicalConnectionToExternal)(THIS_
663         IN  PDEVICE_OBJECT  DeviceObject,
664         IN  PUNKNOWN        FromUnknown,
665         IN  ULONG           FromPin,
666         IN  PUNICODE_STRING ToString,
667         IN  ULONG           ToPin)PURE;
668 
669     STDMETHOD_(NTSTATUS,UnregisterPhysicalConnectionFromExternal)(THIS_
670         IN  PDEVICE_OBJECT  DeviceObject,
671         IN  PUNICODE_STRING FromString,
672         IN  ULONG           FromPin,
673         IN  PUNKNOWN        ToUnknown,
674         IN  ULONG           ToPin)PURE;
675 };
676 
677 typedef IUnregisterPhysicalConnection *PUNREGISTERPHYSICALCONNECTION;
678 #endif
679 
680 #define IMP_IUnregisterPhysicalConnection                                    \
681     STDMETHODIMP_(NTSTATUS) UnregisterPhysicalConnection(                    \
682         IN  PDEVICE_OBJECT  DeviceObject,                                    \
683         IN  PUNKNOWN        FromUnknown,                                     \
684         IN  ULONG           FromPin,                                         \
685         IN  PUNKNOWN        ToUnknown,                                       \
686         IN  ULONG           ToPin);                                          \
687                                                                              \
688     STDMETHODIMP_(NTSTATUS) UnregisterPhysicalConnectionToExternal(          \
689         IN  PDEVICE_OBJECT  DeviceObject,                                    \
690         IN  PUNKNOWN        FromUnknown,                                     \
691         IN  ULONG           FromPin,                                         \
692         IN  PUNICODE_STRING ToString,                                        \
693         IN  ULONG           ToPin);                                          \
694                                                                              \
695     STDMETHODIMP_(NTSTATUS) UnregisterPhysicalConnectionFromExternal(        \
696         IN  PDEVICE_OBJECT  DeviceObject,                                    \
697         IN  PUNICODE_STRING FromString,                                      \
698         IN  ULONG           FromPin,                                         \
699         IN  PUNKNOWN        ToUnknown,                                       \
700         IN  ULONG           ToPin)
701 
702 
703 /* ===============================================================
704     IDmaChannel Interface
705 */
706 
707 #define DEFINE_ABSTRACT_DMACHANNEL() \
708     STDMETHOD_(NTSTATUS, AllocateBuffer)( THIS_ \
709         IN  ULONG BufferSize, \
710         IN  PPHYSICAL_ADDRESS PhysicalAddressConstraint OPTIONAL) PURE; \
711 \
712     STDMETHOD_(void, FreeBuffer)( THIS ) PURE; \
713     STDMETHOD_(ULONG, TransferCount)( THIS ) PURE; \
714     STDMETHOD_(ULONG, MaximumBufferSize)( THIS ) PURE; \
715     STDMETHOD_(ULONG, AllocatedBufferSize)( THIS ) PURE; \
716     STDMETHOD_(ULONG, BufferSize)( THIS ) PURE; \
717 \
718     STDMETHOD_(void, SetBufferSize)( THIS_ \
719         IN  ULONG BufferSize) PURE; \
720 \
721     STDMETHOD_(PVOID, SystemAddress)( THIS ) PURE; \
722     STDMETHOD_(PHYSICAL_ADDRESS, PhysicalAddress)( THIS ) PURE; \
723     STDMETHOD_(PADAPTER_OBJECT, GetAdapterObject)( THIS ) PURE; \
724 \
725     STDMETHOD_(void, CopyTo)( THIS_ \
726         IN  PVOID Destination, \
727         IN  PVOID Source, \
728         IN  ULONG ByteCount) PURE; \
729 \
730     STDMETHOD_(void, CopyFrom)( THIS_ \
731         IN  PVOID Destination, \
732         IN  PVOID Source, \
733         IN  ULONG ByteCount) PURE;
734 
735 #define IMP_IDmaChannel                                                   \
736     STDMETHODIMP_(NTSTATUS) AllocateBuffer(                               \
737         IN  ULONG BufferSize,                                             \
738         IN  PPHYSICAL_ADDRESS PhysicalAddressConstraint OPTIONAL);        \
739                                                                           \
740     STDMETHODIMP_(void) FreeBuffer(void);                                 \
741     STDMETHODIMP_(ULONG) TransferCount(void);                             \
742     STDMETHODIMP_(ULONG) MaximumBufferSize(void);                         \
743     STDMETHODIMP_(ULONG) AllocatedBufferSize(void);                       \
744     STDMETHODIMP_(ULONG) BufferSize(void);                                \
745                                                                           \
746     STDMETHODIMP_(void) SetBufferSize(                                    \
747         IN  ULONG BufferSize);                                            \
748                                                                           \
749     STDMETHODIMP_(PVOID) SystemAddress(void);                             \
750     STDMETHODIMP_(PHYSICAL_ADDRESS) PhysicalAddress(void);                \
751     STDMETHODIMP_(PADAPTER_OBJECT) GetAdapterObject(void);                \
752                                                                           \
753     STDMETHODIMP_(void) CopyTo(                                           \
754         IN  PVOID Destination,                                            \
755         IN  PVOID Source,                                                 \
756         IN  ULONG ByteCount);                                             \
757                                                                           \
758     STDMETHODIMP_(void) CopyFrom(                                         \
759         IN  PVOID Destination,                                            \
760         IN  PVOID Source,                                                 \
761         IN  ULONG ByteCount)
762 
763 #undef INTERFACE
764 #define INTERFACE IDmaChannel
765 
766 DEFINE_GUID(IID_IDmaChannel, 0x22C6AC61L, 0x851B, 0x11D0, 0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE);
767 
768 DECLARE_INTERFACE_(IDmaChannel, IUnknown)
769 {
770     DEFINE_ABSTRACT_UNKNOWN()
771     DEFINE_ABSTRACT_DMACHANNEL()
772 };
773 
774 typedef IDmaChannel *PDMACHANNEL;
775 
776 
777 /* ===============================================================
778     IDmaChannelSlave Interface
779 */
780 
781 #define DEFINE_ABSTRACT_DMACHANNELSLAVE() \
782     STDMETHOD_(NTSTATUS, Start)( THIS_ \
783         IN  ULONG MapSize, \
784         IN  BOOLEAN WriteToDevice) PURE; \
785 \
786     STDMETHOD_(NTSTATUS, Stop)( THIS ) PURE; \
787     STDMETHOD_(ULONG, ReadCounter)( THIS ) PURE; \
788 \
789     STDMETHOD_(NTSTATUS, WaitForTC)( THIS_ \
790         ULONG Timeout) PURE;
791 
792 #define IMP_IDmaChannelSlave                   \
793     IMP_IDmaChannel;                           \
794     STDMETHODIMP_(NTSTATUS) Start(             \
795         IN  ULONG MapSize,                     \
796         IN  BOOLEAN WriteToDevice);            \
797                                                \
798     STDMETHODIMP_(NTSTATUS) Stop(void);        \
799     STDMETHODIMP_(ULONG) ReadCounter(void);    \
800                                                \
801     STDMETHODIMP_(NTSTATUS) WaitForTC(         \
802         ULONG Timeout)
803 
804 #undef INTERFACE
805 #define INTERFACE IDmaChannelSlave
806 
807 #if (NTDDI_VERSION < NTDDI_LONGHORN)
808 DEFINE_GUID(IID_IDmaChannelSlave, 0x22C6AC62L, 0x851B, 0x11D0, 0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE);
809 #endif
810 
811 #undef INTERFACE
812 #define INTERFACE IDmaChannelSlave
813 
814 DECLARE_INTERFACE_(IDmaChannelSlave, IDmaChannel)
815 {
816     DEFINE_ABSTRACT_UNKNOWN()
817     DEFINE_ABSTRACT_DMACHANNEL()
818     DEFINE_ABSTRACT_DMACHANNELSLAVE()
819 };
820 
821 typedef IDmaChannelSlave *PDMACHANNELSLAVE;
822 
823 
824 /* ===============================================================
825     IInterruptSync Interface
826 */
827 
828 typedef enum
829 {
830     InterruptSyncModeNormal = 1,
831     InterruptSyncModeAll,
832     InterruptSyncModeRepeat
833 } INTERRUPTSYNCMODE;
834 
835 struct IInterruptSync;
836 
837 typedef NTSTATUS (NTAPI *PINTERRUPTSYNCROUTINE)(
838     IN  struct IInterruptSync* InterruptSync,
839     IN  PVOID DynamicContext);
840 
841 #undef INTERFACE
842 #define INTERFACE IInterruptSync
843 
844 DECLARE_INTERFACE_(IInterruptSync, IUnknown)
845 {
846     DEFINE_ABSTRACT_UNKNOWN()
847 
848     STDMETHOD_(NTSTATUS, CallSynchronizedRoutine)( THIS_
849         IN  PINTERRUPTSYNCROUTINE Routine,
850         IN  PVOID DynamicContext) PURE;
851 
852     STDMETHOD_(PKINTERRUPT, GetKInterrupt)( THIS ) PURE;
853     STDMETHOD_(NTSTATUS, Connect)( THIS ) PURE;
854     STDMETHOD_(void, Disconnect)( THIS ) PURE;
855 
856     STDMETHOD_(NTSTATUS, RegisterServiceRoutine)( THIS_
857         IN  PINTERRUPTSYNCROUTINE Routine,
858         IN  PVOID DynamicContext,
859         IN  BOOLEAN First) PURE;
860 };
861 
862 DEFINE_GUID(IID_IInterruptSync, 0x22C6AC63L, 0x851B, 0x11D0, 0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE);
863 
864 #define IMP_IInterruptSync                           \
865     STDMETHODIMP_(NTSTATUS) CallSynchronizedRoutine( \
866         IN  PINTERRUPTSYNCROUTINE Routine,           \
867         IN  PVOID DynamicContext);                   \
868                                                      \
869     STDMETHODIMP_(PKINTERRUPT) GetKInterrupt(void);  \
870     STDMETHODIMP_(NTSTATUS) Connect(void);           \
871     STDMETHODIMP_(void) Disconnect(void);            \
872                                                      \
873     STDMETHODIMP_(NTSTATUS) RegisterServiceRoutine(  \
874         IN  PINTERRUPTSYNCROUTINE Routine,           \
875         IN  PVOID DynamicContext,                    \
876         IN  BOOLEAN First)
877 
878 typedef IInterruptSync *PINTERRUPTSYNC;
879 
880 
881 /* ===============================================================
882     IRegistryKey Interface
883 */
884 
885 #undef INTERFACE
886 #define INTERFACE IRegistryKey
887 
888 enum
889 {
890     GeneralRegistryKey,
891     DeviceRegistryKey,
892     DriverRegistryKey,
893     HwProfileRegistryKey,
894     DeviceInterfaceRegistryKey
895 };
896 
897 DEFINE_GUID(IID_IRegistryKey, 0xE8DA4302l, 0xF304, 0x11D0, 0x95, 0x8B, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3);
898 
899 DECLARE_INTERFACE_(IRegistryKey, IUnknown)
900 {
901     DEFINE_ABSTRACT_UNKNOWN()
902 
903     STDMETHOD_(NTSTATUS, QueryKey)( THIS_
904         IN  KEY_INFORMATION_CLASS KeyInformationClass,
905         OUT PVOID KeyInformation,
906         IN  ULONG Length,
907         OUT PULONG ResultLength) PURE;
908 
909     STDMETHOD_(NTSTATUS, EnumerateKey)( THIS_
910         IN  ULONG Index,
911         IN  KEY_INFORMATION_CLASS KeyInformationClass,
912         OUT PVOID KeyInformation,
913         IN  ULONG Length,
914         OUT PULONG ResultLength) PURE;
915 
916     STDMETHOD_(NTSTATUS, QueryValueKey)( THIS_
917         IN  PUNICODE_STRING ValueName,
918         IN  KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
919         OUT PVOID KeyValueInformation,
920         IN  ULONG Length,
921         OUT PULONG ResultLength) PURE;
922 
923     STDMETHOD_(NTSTATUS, EnumerateValueKey)( THIS_
924         IN  ULONG Index,
925         IN  KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
926         OUT PVOID KeyValueInformation,
927         IN  ULONG Length,
928         OUT PULONG ResultLength) PURE;
929 
930     STDMETHOD_(NTSTATUS, SetValueKey)( THIS_
931         IN  PUNICODE_STRING ValueName OPTIONAL,
932         IN  ULONG Type,
933         IN  PVOID Data,
934         IN  ULONG DataSize) PURE;
935 
936     STDMETHOD_(NTSTATUS, QueryRegistryValues)( THIS_
937         IN  PRTL_QUERY_REGISTRY_TABLE QueryTable,
938         IN  PVOID Context OPTIONAL) PURE;
939 
940     STDMETHOD_(NTSTATUS, NewSubKey)( THIS_
941         OUT IRegistryKey** RegistrySubKey,
942         IN  PUNKNOWN OuterUnknown,
943         IN  ACCESS_MASK DesiredAccess,
944         IN  PUNICODE_STRING SubKeyName,
945         IN  ULONG CreateOptions,
946         OUT PULONG Disposition OPTIONAL) PURE;
947 
948     STDMETHOD_(NTSTATUS, DeleteKey)( THIS ) PURE;
949 };
950 
951 #define IMP_IRegistryKey \
952     STDMETHODIMP_(NTSTATUS) QueryKey( \
953         IN  KEY_INFORMATION_CLASS KeyInformationClass, \
954         OUT PVOID KeyInformation, \
955         IN  ULONG Length, \
956         OUT PULONG ResultLength); \
957 \
958     STDMETHODIMP_(NTSTATUS) EnumerateKey( \
959         IN  ULONG Index, \
960         IN  KEY_INFORMATION_CLASS KeyInformationClass, \
961         OUT PVOID KeyInformation, \
962         IN  ULONG Length, \
963         OUT PULONG ResultLength); \
964 \
965     STDMETHODIMP_(NTSTATUS) QueryValueKey( \
966         IN  PUNICODE_STRING ValueName, \
967         IN  KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, \
968         OUT PVOID KeyValueInformation, \
969         IN  ULONG Length, \
970         OUT PULONG ResultLength); \
971 \
972     STDMETHODIMP_(NTSTATUS) EnumerateValueKey( \
973         IN  ULONG Index, \
974         IN  KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, \
975         OUT PVOID KeyValueInformation, \
976         IN  ULONG Length, \
977         OUT PULONG ResultLength); \
978 \
979     STDMETHODIMP_(NTSTATUS) SetValueKey( \
980         IN  PUNICODE_STRING ValueName OPTIONAL, \
981         IN  ULONG Type, \
982         IN  PVOID Data, \
983         IN  ULONG DataSize); \
984 \
985     STDMETHODIMP_(NTSTATUS) QueryRegistryValues( \
986         IN  PRTL_QUERY_REGISTRY_TABLE QueryTable, \
987         IN  PVOID Context OPTIONAL); \
988 \
989     STDMETHODIMP_(NTSTATUS) NewSubKey( \
990         OUT IRegistryKey** RegistrySubKey, \
991         IN  PUNKNOWN OuterUnknown, \
992         IN  ACCESS_MASK DesiredAccess, \
993         IN  PUNICODE_STRING SubKeyName, \
994         IN  ULONG CreateOptions, \
995         OUT PULONG Disposition OPTIONAL); \
996 \
997     STDMETHODIMP_(NTSTATUS) DeleteKey(void);
998 
999 typedef IRegistryKey *PREGISTRYKEY;
1000 
1001 
1002 /* ===============================================================
1003     IMusicTechnology Interface
1004 */
1005 
1006 DECLARE_INTERFACE_(IMusicTechnology, IUnknown)
1007 {
1008     DEFINE_ABSTRACT_UNKNOWN()
1009 
1010     STDMETHOD_(NTSTATUS, SetTechnology)( THIS_
1011         IN  const GUID* Technology) PURE;
1012 };
1013 
1014 #define IMP_IMusicTechnology \
1015     STDMETHODIMP_(NTSTATUS) SetTechnology( \
1016         IN  const GUID* Technology);
1017 
1018 typedef IMusicTechnology *PMUSICTECHNOLOGY;
1019 
1020 
1021 /* ===============================================================
1022     IPort Interface
1023 */
1024 
1025 #if 0
1026 #define STATIC_IPort 0xb4c90a25L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44
1027 DEFINE_GUIDSTRUCT("0xB4C90A25-5791-11d0-86f9-00a0c911b544", IID_IPort);
1028 #define IID_IPort DEFINE_GUIDNAMED(IID_IPort)
1029 #endif
1030 
1031 DEFINE_GUID(IID_IMiniport,
1032     0xb4c90a24L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1033 
1034 DEFINE_GUID(IID_IPort,
1035     0xb4c90a25L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1036 
1037 #define DEFINE_ABSTRACT_PORT() \
1038     STDMETHOD_(NTSTATUS, Init)( THIS_ \
1039         IN  PDEVICE_OBJECT DeviceObject, \
1040         IN  PIRP Irp, \
1041         IN  PUNKNOWN UnknownMiniport, \
1042         IN  PUNKNOWN UnknownAdapter OPTIONAL, \
1043         IN  PRESOURCELIST ResourceList) PURE; \
1044 \
1045     STDMETHOD_(NTSTATUS, GetDeviceProperty)( THIS_ \
1046         IN  DEVICE_REGISTRY_PROPERTY DeviceProperty, \
1047         IN  ULONG BufferLength, \
1048         OUT PVOID PropertyBuffer, \
1049         OUT PULONG ResultLength) PURE; \
1050 \
1051     STDMETHOD_(NTSTATUS, NewRegistryKey)( THIS_ \
1052         OUT PREGISTRYKEY* OutRegistryKey, \
1053         IN  PUNKNOWN OuterUnknown OPTIONAL, \
1054         IN  ULONG RegistryKeyType, \
1055         IN  ACCESS_MASK DesiredAccess, \
1056         IN  POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, \
1057         IN  ULONG CreateOptiona OPTIONAL, \
1058         OUT PULONG Disposition OPTIONAL) PURE;
1059 
1060 #ifdef PC_IMPLEMENTATION
1061 #define IMP_IPort\
1062     STDMETHODIMP_(NTSTATUS) Init\
1063     (   IN      PDEVICE_OBJECT  DeviceObject,\
1064         IN      PIRP            Irp,\
1065         IN      PUNKNOWN        UnknownMiniport,\
1066         IN      PUNKNOWN        UnknownAdapter      OPTIONAL,\
1067         IN      PRESOURCELIST   ResourceList\
1068     );\
1069     STDMETHODIMP_(NTSTATUS) GetDeviceProperty\
1070     (   IN      DEVICE_REGISTRY_PROPERTY    DeviceProperty,\
1071         IN      ULONG                       BufferLength,\
1072         OUT     PVOID                       PropertyBuffer,\
1073         OUT     PULONG                      ResultLength\
1074     );\
1075     STDMETHODIMP_(NTSTATUS) NewRegistryKey\
1076     (   OUT     PREGISTRYKEY *      OutRegistryKey,\
1077         IN      PUNKNOWN            OuterUnknown        OPTIONAL,\
1078         IN      ULONG               RegistryKeyType,\
1079         IN      ACCESS_MASK         DesiredAccess,\
1080         IN      POBJECT_ATTRIBUTES  ObjectAttributes    OPTIONAL,\
1081         IN      ULONG               CreateOptions       OPTIONAL,\
1082         OUT     PULONG              Disposition         OPTIONAL\
1083     )
1084 #endif
1085 
1086 #undef INTERFACE
1087 #define INTERFACE IPort
1088 
1089 DECLARE_INTERFACE_(IPort, IUnknown)
1090 {
1091     DEFINE_ABSTRACT_UNKNOWN()
1092     DEFINE_ABSTRACT_PORT()
1093 };
1094 
1095 typedef IPort *PPORT;
1096 
1097 
1098 /* ===============================================================
1099     IPortMidi Interface
1100 */
1101 
1102 DEFINE_GUID(IID_IPortMidi,
1103     0xb4c90a40L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1104 DEFINE_GUID(CLSID_PortMidi,
1105     0xb4c90a43L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1106 
1107 #undef INTERFACE
1108 #define INTERFACE IPortMidi
1109 
1110 DECLARE_INTERFACE_(IPortMidi, IPort)
1111 {
1112     DEFINE_ABSTRACT_UNKNOWN()
1113     DEFINE_ABSTRACT_PORT()
1114 
1115     STDMETHOD_(VOID, Notify)(THIS_
1116         IN  PSERVICEGROUP ServiceGroup OPTIONAL) PURE;
1117 
1118     STDMETHOD_(NTSTATUS, RegisterServiceGroup)(THIS_
1119         IN  PSERVICEGROUP ServiceGroup) PURE;
1120 };
1121 
1122 typedef IPortMidi *PPORTMIDI;
1123 
1124 #define IMP_IPortMidi() \
1125     STDMETHODIMP_(VOID) Notify( \
1126         IN  PSERVICEGROUP ServiceGroup OPTIONAL); \
1127 \
1128     STDMETHODIMP_(NTSTATUS) RegisterServiceGroup( \
1129         IN  PSERVICEGROUP ServiceGroup);
1130 
1131 #undef INTERFACE
1132 
1133 /* ===============================================================
1134     IPortWaveCyclic Interface
1135 */
1136 
1137 DEFINE_GUID(IID_IPortWaveCyclic,
1138     0xb4c90a26L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1139 DEFINE_GUID(CLSID_PortWaveCyclic,
1140     0xb4c90a2aL, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1141 
1142 #define INTERFACE IPortWaveCyclic
1143 
1144 DECLARE_INTERFACE_(IPortWaveCyclic, IPort)
1145 {
1146     DEFINE_ABSTRACT_UNKNOWN()
1147 
1148     DEFINE_ABSTRACT_PORT()
1149 
1150     STDMETHOD_(VOID, Notify)(THIS_
1151         IN  PSERVICEGROUP ServiceGroup) PURE;
1152 
1153     STDMETHOD_(NTSTATUS, NewSlaveDmaChannel)(THIS_
1154         OUT PDMACHANNELSLAVE* DmaChannel,
1155         IN  PUNKNOWN OuterUnknown,
1156         IN  PRESOURCELIST ResourceList OPTIONAL,
1157         IN  ULONG DmaIndex,
1158         IN  ULONG MaximumLength,
1159         IN  BOOLEAN DemandMode,
1160         IN  DMA_SPEED DmaSpeed) PURE;
1161 
1162     STDMETHOD_(NTSTATUS, NewMasterDmaChannel)(THIS_
1163         OUT PDMACHANNEL* DmaChannel,
1164         IN  PUNKNOWN OuterUnknown,
1165         IN  PRESOURCELIST ResourceList OPTIONAL,
1166         IN  ULONG MaximumLength,
1167         IN  BOOLEAN Dma32BitAddresses,
1168         IN  BOOLEAN Dma64BitAddresses,
1169         IN  DMA_WIDTH DmaWidth,
1170         IN  DMA_SPEED DmaSpeed) PURE;
1171 
1172 };
1173 
1174 typedef IPortWaveCyclic *PPORTWAVECYCLIC;
1175 
1176 #ifdef PC_IMPLEMENTATION
1177 #define IMP_IPortWaveCyclic                           \
1178     IMP_IPort;                                        \
1179     STDMETHODIMP_(VOID) Notify(                       \
1180         IN  PSERVICEGROUP ServiceGroup);              \
1181                                                       \
1182     STDMETHODIMP_(NTSTATUS) NewSlaveDmaChannel(       \
1183         OUT PDMACHANNELSLAVE* DmaChannel,             \
1184         IN  PUNKNOWN OuterUnknown,                    \
1185         IN  PRESOURCELIST ResourceList OPTIONAL,      \
1186         IN  ULONG DmaIndex,                           \
1187         IN  ULONG MaximumLength,                      \
1188         IN  BOOLEAN DemandMode,                       \
1189         IN  DMA_SPEED DmaSpeed);                      \
1190                                                       \
1191     STDMETHODIMP_(NTSTATUS) NewMasterDmaChannel(      \
1192         OUT PDMACHANNEL* DmaChannel,                  \
1193         IN  PUNKNOWN OuterUnknown,                    \
1194         IN  PRESOURCELIST ResourceList OPTIONAL,      \
1195         IN  ULONG MaximumLength,                      \
1196         IN  BOOLEAN Dma32BitAddresses,                \
1197         IN  BOOLEAN Dma64BitAddresses,                \
1198         IN  DMA_WIDTH DmaWidth,                       \
1199         IN  DMA_SPEED DmaSpeed)
1200 #endif
1201 
1202 
1203 #undef INTERFACE
1204 /* ===============================================================
1205     IPortWavePci Interface
1206 */
1207 #undef INTERFACE
1208 #define INTERFACE IPortWavePci
1209 
1210 DEFINE_GUID(IID_IPortWavePci,
1211     0xb4c90a50L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1212 DEFINE_GUID(CLSID_PortWavePci,
1213     0xb4c90a54L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1214 
1215 DECLARE_INTERFACE_(IPortWavePci, IPort)
1216 {
1217     DEFINE_ABSTRACT_UNKNOWN()
1218     DEFINE_ABSTRACT_PORT()
1219 
1220     STDMETHOD_(VOID, Notify)(THIS_
1221         IN  PSERVICEGROUP ServiceGroup) PURE;
1222 
1223     STDMETHOD_(NTSTATUS, NewMasterDmaChannel)(THIS_
1224         OUT PDMACHANNEL* DmaChannel,
1225         IN  PUNKNOWN OuterUnknown,
1226         IN  POOL_TYPE PoolType,
1227         IN  PRESOURCELIST ResourceList OPTIONAL,
1228         IN  BOOLEAN ScatterGather,
1229         IN  BOOLEAN Dma32BitAddresses,
1230         IN  BOOLEAN Dma64BitAddresses,
1231         IN  BOOLEAN IgnoreCount,
1232         IN  DMA_WIDTH DmaWidth,
1233         IN  DMA_SPEED DmaSpeed,
1234         IN  ULONG MaximumLength,
1235         IN  ULONG DmaPort) PURE;
1236 };
1237 
1238 typedef IPortWavePci *PPORTWAVEPCI;
1239 #undef INTERFACE
1240 
1241 #ifdef PC_IMPLEMENTATION
1242 #define IMP_IPortWavePci                                     \
1243     IMP_IPort;                                               \
1244     STDMETHODIMP_(VOID) Notify(                              \
1245         IN  PSERVICEGROUP ServiceGroup);                     \
1246                                                              \
1247     STDMETHODIMP_(NTSTATUS) NewMasterDmaChannel(             \
1248         OUT PDMACHANNEL* DmaChannel,                         \
1249         IN  PUNKNOWN OuterUnknown,                           \
1250         IN  POOL_TYPE PoolType,                              \
1251         IN  PRESOURCELIST ResourceList OPTIONAL,             \
1252         IN  BOOLEAN ScatterGather,                           \
1253         IN  BOOLEAN Dma32BitAddresses,                       \
1254         IN  BOOLEAN Dma64BitAddresses,                       \
1255         IN  BOOLEAN IgnoreCount,                             \
1256         IN  DMA_WIDTH DmaWidth,                              \
1257         IN  DMA_SPEED DmaSpeed,                              \
1258         IN  ULONG MaximumLength,                             \
1259         IN  ULONG DmaPort);
1260 #endif
1261 
1262 /* ===============================================================
1263     IMiniPort Interface
1264 */
1265 
1266 DEFINE_GUID(IID_IMiniPort,
1267     0xb4c90a24L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1268 
1269 #define DEFINE_ABSTRACT_MINIPORT() \
1270     STDMETHOD_(NTSTATUS, GetDescription)( THIS_ \
1271         OUT  PPCFILTER_DESCRIPTOR* Description) PURE; \
1272 \
1273     STDMETHOD_(NTSTATUS, DataRangeIntersection)( THIS_ \
1274         IN  ULONG PinId, \
1275         IN  PKSDATARANGE DataRange, \
1276         IN  PKSDATARANGE MatchingDataRange, \
1277         IN  ULONG OutputBufferLength, \
1278         OUT PVOID ResultantFormat OPTIONAL, \
1279         OUT PULONG ResultantFormatLength) PURE;
1280 
1281 #define IMP_IMiniport                                        \
1282     STDMETHODIMP_(NTSTATUS) GetDescription(                  \
1283         OUT  PPCFILTER_DESCRIPTOR* Description);             \
1284                                                              \
1285     STDMETHODIMP_(NTSTATUS) DataRangeIntersection(           \
1286         IN  ULONG PinId,                                     \
1287         IN  PKSDATARANGE DataRange,                          \
1288         IN  PKSDATARANGE MatchingDataRange,                  \
1289         IN  ULONG OutputBufferLength,                        \
1290         OUT PVOID ResultantFormat OPTIONAL,                  \
1291         OUT PULONG ResultantFormatLength)
1292 
1293 DECLARE_INTERFACE_(IMiniport, IUnknown)
1294 {
1295     DEFINE_ABSTRACT_UNKNOWN()
1296     DEFINE_ABSTRACT_MINIPORT()
1297 };
1298 
1299 typedef IMiniport *PMINIPORT;
1300 
1301 
1302 /* ===============================================================
1303     IMiniportMidiStream Interface
1304 */
1305 #undef INTERFACE
1306 #define INTERFACE IMiniportMidiStream
1307 
1308 DEFINE_GUID(IID_IMiniportMidiStream,
1309     0xb4c90a42L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1310 
1311 DECLARE_INTERFACE_(IMiniportMidiStream, IUnknown)
1312 {
1313     DEFINE_ABSTRACT_UNKNOWN()
1314 
1315     STDMETHOD_(NTSTATUS,SetFormat)(THIS_
1316         IN PKSDATAFORMAT DataFormat)PURE;
1317 
1318     STDMETHOD_(NTSTATUS,SetState)(THIS_
1319         IN KSSTATE State)PURE;
1320 
1321     STDMETHOD_(NTSTATUS,Read)(THIS_
1322         IN PVOID BufferAddress,
1323         IN ULONG BufferLength,
1324         OUT PULONG BytesRead)PURE;
1325 
1326     STDMETHOD_(NTSTATUS,Write)(THIS_
1327         IN PVOID BufferAddress,
1328         IN ULONG BytesToWrite,
1329         OUT PULONG BytesWritten)PURE;
1330 };
1331 
1332 typedef IMiniportMidiStream* PMINIPORTMIDISTREAM;
1333 #undef INTERFACE
1334 
1335 /* ===============================================================
1336     IMiniportMidi Interface
1337 */
1338 #undef INTERFACE
1339 #define INTERFACE IMiniportMidi
1340 
1341 DEFINE_GUID(IID_IMiniportMidi,
1342     0xb4c90a41L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1343 
1344 DECLARE_INTERFACE_(IMiniportMidi, IMiniport)
1345 {
1346     DEFINE_ABSTRACT_UNKNOWN()
1347     DEFINE_ABSTRACT_MINIPORT()
1348 
1349     STDMETHOD_(NTSTATUS, Init)(THIS_
1350     IN  PUNKNOWN UnknownAdapter,
1351     IN  PRESOURCELIST ResourceList,
1352     IN  PPORTMIDI Port,
1353     OUT PSERVICEGROUP* ServiceGroup) PURE;
1354 
1355     STDMETHOD_(void, Service)(THIS) PURE;
1356 
1357     STDMETHOD_(NTSTATUS, NewStream)(THIS_
1358         OUT PMINIPORTMIDISTREAM *Stream,
1359         IN  PUNKNOWN OuterUnknown OPTIONAL,
1360         IN  POOL_TYPE PoolType,
1361         IN  ULONG Pin,
1362         IN  BOOLEAN Capture,
1363         IN  PKSDATAFORMAT DataFormat,
1364         OUT PSERVICEGROUP* ServiceGroup) PURE;
1365 
1366 };
1367 
1368 typedef IMiniportMidi *PMINIPORTMIDI;
1369 #undef INTERFACE
1370 
1371 /* ===============================================================
1372     IMiniportDriverUart Interface
1373 */
1374 
1375 DEFINE_GUID(IID_MiniportDriverUart,
1376     0xb4c90ae1L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1377 DEFINE_GUID(CLSID_MiniportDriverUart,
1378     0xb4c90ae1L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1379 
1380 /* ===============================================================
1381     IPortTopology Interface
1382 */
1383 #if 0
1384 #define STATIC_IPortTopology \
1385     0xb4c90a30L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44
1386 DEFINE_GUIDSTRUCT("0xB4C90A30-5791-11d0-86f9-00a0c911b544", IID_IPortTopology);
1387 #define IID_IPortTopology DEFINE_GUIDNAMED(IID_IPortTopology)
1388 #endif
1389 
1390 #undef INTERFACE
1391 #define INTERFACE IPortTopology
1392 
1393 DEFINE_GUID(IID_IPortTopology, 0xb4c90a30L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1394 DEFINE_GUID(CLSID_PortTopology, 0xb4c90a32L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1395 
1396 #undef INTERFACE
1397 #define INTERFACE IPortTopology
1398 
1399 DECLARE_INTERFACE_(IPortTopology, IPort)
1400 {
1401     DEFINE_ABSTRACT_UNKNOWN()
1402     DEFINE_ABSTRACT_PORT()
1403 };
1404 
1405 typedef IPortTopology *PPORTTOPOLOGY;
1406 
1407 #define IMP_IPortTopology IMP_IPort
1408 
1409 
1410 /* ===============================================================
1411     IMiniportTopology Interface
1412 */
1413 
1414 #undef INTERFACE
1415 #define INTERFACE IMiniportTopology
1416 
1417 DEFINE_GUID(IID_IMiniportTopology, 0xb4c90a31L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1418 
1419 #undef INTERFACE
1420 #define INTERFACE IMiniportTopology
1421 
1422 DECLARE_INTERFACE_(IMiniportTopology,IMiniport)
1423 {
1424     DEFINE_ABSTRACT_UNKNOWN()
1425     DEFINE_ABSTRACT_MINIPORT()
1426 
1427     STDMETHOD_(NTSTATUS,Init)(THIS_
1428         IN PUNKNOWN UnknownAdapter,
1429         IN PRESOURCELIST ResourceList,
1430         IN PPORTTOPOLOGY Port)PURE;
1431 };
1432 
1433 typedef IMiniportTopology *PMINIPORTTOPOLOGY;
1434 
1435 /* ===============================================================
1436     IMiniportWaveCyclicStream Interface
1437 */
1438 
1439 #undef INTERFACE
1440 #define INTERFACE IMiniportWaveCyclicStream
1441 
1442 DEFINE_GUID(IID_IMiniportWaveCyclicStream,
1443 0xb4c90a28L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1444 
1445 DECLARE_INTERFACE_(IMiniportWaveCyclicStream,IUnknown)
1446 {
1447     DEFINE_ABSTRACT_UNKNOWN()
1448 
1449     STDMETHOD_(NTSTATUS,SetFormat)(THIS_
1450         IN PKSDATAFORMAT DataFormat)PURE;
1451 
1452     STDMETHOD_(ULONG,SetNotificationFreq)(THIS_
1453         IN ULONG Interval,
1454         OUT PULONG FrameSize) PURE;
1455 
1456     STDMETHOD_(NTSTATUS,SetState)(THIS_
1457         IN KSSTATE State) PURE;
1458 
1459     STDMETHOD_(NTSTATUS,GetPosition)( THIS_
1460         OUT PULONG Position) PURE;
1461 
1462     STDMETHOD_(NTSTATUS,NormalizePhysicalPosition)(THIS_
1463         IN OUT PLONGLONG PhysicalPosition) PURE;
1464 
1465     STDMETHOD_(void, Silence)( THIS_
1466         IN PVOID Buffer,
1467         IN ULONG ByteCount) PURE;
1468 };
1469 
1470 typedef IMiniportWaveCyclicStream *PMINIPORTWAVECYCLICSTREAM;
1471 
1472 #define IMP_IMiniportWaveCyclicStream\
1473     STDMETHODIMP_(NTSTATUS) SetFormat\
1474     (   IN      PKSDATAFORMAT   DataFormat\
1475     );\
1476     STDMETHODIMP_(ULONG) SetNotificationFreq\
1477     (   IN      ULONG           Interval,\
1478         OUT     PULONG          FrameSize\
1479     );\
1480     STDMETHODIMP_(NTSTATUS) SetState\
1481     (   IN      KSSTATE         State\
1482     );\
1483     STDMETHODIMP_(NTSTATUS) GetPosition\
1484     (   OUT     PULONG          Position\
1485     );\
1486     STDMETHODIMP_(NTSTATUS) NormalizePhysicalPosition\
1487     (   IN OUT PLONGLONG        PhysicalPosition\
1488     );\
1489     STDMETHODIMP_(void) Silence\
1490     (   IN      PVOID           Buffer,\
1491         IN      ULONG           ByteCount\
1492     )
1493 
1494 
1495 /* ===============================================================
1496     IMiniportWaveCyclic Interface
1497 */
1498 #undef INTERFACE
1499 
1500 DEFINE_GUID(IID_IMiniportWaveCyclic,
1501     0xb4c90a27L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1502 
1503 #define INTERFACE IMiniportWaveCyclic
1504 
1505 DECLARE_INTERFACE_(IMiniportWaveCyclic, IMiniport)
1506 {
1507     DEFINE_ABSTRACT_UNKNOWN()
1508     DEFINE_ABSTRACT_MINIPORT()
1509 
1510     STDMETHOD_(NTSTATUS, Init)(THIS_
1511         IN PUNKNOWN  UnknownAdapter,
1512         IN PRESOURCELIST  ResourceList,
1513         IN PPORTWAVECYCLIC  Port) PURE;
1514 
1515     STDMETHOD_(NTSTATUS, NewStream)(THIS_
1516         OUT PMINIPORTWAVECYCLICSTREAM  *Stream,
1517         IN PUNKNOWN  OuterUnknown  OPTIONAL,
1518         IN POOL_TYPE  PoolType,
1519         IN ULONG  Pin,
1520         IN BOOLEAN  Capture,
1521         IN PKSDATAFORMAT  DataFormat,
1522         OUT PDMACHANNEL  *DmaChannel,
1523         OUT PSERVICEGROUP  *ServiceGroup) PURE;
1524 };
1525 
1526 typedef IMiniportWaveCyclic *PMINIPORTWAVECYCLIC;
1527 #undef INTERFACE
1528 
1529 #define IMP_IMiniportWaveCyclic\
1530     IMP_IMiniport;\
1531     STDMETHODIMP_(NTSTATUS) Init\
1532     (   IN      PUNKNOWN        UnknownAdapter,\
1533         IN      PRESOURCELIST   ResourceList,\
1534         IN      PPORTWAVECYCLIC Port\
1535     );\
1536     STDMETHODIMP_(NTSTATUS) NewStream\
1537     (   OUT     PMINIPORTWAVECYCLICSTREAM * Stream,\
1538         IN      PUNKNOWN                    OuterUnknown    OPTIONAL,\
1539         IN      POOL_TYPE                   PoolType,\
1540         IN      ULONG                       Pin,\
1541         IN      BOOLEAN                     Capture,\
1542         IN      PKSDATAFORMAT               DataFormat,\
1543         OUT     PDMACHANNEL *               DmaChannel,\
1544         OUT     PSERVICEGROUP *             ServiceGroup\
1545     )
1546 
1547 
1548 /* ===============================================================
1549     IPortWavePciStream Interface
1550 */
1551 #undef INTERFACE
1552 #define INTERFACE IPortWavePciStream
1553 
1554 DEFINE_GUID(IID_IPortWavePciStream, 0xb4c90a51L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1555 
1556 DECLARE_INTERFACE_(IPortWavePciStream,IUnknown)
1557 {
1558     DEFINE_ABSTRACT_UNKNOWN()   //  For IUnknown
1559 
1560     STDMETHOD_(NTSTATUS,GetMapping)(THIS_
1561         IN PVOID Tag,
1562         OUT PPHYSICAL_ADDRESS PhysicalAddress,
1563         OUT PVOID * VirtualAddress,
1564         OUT PULONG ByteCount,
1565         OUT PULONG Flags)PURE;
1566 
1567     STDMETHOD_(NTSTATUS,ReleaseMapping)(THIS_
1568         IN PVOID Tag)PURE;
1569 
1570     STDMETHOD_(NTSTATUS,TerminatePacket)(THIS)PURE;
1571 };
1572 
1573 typedef IPortWavePciStream *PPORTWAVEPCISTREAM;
1574 
1575 #define IMP_IPortWavePciStream                             \
1576     STDMETHODIMP_(NTSTATUS) GetMapping(                    \
1577         IN PVOID Tag,                                      \
1578         OUT PPHYSICAL_ADDRESS PhysicalAddress,             \
1579         OUT PVOID * VirtualAddress,                        \
1580         OUT PULONG ByteCount,                              \
1581         OUT PULONG Flags);                                 \
1582                                                            \
1583     STDMETHODIMP_(NTSTATUS) ReleaseMapping(                \
1584         IN PVOID Tag);                                     \
1585                                                            \
1586     STDMETHODIMP_(NTSTATUS) TerminatePacket(THIS)
1587 
1588 
1589 /* ===============================================================
1590     IMiniportWavePciStream Interface
1591 */
1592 #undef INTERFACE
1593 #define INTERFACE IMiniportWavePciStream
1594 
1595 DEFINE_GUID(IID_IMiniportWavePciStream, 0xb4c90a53L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1596 
1597 DECLARE_INTERFACE_(IMiniportWavePciStream,IUnknown)
1598 {
1599     DEFINE_ABSTRACT_UNKNOWN()
1600 
1601     STDMETHOD_(NTSTATUS,SetFormat)(THIS_
1602         IN PKSDATAFORMAT DataFormat)PURE;
1603 
1604     STDMETHOD_(NTSTATUS,SetState)(THIS_
1605         IN KSSTATE State)PURE;
1606 
1607     STDMETHOD_(NTSTATUS,GetPosition)(THIS_
1608         OUT PULONGLONG Position)PURE;
1609 
1610     STDMETHOD_(NTSTATUS,NormalizePhysicalPosition)(THIS_
1611         IN OUT PLONGLONG PhysicalPosition)PURE;
1612 
1613     STDMETHOD_(NTSTATUS,GetAllocatorFraming)(THIS_
1614         OUT PKSALLOCATOR_FRAMING AllocatorFraming) PURE;
1615 
1616     STDMETHOD_(NTSTATUS,RevokeMappings)(THIS_
1617         IN PVOID FirstTag,
1618         IN PVOID LastTag,
1619         OUT PULONG MappingsRevoked)PURE;
1620 
1621     STDMETHOD_(void,MappingAvailable)(THIS)PURE;
1622 
1623     STDMETHOD_(void,Service)(THIS)PURE;
1624 };
1625 
1626 typedef IMiniportWavePciStream *PMINIPORTWAVEPCISTREAM;
1627 
1628 /* ===============================================================
1629     IMiniportWavePci Interface
1630 */
1631 #undef INTERFACE
1632 #define INTERFACE IMiniportWavePci
1633 
1634 DEFINE_GUID(IID_IMiniportWavePci, 0xb4c90a52L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
1635 
1636 DECLARE_INTERFACE_(IMiniportWavePci,IMiniport)
1637 {
1638     DEFINE_ABSTRACT_UNKNOWN()
1639 
1640     DEFINE_ABSTRACT_MINIPORT()
1641 
1642     STDMETHOD_(NTSTATUS,Init)(THIS_
1643         IN PUNKNOWN UnknownAdapter,
1644         IN PRESOURCELIST ResourceList,
1645         IN PPORTWAVEPCI Port,
1646         OUT PSERVICEGROUP * ServiceGroup)PURE;
1647 
1648     STDMETHOD_(NTSTATUS,NewStream)(THIS_
1649         OUT PMINIPORTWAVEPCISTREAM *    Stream,
1650         IN PUNKNOWN OuterUnknown    OPTIONAL,
1651         IN POOL_TYPE PoolType,
1652         IN PPORTWAVEPCISTREAM PortStream,
1653         IN ULONG Pin,
1654         IN BOOLEAN Capture,
1655         IN PKSDATAFORMAT DataFormat,
1656         OUT PDMACHANNEL * DmaChannel,
1657         OUT PSERVICEGROUP * ServiceGroup)PURE;
1658 
1659     STDMETHOD_(void,Service)(THIS)PURE;
1660 };
1661 
1662 typedef IMiniportWavePci *PMINIPORTWAVEPCI;
1663 
1664 
1665 #if !defined(DEFINE_ABSTRACT_MINIPORTWAVERTSTREAM)
1666 
1667 #define DEFINE_ABSTRACT_MINIPORTWAVERTSTREAM()                 \
1668     STDMETHOD_(NTSTATUS,SetFormat)                             \
1669     (   THIS_                                                  \
1670         IN      PKSDATAFORMAT   DataFormat                   \
1671     )   PURE;                                                  \
1672     STDMETHOD_(NTSTATUS,SetState)                              \
1673     (   THIS_                                                  \
1674         IN      KSSTATE         State                        \
1675     )   PURE;                                                  \
1676     STDMETHOD_(NTSTATUS,GetPosition)                           \
1677     (   THIS_                                                  \
1678         OUT     PKSAUDIO_POSITION   Position                 \
1679     )   PURE;                                                  \
1680     STDMETHOD_(NTSTATUS,AllocateAudioBuffer)                   \
1681     (   THIS_                                                  \
1682         IN  ULONG                   RequestedSize,           \
1683         OUT PMDL                    *AudioBufferMdl,         \
1684         OUT ULONG                   *ActualSize,             \
1685         OUT ULONG                   *OffsetFromFirstPage,    \
1686         OUT MEMORY_CACHING_TYPE     *CacheType               \
1687     ) PURE;                                                    \
1688     STDMETHOD_(VOID,FreeAudioBuffer)                           \
1689     (   THIS_                                                  \
1690         IN     PMDL                    AudioBufferMdl,          \
1691         IN     ULONG                   BufferSize               \
1692     ) PURE;                                                    \
1693     STDMETHOD_(VOID,GetHWLatency)                              \
1694     (   THIS_                                                  \
1695         OUT KSRTAUDIO_HWLATENCY     *hwLatency               \
1696     ) PURE;                                                    \
1697     STDMETHOD_(NTSTATUS,GetPositionRegister)                   \
1698     (   THIS_                                                  \
1699         OUT KSRTAUDIO_HWREGISTER    *Register                \
1700     ) PURE;                                                    \
1701     STDMETHOD_(NTSTATUS,GetClockRegister)                      \
1702     (   THIS_                                                  \
1703         OUT KSRTAUDIO_HWREGISTER    *Register                \
1704     ) PURE;
1705 
1706 #endif
1707 
1708 
1709 /* ===============================================================
1710     IAdapterPowerManagement Interface
1711 */
1712 
1713 #if (NTDDI_VERSION >= NTDDI_VISTA)
1714 /* ===============================================================
1715     IPortWaveRT Interface
1716 */
1717 
1718 DEFINE_GUID(CLSID_PortWaveRT, 0xcc9be57a, 0xeb9e, 0x42b4, 0x94, 0xfc, 0xc, 0xad, 0x3d, 0xbc, 0xe7, 0xfa);
1719 DEFINE_GUID(IID_IPortWaveRT, 0x339ff909, 0x68a9, 0x4310, 0xb0, 0x9b, 0x27, 0x4e, 0x96, 0xee, 0x4c, 0xbd);
1720 
1721 #undef INTERFACE
1722 #define INTERFACE IPortWaveRT
1723 
1724 DECLARE_INTERFACE_(IPortWaveRT,IPort)
1725 {
1726     DEFINE_ABSTRACT_UNKNOWN()   //  For IUnknown
1727 
1728     DEFINE_ABSTRACT_PORT()      //  For IPort
1729 };
1730 
1731 typedef IPortWaveRT *PPORTWAVERT;
1732 
1733 #ifdef PC_IMPLEMENTATION
1734 #define IMP_IPortWaveRT IMP_IPort
1735 #endif
1736 
1737 
1738 /* ===============================================================
1739     IPortWaveRTStream Interface
1740 */
1741 
1742 #undef INTERFACE
1743 #define INTERFACE IPortWaveRTStream
1744 
1745 DEFINE_GUID(IID_IPortWaveRTStream, 0x1809ce5a, 0x64bc, 0x4e62, 0xbd, 0x7d, 0x95, 0xbc, 0xe4, 0x3d, 0xe3, 0x93);
1746 
1747 DECLARE_INTERFACE_(IPortWaveRTStream, IUnknown)
1748 {
1749     DEFINE_ABSTRACT_UNKNOWN()
1750 
1751     STDMETHOD_(PMDL, AllocatePagesForMdl)
1752     (   THIS_
1753         IN      PHYSICAL_ADDRESS    HighAddress,
1754         IN      SIZE_T              TotalBytes
1755     )   PURE;
1756 
1757     STDMETHOD_(PMDL, AllocateContiguousPagesForMdl)
1758     (   THIS_
1759         IN      PHYSICAL_ADDRESS    LowAddress,
1760         IN      PHYSICAL_ADDRESS    HighAddress,
1761         IN      SIZE_T              TotalBytes
1762     )   PURE;
1763 
1764     STDMETHOD_(PVOID, MapAllocatedPages)
1765     (   THIS_
1766         IN      PMDL                    MemoryDescriptorList,
1767         IN      MEMORY_CACHING_TYPE     CacheType
1768     )   PURE;
1769 
1770     STDMETHOD_(VOID, UnmapAllocatedPages)
1771     (   THIS_
1772         IN      PVOID   BaseAddress,
1773         IN      PMDL    MemoryDescriptorList
1774     )   PURE;
1775 
1776     STDMETHOD_(VOID, FreePagesFromMdl)
1777     (   THIS_
1778         IN      PMDL    MemoryDescriptorList
1779     )   PURE;
1780 
1781     STDMETHOD_(ULONG, GetPhysicalPagesCount)
1782     (   THIS_
1783         IN      PMDL    MemoryDescriptorList
1784     )   PURE;
1785 
1786     STDMETHOD_(PHYSICAL_ADDRESS, GetPhysicalPageAddress)
1787     (   THIS_
1788         IN      PMDL    MemoryDescriptorList,
1789         IN      ULONG   Index
1790     )   PURE;
1791 };
1792 
1793 typedef IPortWaveRTStream *PPORTWAVERTSTREAM;
1794 
1795 
1796 /* ===============================================================
1797     IMiniportWaveRTStream Interface
1798 */
1799 
1800 #undef INTERFACE
1801 #define INTERFACE IMiniportWaveRTStream
1802 
1803 DEFINE_GUID(IID_IMiniportWaveRTStream, 0xac9ab, 0xfaab, 0x4f3d, 0x94, 0x55, 0x6f, 0xf8, 0x30, 0x6a, 0x74, 0xa0);
1804 
1805 DECLARE_INTERFACE_(IMiniportWaveRTStream, IUnknown)
1806 {
1807     DEFINE_ABSTRACT_UNKNOWN()
1808     DEFINE_ABSTRACT_MINIPORTWAVERTSTREAM()
1809 };
1810 
1811 typedef IMiniportWaveRTStream *PMINIPORTWAVERTSTREAM;
1812 
1813 #define IMP_IMiniportWaveRTStream\
1814     STDMETHODIMP_(NTSTATUS) SetFormat\
1815     (   IN      PKSDATAFORMAT   DataFormat\
1816     );\
1817     STDMETHODIMP_(NTSTATUS) SetState\
1818     (   IN      KSSTATE         State\
1819     );\
1820     STDMETHODIMP_(NTSTATUS) GetPosition\
1821     (   OUT     PKSAUDIO_POSITION   Position\
1822     );\
1823     STDMETHODIMP_(NTSTATUS) AllocateAudioBuffer\
1824     (\
1825         IN      ULONG                   RequestedSize,\
1826         OUT     PMDL                    *AudioBufferMdl,\
1827         OUT     ULONG                   *ActualSize,\
1828         OUT     ULONG                   *OffsetFromFirstPage,\
1829         OUT     MEMORY_CACHING_TYPE     *CacheType\
1830     );\
1831     STDMETHODIMP_(VOID) FreeAudioBuffer\
1832     (\
1833         IN  PMDL                    AudioBufferMdl,\
1834         IN  ULONG                   BufferSize\
1835     );\
1836     STDMETHODIMP_(VOID) GetHWLatency\
1837     (\
1838         OUT KSRTAUDIO_HWLATENCY     *hwLatency\
1839     );\
1840     STDMETHODIMP_(NTSTATUS) GetPositionRegister\
1841     (\
1842         OUT KSRTAUDIO_HWREGISTER    *Register\
1843     );\
1844     STDMETHODIMP_(NTSTATUS) GetClockRegister\
1845     (\
1846         OUT KSRTAUDIO_HWREGISTER    *Register\
1847     )
1848 
1849 
1850 /* ===============================================================
1851     IMiniportWaveRTStreamNotification Interface
1852 */
1853 
1854 #undef INTERFACE
1855 #define INTERFACE IMiniportWaveRTStreamNotification
1856 
1857 DEFINE_GUID(IID_IMiniportWaveRTStreamNotification, 0x23759128, 0x96f1, 0x423b, 0xab, 0x4d, 0x81, 0x63, 0x5b, 0xcf, 0x8c, 0xa1);
1858 
1859 DECLARE_INTERFACE_(IMiniportWaveRTStreamNotification, IMiniportWaveRTStream)
1860 {
1861     DEFINE_ABSTRACT_UNKNOWN()
1862 
1863     DEFINE_ABSTRACT_MINIPORTWAVERTSTREAM()
1864 
1865     STDMETHOD_(NTSTATUS,AllocateBufferWithNotification)
1866     (   THIS_
1867         IN      ULONG                   NotificationCount,
1868         IN      ULONG                   RequestedSize,
1869         OUT     PMDL                    *AudioBufferMdl,
1870         OUT     ULONG                   *ActualSize,
1871         OUT     ULONG                   *OffsetFromFirstPage,
1872         OUT     MEMORY_CACHING_TYPE     *CacheType
1873     )   PURE;
1874 
1875     STDMETHOD_(VOID,FreeBufferWithNotification)
1876     (   THIS_
1877         IN      PMDL            AudioBufferMdl,
1878         IN      ULONG           BufferSize
1879     )   PURE;
1880 
1881     STDMETHOD_(NTSTATUS,RegisterNotificationEvent)
1882     (   THIS_
1883         IN      PKEVENT         NotificationEvent
1884     )   PURE;
1885 
1886     STDMETHOD_(NTSTATUS,UnregisterNotificationEvent)
1887     (   THIS_
1888         IN      PKEVENT         NotificationEvent
1889     )   PURE;
1890 };
1891 
1892 /* ===============================================================
1893     IMiniportWaveRT Interface
1894 */
1895 
1896 #undef INTERFACE
1897 #define INTERFACE IMiniportWaveRT
1898 
1899 DEFINE_GUID(IID_IMiniportWaveRT, 0xf9fc4d6, 0x6061, 0x4f3c, 0xb1, 0xfc, 0x7, 0x5e, 0x35, 0xf7, 0x96, 0xa);
1900 
1901 DECLARE_INTERFACE_(IMiniportWaveRT, IMiniport)
1902 {
1903     DEFINE_ABSTRACT_UNKNOWN()
1904 
1905     DEFINE_ABSTRACT_MINIPORT()
1906 
1907     STDMETHOD_(NTSTATUS,Init)
1908     (   THIS_
1909         IN      PUNKNOWN            UnknownAdapter,
1910         IN      PRESOURCELIST       ResourceList,
1911         IN      PPORTWAVERT             Port
1912     )   PURE;
1913 
1914     STDMETHOD_(NTSTATUS,NewStream)
1915     (   THIS_
1916         OUT     PMINIPORTWAVERTSTREAM *         Stream,
1917         IN      PPORTWAVERTSTREAM               PortStream,
1918         IN      ULONG                       Pin,
1919         IN      BOOLEAN                     Capture,
1920         IN      PKSDATAFORMAT               DataFormat
1921     )   PURE;
1922 
1923     STDMETHOD_(NTSTATUS,GetDeviceDescription)
1924     (   THIS_
1925         OUT     PDEVICE_DESCRIPTION     DeviceDescription
1926     )   PURE;
1927 };
1928 
1929 typedef IMiniportWaveRT *PMINIPORTWAVERT;
1930 
1931 #define IMP_IMiniportWaveRT\
1932     IMP_IMiniport;\
1933     STDMETHODIMP_(NTSTATUS) Init\
1934     (   IN      PUNKNOWN            UnknownAdapter,\
1935         IN      PRESOURCELIST       ResourceList,\
1936         IN      PPORTWAVERT             Port\
1937     );\
1938     STDMETHODIMP_(NTSTATUS) NewStream\
1939     (   OUT     PMINIPORTWAVERTSTREAM *         Stream,\
1940         IN      PPORTWAVERTSTREAM               PortStream,\
1941         IN      ULONG                       Pin,\
1942         IN      BOOLEAN                     Capture,\
1943         IN      PKSDATAFORMAT               DataFormat\
1944     );\
1945     STDMETHODIMP_(NTSTATUS) GetDeviceDescription\
1946     (   OUT     PDEVICE_DESCRIPTION     DeviceDescription\
1947     )
1948 
1949 #endif
1950 
1951 /* ===============================================================
1952     IAdapterPowerManagement Interface
1953 */
1954 
1955 #undef INTERFACE
1956 #define INTERFACE IAdapterPowerManagement
1957 
1958 DEFINE_GUID(IID_IAdapterPowerManagement, 0x793417D0L, 0x35FE, 0x11D1, 0xAD, 0x08, 0x00, 0xA0, 0xC9, 0x0A, 0xB1, 0xB0);
1959 
1960 DECLARE_INTERFACE_(IAdapterPowerManagement, IUnknown)
1961 {
1962     DEFINE_ABSTRACT_UNKNOWN()
1963 
1964     STDMETHOD_(void,PowerChangeState)(THIS_
1965         IN POWER_STATE NewState) PURE;
1966 
1967     STDMETHOD_(NTSTATUS,QueryPowerChangeState)(THIS_
1968         IN POWER_STATE NewStateQuery) PURE;
1969 
1970     STDMETHOD_(NTSTATUS,QueryDeviceCapabilities)(THIS_
1971         IN PDEVICE_CAPABILITIES PowerDeviceCaps) PURE;
1972 };
1973 
1974 #define IMP_IAdapterPowerManagement                       \
1975     STDMETHODIMP_(void) PowerChangeState                  \
1976     (   IN      POWER_STATE     NewState                  \
1977     );                                                    \
1978     STDMETHODIMP_(NTSTATUS) QueryPowerChangeState         \
1979     (   IN      POWER_STATE     NewStateQuery             \
1980     );                                                    \
1981     STDMETHODIMP_(NTSTATUS) QueryDeviceCapabilities       \
1982     (   IN      PDEVICE_CAPABILITIES    PowerDeviceCaps   \
1983     )
1984 
1985 typedef IAdapterPowerManagement *PADAPTERPOWERMANAGEMENT;
1986 
1987 
1988 /* ===============================================================
1989     IPowerNotify Interface
1990 */
1991 
1992 #undef INTERFACE
1993 #define INTERFACE IPowerNotify
1994 
1995 DEFINE_GUID(IID_IPowerNotify, 0x3DD648B8L, 0x969F, 0x11D1, 0x95, 0xA9, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3);
1996 
1997 DECLARE_INTERFACE_(IPowerNotify, IUnknown)
1998 {
1999     DEFINE_ABSTRACT_UNKNOWN()
2000 
2001     STDMETHOD_(void, PowerChangeNotify)(THIS_
2002         IN POWER_STATE PowerState)PURE;
2003 };
2004 
2005 typedef IPowerNotify *PPOWERNOTIFY;
2006 
2007 #define IMP_IPowerNotify\
2008     STDMETHODIMP_(void) PowerChangeNotify\
2009     (   IN  POWER_STATE     PowerState\
2010     )
2011 
2012 
2013 #undef INTERFACE
2014 
2015 /* ===============================================================
2016     IPinCount Interface
2017 */
2018 #if (NTDDI_VERSION >= NTDDI_WINXP)
2019 
2020 #undef INTERFACE
2021 #define INTERFACE IPinCount
2022 
2023 DEFINE_GUID(IID_IPinCount, 0x5dadb7dcL, 0xa2cb, 0x4540, 0xa4, 0xa8, 0x42, 0x5e, 0xe4, 0xae, 0x90, 0x51);
2024 
2025 DECLARE_INTERFACE_(IPinCount, IUnknown)
2026 {
2027     DEFINE_ABSTRACT_UNKNOWN()
2028 
2029     STDMETHOD_(void,PinCount)(THIS_
2030         IN ULONG PinId,
2031         IN OUT PULONG FilterNecessary,
2032         IN OUT PULONG FilterCurrent,
2033         IN OUT PULONG FilterPossible,
2034         IN OUT PULONG GlobalCurrent,
2035         IN OUT PULONG GlobalPossible) PURE;
2036 };
2037 typedef IPinCount *PPINCOUNT;
2038 
2039 #undef INTERFACE
2040 #endif
2041 
2042 
2043 /* ===============================================================
2044     IPortEvents Interface
2045 */
2046 
2047 #undef INTERFACE
2048 #define INTERFACE IPortEvents
2049 
2050 DEFINE_GUID(IID_IPortEvents, 0xA80F29C4L, 0x5498, 0x11D2, 0x95, 0xD9, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3);
2051 DECLARE_INTERFACE_(IPortEvents, IUnknown)
2052 {
2053     DEFINE_ABSTRACT_UNKNOWN()
2054 
2055     STDMETHOD_(void,AddEventToEventList)(THIS_
2056         IN  PKSEVENT_ENTRY EventEntry)PURE;
2057 
2058     STDMETHOD_(void,GenerateEventList)(THIS_
2059         IN  GUID* Set OPTIONAL,
2060         IN  ULONG EventId,
2061         IN  BOOL PinEvent,
2062         IN  ULONG PinId,
2063         IN  BOOL NodeEvent,
2064         IN  ULONG NodeId)PURE;
2065 };
2066 
2067 typedef IPortEvents *PPORTEVENTS;
2068 
2069 
2070 #define IMP_IPortEvents                        \
2071     STDMETHODIMP_(void) AddEventToEventList(   \
2072         IN  PKSEVENT_ENTRY EventEntry);        \
2073                                                \
2074     STDMETHODIMP_(void) GenerateEventList(     \
2075         IN  GUID* Set OPTIONAL,                \
2076         IN  ULONG EventId,                     \
2077         IN  BOOL PinEvent,                     \
2078         IN  ULONG PinId,                       \
2079         IN  BOOL NodeEvent,                    \
2080         IN  ULONG NodeId)
2081 
2082 /* ===============================================================
2083     IDrmPort / IDrmPort2 Interfaces
2084     These are almost identical, except for the addition of two extra methods.
2085 */
2086 
2087 #undef INTERFACE
2088 #define INTERFACE IDrmPort
2089 
2090 #if (NTDDI_VERSION >= NTDDI_WINXP)
2091 DEFINE_GUID(IID_IDrmPort, 0x286D3DF8L, 0xCA22, 0x4E2E, 0xB9, 0xBC, 0x20, 0xB4, 0xF0, 0xE2, 0x01, 0xCE);
2092 #endif
2093 
2094 #define DEFINE_ABSTRACT_DRMPORT()                          \
2095     STDMETHOD_(NTSTATUS,CreateContentMixed)(THIS_          \
2096         IN  PULONG paContentId,                            \
2097         IN  ULONG cContentId,                              \
2098         OUT PULONG pMixedContentId)PURE;                   \
2099                                                            \
2100     STDMETHOD_(NTSTATUS,DestroyContent)(THIS_              \
2101         IN ULONG ContentId)PURE;                           \
2102                                                            \
2103     STDMETHOD_(NTSTATUS,ForwardContentToFileObject)(THIS_  \
2104         IN ULONG        ContentId,                         \
2105         IN PFILE_OBJECT FileObject)PURE;                   \
2106                                                            \
2107     STDMETHOD_(NTSTATUS,ForwardContentToInterface)(THIS_   \
2108         IN ULONG ContentId,                                \
2109         IN PUNKNOWN pUnknown,                              \
2110         IN ULONG NumMethods)PURE;                          \
2111                                                            \
2112     STDMETHOD_(NTSTATUS,GetContentRights)(THIS_            \
2113         IN  ULONG ContentId,                               \
2114         OUT PDRMRIGHTS  DrmRights)PURE;
2115 
2116 DECLARE_INTERFACE_(IDrmPort, IUnknown)
2117 {
2118     DEFINE_ABSTRACT_UNKNOWN()
2119     DEFINE_ABSTRACT_DRMPORT()
2120 };
2121 
2122 typedef IDrmPort *PDRMPORT;
2123 
2124 #define IMP_IDrmPort                                       \
2125     STDMETHODIMP_(NTSTATUS) CreateContentMixed(            \
2126         IN  PULONG paContentId,                            \
2127         IN  ULONG cContentId,                              \
2128         OUT PULONG pMixedContentId);                       \
2129                                                            \
2130     STDMETHODIMP_(NTSTATUS) DestroyContent(                \
2131         IN ULONG ContentId);                               \
2132                                                            \
2133     STDMETHODIMP_(NTSTATUS) ForwardContentToFileObject(    \
2134         IN ULONG        ContentId,                         \
2135         IN PFILE_OBJECT FileObject);                       \
2136                                                            \
2137     STDMETHODIMP_(NTSTATUS) ForwardContentToInterface(     \
2138         IN ULONG ContentId,                                \
2139         IN PUNKNOWN pUnknown,                              \
2140         IN ULONG NumMethods);                              \
2141                                                            \
2142     STDMETHODIMP_(NTSTATUS) GetContentRights(              \
2143         IN  ULONG ContentId,                               \
2144         OUT PDRMRIGHTS  DrmRights)
2145 
2146 
2147 /* ===============================================================
2148     IDrmPort2 Interface
2149 */
2150 
2151 #undef INTERFACE
2152 #define INTERFACE IDrmPort2
2153 
2154 #if (NTDDI_VERSION >= NTDDI_WINXP)
2155 DEFINE_GUID(IID_IDrmPort2, 0x1ACCE59CL, 0x7311, 0x4B6B, 0x9F, 0xBA, 0xCC, 0x3B, 0xA5, 0x9A, 0xCD, 0xCE);
2156 #endif
2157 
2158 DECLARE_INTERFACE_(IDrmPort2, IDrmPort)
2159 {
2160     DEFINE_ABSTRACT_UNKNOWN()
2161     DEFINE_ABSTRACT_DRMPORT()
2162 
2163     STDMETHOD_(NTSTATUS,AddContentHandlers)(THIS_
2164         IN ULONG ContentId,
2165         IN PVOID * paHandlers,
2166         IN ULONG NumHandlers)PURE;
2167 
2168     STDMETHOD_(NTSTATUS,ForwardContentToDeviceObject)(THIS_
2169         IN ULONG ContentId,
2170         IN PVOID Reserved,
2171         IN PCDRMFORWARD DrmForward)PURE;
2172 };
2173 
2174 typedef IDrmPort2 *PDRMPORT2;
2175 
2176 #define IMP_IDrmPort2                                                \
2177     IMP_IDrmPort;                                                    \
2178     STDMETHODIMP_(NTSTATUS) AddContentHandlers(                      \
2179         IN ULONG ContentId,                                          \
2180         IN PVOID * paHandlers,                                       \
2181         IN ULONG NumHandlers);                                       \
2182                                                                      \
2183     STDMETHODIMP_(NTSTATUS) ForwardContentToDeviceObject(            \
2184         IN ULONG ContentId,                                          \
2185         IN PVOID Reserved,                                           \
2186         IN PCDRMFORWARD DrmForward)
2187 
2188 
2189 /* ===============================================================
2190     IPortClsVersion Interface
2191 */
2192 #undef INTERFACE
2193 #define INTERFACE IPortClsVersion
2194 
2195 #if (NTDDI_VERSION >= NTDDI_WINXP)
2196 DEFINE_GUID(IID_IPortClsVersion, 0x7D89A7BBL, 0x869B, 0x4567, 0x8D, 0xBE, 0x1E, 0x16, 0x8C, 0xC8, 0x53, 0xDE);
2197 #endif
2198 
2199 DECLARE_INTERFACE_(IPortClsVersion, IUnknown)
2200 {
2201     DEFINE_ABSTRACT_UNKNOWN()
2202 
2203     STDMETHOD_(DWORD, GetVersion)(THIS) PURE;
2204 };
2205 
2206 #define IMP_IPortClsVersion \
2207     STDMETHODIMP_(DWORD) GetVersion(void);
2208 
2209 typedef IPortClsVersion *PPORTCLSVERSION;
2210 
2211 #undef INTERFACE
2212 
2213 #if (NTDDI_VERSION >= NTDDI_WINXP)
2214 DEFINE_GUID(IID_IMusicTechnology,
2215 0x80396C3CL, 0xCBCB, 0x409B, 0x9F, 0x65, 0x4F, 0x1E, 0x74, 0x67, 0xCD, 0xAF);
2216 #endif
2217 
2218 /* ===============================================================
2219     IDmaOperations Interface
2220 */
2221 
2222 /* ===============================================================
2223     IPreFetchOffset Interface
2224 */
2225 
2226 /* ===============================================================
2227     PortCls API Functions
2228 */
2229 
2230 typedef NTSTATUS
2231 (NTAPI *PCPFNSTARTDEVICE)(
2232   IN PDEVICE_OBJECT DeviceObject,
2233   IN PIRP Irp,
2234   IN PRESOURCELIST ResourceList);
2235 
2236 /* This is in NTDDK.H */
2237 /*
2238 typedef NTSTATUS (*PDRIVER_ADD_DEVICE)(
2239     IN struct _DRIVER_OBJECT* DriverObject,
2240     IN struct _DEVICE_OBJECT* PhysicalDeviceObject);
2241 */
2242 
2243 PORTCLASSAPI NTSTATUS NTAPI
2244 PcAddAdapterDevice(
2245   IN PDRIVER_OBJECT DriverObject,
2246   IN PDEVICE_OBJECT PhysicalDeviceObject,
2247   IN PCPFNSTARTDEVICE StartDevice,
2248   IN ULONG MaxObjects,
2249   IN ULONG DeviceExtensionSize);
2250 
2251 PORTCLASSAPI NTSTATUS NTAPI
2252 PcInitializeAdapterDriver(
2253   IN PDRIVER_OBJECT DriverObject,
2254   IN PUNICODE_STRING RegistryPathName,
2255   IN PDRIVER_ADD_DEVICE AddDevice);
2256 
2257 /* ===============================================================
2258     Factories (TODO: Move elsewhere)
2259 */
2260 
2261 PORTCLASSAPI NTSTATUS NTAPI
2262 PcNewDmaChannel(
2263   OUT PDMACHANNEL* OutDmaChannel,
2264   IN PUNKNOWN OuterUnknown OPTIONAL,
2265   IN POOL_TYPE PoolType,
2266   IN PDEVICE_DESCRIPTION DeviceDescription,
2267   IN PDEVICE_OBJECT DeviceObject);
2268 
2269 PORTCLASSAPI NTSTATUS NTAPI
2270 PcNewInterruptSync(
2271   OUT PINTERRUPTSYNC* OUtInterruptSync,
2272   IN PUNKNOWN OuterUnknown OPTIONAL,
2273   IN PRESOURCELIST ResourceList,
2274   IN ULONG ResourceIndex,
2275   IN INTERRUPTSYNCMODE Mode);
2276 
2277 PORTCLASSAPI NTSTATUS NTAPI
2278 PcNewMiniport(
2279   OUT PMINIPORT* OutMiniport,
2280   IN REFCLSID ClassId);
2281 
2282 PORTCLASSAPI NTSTATUS NTAPI
2283 PcNewPort(
2284   OUT PPORT* OutPort,
2285   IN REFCLSID ClassId);
2286 
2287 PORTCLASSAPI NTSTATUS NTAPI
2288 PcNewRegistryKey(
2289   OUT PREGISTRYKEY* OutRegistryKey,
2290   IN PUNKNOWN OuterUnknown OPTIONAL,
2291   IN ULONG RegistryKeyType,
2292   IN ACCESS_MASK DesiredAccess,
2293   IN PVOID DeviceObject OPTIONAL,
2294   IN PVOID SubDevice OPTIONAL,
2295   IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
2296   IN ULONG CreateOptions OPTIONAL,
2297   OUT PULONG Disposition OPTIONAL);
2298 
2299 PORTCLASSAPI NTSTATUS NTAPI
2300 PcNewResourceList(
2301   OUT PRESOURCELIST* OutResourceList,
2302   IN PUNKNOWN OuterUnknown OPTIONAL,
2303   IN POOL_TYPE PoolType,
2304   IN PCM_RESOURCE_LIST TranslatedResources,
2305   IN PCM_RESOURCE_LIST UntranslatedResources);
2306 
2307 PORTCLASSAPI NTSTATUS NTAPI
2308 PcNewResourceSublist(
2309   OUT PRESOURCELIST* OutResourceList,
2310   IN PUNKNOWN OuterUnknown OPTIONAL,
2311   IN POOL_TYPE PoolType,
2312   IN PRESOURCELIST ParentList,
2313   IN ULONG MaximumEntries);
2314 
2315 PORTCLASSAPI NTSTATUS NTAPI
2316 PcNewServiceGroup(
2317   OUT PSERVICEGROUP* OutServiceGroup,
2318   IN PUNKNOWN OuterUnknown OPTIONAL);
2319 
2320 
2321 /* ===============================================================
2322     IRP Handling
2323 */
2324 
2325 PORTCLASSAPI NTSTATUS NTAPI
2326 PcDispatchIrp(
2327   IN PDEVICE_OBJECT DeviceObject,
2328   IN PIRP Irp);
2329 
2330 PORTCLASSAPI NTSTATUS NTAPI
2331 PcCompleteIrp(
2332   IN PDEVICE_OBJECT DeviceObject,
2333   IN PIRP Irp,
2334   IN NTSTATUS Status);
2335 
2336 PORTCLASSAPI NTSTATUS NTAPI
2337 PcForwardIrpSynchronous(
2338   IN PDEVICE_OBJECT DeviceObject,
2339   IN PIRP Irp);
2340 
2341 /* ===============================================================
2342     Power Management
2343 */
2344 
2345 PORTCLASSAPI NTSTATUS NTAPI
2346 PcRegisterAdapterPowerManagement(
2347   IN PUNKNOWN pUnknown,
2348   IN PVOID pvContext1);
2349 
2350 PORTCLASSAPI NTSTATUS NTAPI
2351 PcUnregisterAdapterPowerManagement(
2352   IN PDEVICE_OBJECT DeviceObject);
2353 
2354 PORTCLASSAPI NTSTATUS NTAPI
2355 PcRequestNewPowerState(
2356   IN PDEVICE_OBJECT pDeviceObject,
2357   IN DEVICE_POWER_STATE RequestedNewState);
2358 
2359 /* ===============================================================
2360     Properties
2361 */
2362 
2363 PORTCLASSAPI NTSTATUS NTAPI
2364 PcGetDeviceProperty(
2365   IN PVOID DeviceObject,
2366   IN DEVICE_REGISTRY_PROPERTY DeviceProperty,
2367   IN ULONG BufferLength,
2368   OUT PVOID PropertyBuffer,
2369   OUT PULONG ResultLength);
2370 
2371 PORTCLASSAPI NTSTATUS NTAPI
2372 PcCompletePendingPropertyRequest(
2373   IN PPCPROPERTY_REQUEST PropertyRequest,
2374   IN NTSTATUS NtStatus);
2375 
2376 /* ===============================================================
2377     I/O Timeouts
2378 */
2379 
2380 PORTCLASSAPI NTSTATUS NTAPI
2381 PcRegisterIoTimeout(
2382   IN PDEVICE_OBJECT pDeviceObject,
2383   IN PIO_TIMER_ROUTINE pTimerRoutine,
2384   IN PVOID pContext);
2385 
2386 PORTCLASSAPI NTSTATUS NTAPI
2387 PcUnregisterIoTimeout(
2388   IN PDEVICE_OBJECT pDeviceObject,
2389   IN PIO_TIMER_ROUTINE pTimerRoutine,
2390   IN PVOID pContext);
2391 
2392 /* ===============================================================
2393     Physical Connections
2394 */
2395 
2396 PORTCLASSAPI NTSTATUS NTAPI
2397 PcRegisterPhysicalConnection(
2398   IN PDEVICE_OBJECT DeviceObject,
2399   IN PUNKNOWN FromUnknown,
2400   IN ULONG FromPin,
2401   IN PUNKNOWN ToUnknown,
2402   IN ULONG ToPin);
2403 
2404 PORTCLASSAPI NTSTATUS NTAPI
2405 PcRegisterPhysicalConnectionFromExternal(
2406   IN PDEVICE_OBJECT DeviceObject,
2407   IN PUNICODE_STRING FromString,
2408   IN ULONG FromPin,
2409   IN PUNKNOWN ToUnknown,
2410   IN ULONG ToPin);
2411 
2412 PORTCLASSAPI NTSTATUS NTAPI
2413 PcRegisterPhysicalConnectionToExternal(
2414   IN PDEVICE_OBJECT DeviceObject,
2415   IN PUNKNOWN FromUnknown,
2416   IN ULONG FromPin,
2417   IN PUNICODE_STRING ToString,
2418   IN ULONG ToPin);
2419 
2420 /* ===============================================================
2421     Misc
2422 */
2423 
2424 PORTCLASSAPI ULONGLONG NTAPI
2425 PcGetTimeInterval(
2426   IN ULONGLONG Since);
2427 
2428 #define GTI_SECONDS(t)      (ULONGLONG(t)*10000000)
2429 #define GTI_MILLISECONDS(t) (ULONGLONG(t)*10000)
2430 #define GTI_MICROSECONDS(t) (ULONGLONG(t)*10)
2431 
2432 PORTCLASSAPI NTSTATUS NTAPI
2433 PcRegisterSubdevice(
2434   IN PDEVICE_OBJECT DeviceObject,
2435   IN PWCHAR Name,
2436   IN PUNKNOWN Unknown);
2437 
2438 /* ===============================================================
2439     Digital Rights Management Functions
2440     Implemented in XP and above
2441 */
2442 
2443 PORTCLASSAPI NTSTATUS NTAPI
2444 PcAddContentHandlers(
2445   IN ULONG ContentId,
2446   IN PVOID *paHandlers,
2447   IN ULONG NumHandlers);
2448 
2449 PORTCLASSAPI NTSTATUS NTAPI
2450 PcCreateContentMixed(
2451   IN PULONG paContentId,
2452   IN ULONG cContentId,
2453   OUT PULONG pMixedContentId);
2454 
2455 PORTCLASSAPI NTSTATUS NTAPI
2456 PcDestroyContent(
2457   IN ULONG ContentId);
2458 
2459 PORTCLASSAPI NTSTATUS NTAPI
2460 PcForwardContentToDeviceObject(
2461   IN ULONG ContentId,
2462   IN PVOID Reserved,
2463   IN PCDRMFORWARD DrmForward);
2464 
2465 PORTCLASSAPI NTSTATUS NTAPI
2466 PcForwardContentToFileObject(
2467   IN ULONG ContentId,
2468   IN PFILE_OBJECT FileObject);
2469 
2470 PORTCLASSAPI NTSTATUS NTAPI
2471 PcForwardContentToInterface(
2472   IN ULONG ContentId,
2473   IN PUNKNOWN pUnknown,
2474   IN ULONG NumMethods);
2475 
2476 PORTCLASSAPI NTSTATUS NTAPI
2477 PcGetContentRights(
2478   IN ULONG ContentId,
2479   OUT PDRMRIGHTS DrmRights);
2480 
2481 #endif /* PORTCLS_H */
2482