ReactOS 0.4.15-dev-7842-g558ab78
rtminiport.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 rtminiport.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 RT Miniport: "
12
13#include "rtminiport.h"
14#include "rtstream.h"
15
16#if (NTDDI_VERSION >= NTDDI_VISTA)
17
18#ifdef _MSC_VER
19#pragma code_seg("PAGE")
20#endif
21
23
24/*****************************************************************************
25 * CreateAC97MiniportWaveRT
26 *****************************************************************************
27 * Creates a RT miniport object for the AC97 adapter.
28 * This uses a macro from STDUNK.H to do all the work.
29 */
31(
34 IN PUNKNOWN UnknownOuter OPTIONAL,
36 __drv_reportError("Must succeed pool allocations are forbidden. "
37 "Allocation failures cause a system crash"))
39)
40{
41 PAGED_CODE ();
42
44
45 DOUT (DBG_PRINT, ("[CreateMiniportWaveRT]"));
46
47 STD_CREATE_BODY_WITH_TAG_(CAC97MiniportWaveRT,Unknown,UnknownOuter,PoolType,
49}
50
51
52/*****************************************************************************
53 * CAC97MiniportWaveRT::Init
54 *****************************************************************************
55 * Initializes the miniport.
56 * Initializes variables and modifies the wave topology if needed.
57 */
58STDMETHODIMP_(NTSTATUS) CAC97MiniportWaveRT::Init
59(
60 _In_ PUNKNOWN UnknownAdapter,
62 _In_ PPORTWAVERT Port_
63)
64{
65 PAGED_CODE ();
66
67 return CMiniport::Init(
68 UnknownAdapter,
70 Port_
71 );
72}
73
74
75/*****************************************************************************
76 * CAC97MiniportWaveRT::ProcessResources
77 *****************************************************************************
78 * Processes the resource list, setting up helper objects accordingly.
79 * Sets up the Interrupt + Service routine and DMA.
80 */
82(
84)
85{
86 PAGED_CODE ();
87
89
90
91 DOUT (DBG_PRINT, ("[CAC97MiniportWaveRT::ProcessResources]"));
92
93
94 ULONG countIRQ = ResourceList->NumberOfInterrupts ();
95 if (countIRQ < 1)
96 {
97 DOUT (DBG_ERROR, ("Unknown configuration for wave miniport!"));
99 }
100
101 //
102 // Create an interrupt sync object
103 //
104 NTSTATUS ntStatus = STATUS_SUCCESS;
106 NULL,
108 0,
110
111 if (!NT_SUCCESS (ntStatus) || !InterruptSync)
112 {
113 DOUT (DBG_ERROR, ("Failed to create an interrupt sync!"));
115 }
116
117 //
118 // Register our ISR.
119 //
120 ntStatus = InterruptSync->RegisterServiceRoutine (InterruptServiceRoutine,
121 (PVOID)this, FALSE);
122 if (!NT_SUCCESS (ntStatus))
123 {
124 DOUT (DBG_ERROR, ("Failed to register ISR!"));
125 return ntStatus;
126 }
127
128 //
129 // Connect the interrupt.
130 //
131 ntStatus = InterruptSync->Connect ();
132 if (!NT_SUCCESS (ntStatus))
133 {
134 DOUT (DBG_ERROR, ("Failed to connect the ISR with InterruptSync!"));
135 return ntStatus;
136 }
137
138 //
139 // On failure object is destroyed which cleans up.
140 //
141 return STATUS_SUCCESS;
142}
143
144
145/*****************************************************************************
146 * CAC97MiniportWaveRT::NewStream
147 *****************************************************************************
148 * Creates a new stream.
149 * This function is called when a streaming pin is created.
150 * It checks if the channel is already in use, tests the data format, creates
151 * and initializes the stream object.
152 */
153STDMETHODIMP CAC97MiniportWaveRT::NewStream
154(
156 _In_ PPORTWAVERTSTREAM PortStream,
157 _In_ ULONG Channel_,
160)
161{
162 PAGED_CODE ();
163
164 ASSERT (Stream);
165 ASSERT (PortStream);
167
169 NTSTATUS ntStatus = STATUS_SUCCESS;
170
171 DOUT (DBG_PRINT, ("[CAC97MiniportWaveRT::NewStream]"));
172
173 //
174 // Check parameters.
175 //
176 ntStatus = ValidateFormat (DataFormat, (WavePins)Channel_);
177 if (!NT_SUCCESS (ntStatus))
178 {
179 return ntStatus;
180 }
181
182 //
183 // Create a new stream.
184 //
185 ntStatus = CreateAC97MiniportWaveRTStream (&pStream);
186
187 //
188 // Return in case of an error.
189 //
190 if (!NT_SUCCESS (ntStatus))
191 {
192 DOUT (DBG_ERROR, ("[NewStream] Failed to create stream!"));
193 return ntStatus;
194 }
195
196 //
197 // Initialize the stream.
198 //
199 ntStatus = pStream->Init (this,
200 PortStream,
201 Channel,
202 Capture,
203 DataFormat);
204 if (!NT_SUCCESS (ntStatus))
205 {
206 //
207 // Release the stream and clean up.
208 //
209 DOUT (DBG_ERROR, ("[NewStream] Failed to init stream!"));
210 pStream->Release ();
211 *Stream = NULL;
212 return ntStatus;
213 }
214
215 //
216 // Save the pointers.
217 //
218 *Stream = (PMINIPORTWAVERTSTREAM)pStream;
219
220 return STATUS_SUCCESS;
221}
222
223/*****************************************************************************
224 * CAC97MiniportWaveRT::GetDeviceDescription
225 *****************************************************************************
226 * Gets the topology.
227 */
228STDMETHODIMP_(NTSTATUS) CAC97MiniportWaveRT::GetDeviceDescription
229(
230 _Out_ PDEVICE_DESCRIPTION DmaDeviceDescription
231)
232{
233 PAGED_CODE ();
234
235 ASSERT (DmaDeviceDescription);
236
237 DOUT (DBG_PRINT, ("[CAC97MiniportWaveRT::GetDeviceDescription]"));
238
239 RtlZeroMemory (DmaDeviceDescription, sizeof (DEVICE_DESCRIPTION));
240 DmaDeviceDescription->Master = TRUE;
241 DmaDeviceDescription->ScatterGather = TRUE;
242 DmaDeviceDescription->Dma32BitAddresses = TRUE;
243 DmaDeviceDescription->InterfaceType = PCIBus;
244 DmaDeviceDescription->MaximumLength = 0x1FFFE;
245
246 return STATUS_SUCCESS;
247}
248
249
250
251#endif
252
#define PAGED_CODE()
unsigned char BOOLEAN
IPortWaveRT * PPORTWAVERT
Definition: interfaces.hpp:681
LONG NTSTATUS
Definition: precomp.h:26
#define STDMETHODIMP
Definition: basetyps.h:43
#define STDMETHODIMP_(t)
Definition: basetyps.h:44
struct _Capture Capture
Definition: capture.h:24
NTSTATUS Init(IN CAC97MiniportWaveRT *Miniport_, IN PPORTWAVERTSTREAM PortStream, IN ULONG Channel, IN BOOLEAN Capture, IN PKSDATAFORMAT DataFormat)
Definition: rtstream.cpp:106
NTSTATUS ProcessResources(IN PRESOURCELIST ResourceList)
Definition: rtminiport.cpp:82
PINTERRUPTSYNC InterruptSync
Definition: rtminiport.h:75
static NTSTATUS InterruptServiceRoutine(IN PINTERRUPTSYNC InterruptSync, IN PVOID StaticContext)
#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:32
NTSTATUS CreateAC97MiniportWaveRT(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
@ PCIBus
Definition: hwresource.cpp:142
@ Unknown
Definition: i8042prt.h:114
NTSTATUS NTAPI PcNewInterruptSync(OUT PINTERRUPTSYNC *OutInterruptSync, IN PUNKNOWN OuterUnknown OPTIONAL, IN PRESOURCELIST ResourceList, IN ULONG ResourceIndex, IN INTERRUPTSYNCMODE Mode)
Definition: interrupt.cpp:295
#define ASSERT(a)
Definition: mode.c:44
static IStream Stream
Definition: htmldoc.c:1115
#define _Out_
Definition: ms_sal.h:345
#define _When_(expr, annos)
Definition: ms_sal.h:254
#define _In_
Definition: ms_sal.h:308
#define DBG_ERROR
Definition: nfs41_debug.h:78
#define STATUS_DEVICE_CONFIGURATION_ERROR
Definition: ntstatus.h:619
IMiniportWaveRT * PMINIPORTWAVERT
Definition: portcls.h:1983
IResourceList * PRESOURCELIST
Definition: portcls.h:442
IMiniportWaveRTStream * PMINIPORTWAVERTSTREAM
Definition: portcls.h:1865
IPortWaveRTStream * PPORTWAVERTSTREAM
Definition: portcls.h:1847
@ InterruptSyncModeNormal
Definition: portcls.h:840
IN REFCLSID
Definition: rtminiport.cpp:33
NTSTATUS CreateAC97MiniportWaveRTStream(OUT CAC97MiniportWaveRTStream **pRTStream)
Definition: rtstream.cpp:38
#define STATUS_SUCCESS
Definition: shellext.h:65
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
INT POOL_TYPE
Definition: typedefs.h:78
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_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:168
@ NonPagedPoolMustSucceed
Definition: ketypes.h:880