ReactOS 0.4.16-dev-297-gc569aee
wavepciminiport.cpp
Go to the documentation of this file.
1/********************************************************************************
2** Copyright (c) 1998-2000 Microsoft Corporation. All Rights Reserved.
3**
4** Portions Copyright (c) 1998-1999 Intel Corporation
5**
6********************************************************************************/
7
8/* The file wavepciminiport.cpp was reviewed by LCA in June 2011 and is acceptable for use by Microsoft. */
9
10// Every debug output has "Modulname text"
11#define STR_MODULENAME "AC97 Wave: "
12
13#include "wavepciminiport.h"
14#include "wavepcistream.h"
15
16
17#ifdef _MSC_VER
18#pragma code_seg("PAGE")
19#endif
20
21IMP_CMiniport(CMiniportWaveICH, IID_IMiniportWavePci)
22
23/*****************************************************************************
24 * CreateAC97MiniportWavePCI
25 *****************************************************************************
26 * Creates a AC97 wave miniport object for the AC97 adapter.
27 * This uses a macro from STDUNK.H to do all the work.
28 */
30(
33 IN PUNKNOWN UnknownOuter OPTIONAL,
35 __drv_reportError("Must succeed pool allocations are forbidden. "
36 "Allocation failures cause a system crash"))
38)
39{
40 PAGED_CODE ();
41
43
44 DOUT (DBG_PRINT, ("[CreateAC97MiniportWavePCI]"));
45
46 STD_CREATE_BODY_WITH_TAG_(CMiniportWaveICH,Unknown,UnknownOuter,PoolType,
48}
49
50/*****************************************************************************
51 * CMiniportWaveICH::Init
52 *****************************************************************************
53 * Initializes the miniport.
54 * Initializes variables and modifies the wave topology if needed.
55 */
56STDMETHODIMP_(NTSTATUS) CMiniportWaveICH::Init
57(
58 _In_ PUNKNOWN UnknownAdapter,
60 _In_ PPORTWAVEPCI Port_,
61 _Out_ PSERVICEGROUP *ServiceGroup_
62)
63{
64 PAGED_CODE ();
65
66 //
67 // No miniport service group
68 //
69 *ServiceGroup_ = NULL;
70
71 NTSTATUS ntStatus = CMiniport::Init(
72 UnknownAdapter,
74 Port_
75 );
76
77 if (!NT_SUCCESS (ntStatus))
78 {
79 return ntStatus;
80 }
81
82 //
83 // Create the DMA Channel object.
84 //
85 ntStatus = Port->NewMasterDmaChannel (&DmaChannel, // OutDmaChannel
86 NULL, // OuterUnknown (opt)
87 NonPagedPool, // Pool Type
88 NULL, // ResourceList (opt)
89 TRUE, // ScatterGather
90 TRUE, // Dma32BitAddresses
91 FALSE, // Dma64BitAddresses
92 FALSE, // IgnoreCount
93 Width32Bits, // DmaWidth
94 MaximumDmaSpeed, // DmaSpeed
95 0x1FFFE, // MaximumLength (128KByte -2)
96 0); // DmaPort
97 if (!NT_SUCCESS (ntStatus))
98 {
99 DOUT (DBG_ERROR, ("Failed on NewMasterDmaChannel!"));
100 return ntStatus;
101 }
102
103 //
104 // On failure object is destroyed which cleans up.
105 //
106 return ntStatus;
107}
108
109/*****************************************************************************
110 * CMiniportWaveICH::NewStream
111 *****************************************************************************
112 * Creates a new stream.
113 * This function is called when a streaming pin is created.
114 * It checks if the channel is already in use, tests the data format, creates
115 * and initializes the stream object.
116 */
118STDMETHODIMP CMiniportWaveICH::NewStream
119(
121 PUNKNOWN OuterUnknown,
123 PPORTWAVEPCISTREAM PortStream,
124 ULONG Pin_,
127 PDMACHANNEL *DmaChannel_,
128 PSERVICEGROUP *ServiceGroup
129)
130{
131 PAGED_CODE ();
132
133 ASSERT (Stream);
134 ASSERT (PortStream);
136 ASSERT (DmaChannel_);
137 ASSERT (ServiceGroup);
138
139 CMiniportWaveICHStream *pWaveICHStream = NULL;
140 NTSTATUS ntStatus = STATUS_SUCCESS;
141
142 DOUT (DBG_PRINT, ("[CMiniportWaveICH::NewStream]"));
143
144 //
145 // Check parameters.
146 //
147 ntStatus = ValidateFormat (DataFormat, (WavePins)Pin_);
148 if (!NT_SUCCESS (ntStatus))
149 {
150 return ntStatus;
151 }
152
153 //
154 // Create a new stream.
155 //
156 ntStatus = CreateMiniportWaveICHStream (&pWaveICHStream, OuterUnknown,
157 PoolType);
158
159 //
160 // Return in case of an error.
161 //
162 if (!NT_SUCCESS (ntStatus))
163 {
164 DOUT (DBG_ERROR, ("[NewStream] Failed to create stream!"));
165 return ntStatus;
166 }
167
168 //
169 // Initialize the stream.
170 //
171 ntStatus = pWaveICHStream->Init ((CMiniport*)this,
172 PortStream,
173 (WavePins)Pin_,
174 Capture,
176 ServiceGroup);
177 if (!NT_SUCCESS (ntStatus))
178 {
179 //
180 // Release the stream and clean up.
181 //
182 DOUT (DBG_ERROR, ("[NewStream] Failed to init stream!"));
183 pWaveICHStream->Release ();
184
185 return ntStatus;
186 }
187
188 //
189 // Save the pointers.
190 //
191 *Stream = (PMINIPORTWAVEPCISTREAM)pWaveICHStream;
192 obj_AddRef(DmaChannel, (PVOID *)DmaChannel_);
193
194 return STATUS_SUCCESS;
195}
196
197/*****************************************************************************
198 * Non paged code begins here
199 *****************************************************************************
200 */
201
202#ifdef _MSC_VER
203#pragma code_seg()
204#endif
205/*****************************************************************************
206 * CMiniportWaveICH::Service
207 *****************************************************************************
208 * Processing routine for dealing with miniport interrupts. This routine is
209 * called at DISPATCH_LEVEL.
210 */
211STDMETHODIMP_(void) CMiniportWaveICH::Service (void)
212{
213 // not needed
214}
#define PAGED_CODE()
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define STDMETHODIMP
Definition: basetyps.h:43
struct _Capture Capture
Definition: capture.h:24
NTSTATUS Init(IN CMiniport *Miniport_, IN PUNKNOWN PortStream, IN WavePins Pin_, IN BOOLEAN Capture_, IN PKSDATAFORMAT DataFormat_, OUT PSERVICEGROUP *ServiceGroup_)
Definition: stream.cpp:65
NTSTATUS ValidateFormat(IN PKSDATAFORMAT DataFormat, IN WavePins Pin)
Definition: miniport.cpp:781
PDMACHANNEL DmaChannel
Definition: miniport.h:33
_In_ PRESOURCELIST _In_ PPORT Port_
Definition: miniport.h:98
PPORT_ Port
Definition: miniport.h:30
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
void __fastcall obj_AddRef(PUNKNOWN obj, void **ppvObject)
Definition: miniport.cpp:1264
NTSTATUS CreateAC97MiniportWavePCI(OUT PUNKNOWN *Unknown, IN REFCLSID, IN PUNKNOWN UnknownOuter OPTIONAL, IN POOL_TYPE PoolType)
#define DOUT(lvl, strings)
Definition: debug.h:82
#define IMP_CMiniport(cType, IID)
Definition: miniport.h:119
WavePins
Definition: shared.h:317
#define __drv_reportError(why)
Definition: driverspecs.h:320
#define NonPagedPool
Definition: env_spec_w32.h:307
@ Unknown
Definition: i8042prt.h:114
#define ASSERT(a)
Definition: mode.c:44
static IStream Stream
Definition: htmldoc.c:1115
#define DBG_ERROR
Definition: nfs41_debug.h:78
#define _Use_decl_annotations_
Definition: no_sal2.h:92
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _When_(c, a)
Definition: no_sal2.h:38
IDmaChannel * PDMACHANNEL
Definition: portcls.h:784
IMiniportWavePciStream * PMINIPORTWAVEPCISTREAM
Definition: portcls.h:1643
IResourceList * PRESOURCELIST
Definition: portcls.h:442
IPortWavePciStream * PPORTWAVEPCISTREAM
Definition: portcls.h:1590
IMiniportWavePci * PMINIPORTWAVEPCI
Definition: portcls.h:1697
IServiceGroup * PSERVICEGROUP
Definition: portcls.h:614
IPortWavePci * PPORTWAVEPCI
Definition: portcls.h:1248
@ Width32Bits
Definition: miniport.h:107
@ MaximumDmaSpeed
Definition: miniport.h:117
#define STATUS_SUCCESS
Definition: shellext.h:65
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
INT POOL_TYPE
Definition: typedefs.h:78
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
IN REFCLSID
STDMETHODIMP_(void) CMiniportWaveICH
NTSTATUS CreateMiniportWaveICHStream(OUT CMiniportWaveICHStream **pWaveIchStream, IN PUNKNOWN pUnknown, _When_((PoolType &NonPagedPoolMustSucceed) !=0, __drv_reportError("Must succeed pool allocations are forbidden. " "Allocation failures cause a system crash")) IN POOL_TYPE PoolType)
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG PoolTag
Definition: wdfmemory.h:164
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309
#define DBG_PRINT(ppi, ch, level)
Definition: win32kdebug.h:169
@ NonPagedPoolMustSucceed
Definition: ketypes.h:880