ReactOS 0.4.15-dev-8102-g108db8f
adapter.cpp File Reference
#include "adapter.hpp"
Include dependency graph for adapter.cpp:

Go to the source code of this file.

Macros

#define PUT_GUIDS_HERE
 

Functions

static NTSTATUS InstallSubdevice (PDEVICE_OBJECT DeviceObject, PIRP Irp, PWCHAR Name, REFGUID PortClassId, REFGUID MiniportClassId, PFNCREATEINSTANCE MiniportCreate, PUNKNOWN UnknownAdapter, PRESOURCELIST ResourceList, REFGUID PortInterfaceId, PUNKNOWN *OutPortUnknown)
 
static NTSTATUS ProcessResources (PRESOURCELIST ResourceList, PRESOURCELIST *UartResourceList)
 
NTSTATUS NTAPI StartDevice (PDEVICE_OBJECT DeviceObject, PIRP Irp, PRESOURCELIST ResourceList)
 
NTSTATUS NTAPI AddDevice (PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT PhysicalDeviceObject)
 
static bool CopyResourceDescriptor (PIO_RESOURCE_DESCRIPTOR pInResDescriptor, PIO_RESOURCE_DESCRIPTOR pOutResDescriptor)
 
NTSTATUS NTAPI AdapterDispatchPnp (PDEVICE_OBJECT pDeviceObject, PIRP pIrp)
 
NTSTATUS NTAPI DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPathName)
 
int __cdecl _purecall (void)
 

Macro Definition Documentation

◆ PUT_GUIDS_HERE

#define PUT_GUIDS_HERE

Definition at line 28 of file adapter.cpp.

Function Documentation

◆ _purecall()

int __cdecl _purecall ( void  )

Definition at line 429 of file adapter.cpp.

430{
431 return 0;
432}

◆ AdapterDispatchPnp()

NTSTATUS NTAPI AdapterDispatchPnp ( PDEVICE_OBJECT  pDeviceObject,
PIRP  pIrp 
)

Definition at line 312 of file adapter.cpp.

313{
314 PAGED_CODE();
316 ASSERT(pIrp);
317 DBGPRINT(("AdapterDispatchPnp()"));
318
319 NTSTATUS ntStatus = STATUS_SUCCESS;
320 ULONG resourceListSize;
324
326 DBGPRINT(("[AdapterDispatchPnp] - IRP_MN_FILTER_RESOURCE_REQUIREMENTS"));
327
328 list = (PIO_RESOURCE_REQUIREMENTS_LIST)pIrp->IoStatus.Information;
329
330 // IO_RESOURCE_REQUIREMENTS_LIST has 1 IO_RESOURCE_LIST, IO_RESOURCE_LIST has 1 IO_RESOURCE_DESCRIPTOR and we want 2 more
331 resourceListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) + sizeof(IO_RESOURCE_DESCRIPTOR)*(list->List[0].Count+2) ;
332 resourceList = (PIO_RESOURCE_REQUIREMENTS_LIST)ExAllocatePoolWithTag(PagedPool, resourceListSize, 'LRDV');
333
334 if (!resourceList) {
336 return ntStatus;
337 }
338
339
340 RtlZeroMemory(resourceList, resourceListSize);
341
342 // initialize the list header
343 resourceList->AlternativeLists = 1; // number of IO_RESOURCE_LISTs
344 resourceList->ListSize = resourceListSize;
345
346 resourceList->List[0].Version = 1;
347 resourceList->List[0].Revision = 1;
348 resourceList->List[0].Count = 0;
349
350 // copy the resources which have already been assigned
351 for (unsigned int i=0;i<list->List[0].Count;i++) {
352 if (CopyResourceDescriptor(&list->List[0].Descriptors[i], &resourceList->List[0].Descriptors[resourceList->List[0].Count])) {
353 resourceList->List[0].Count++;
354 }
355 }
357
358 // an additional port for mpu401
359 resourceList->List[0].Count++;
360 descriptor = &resourceList->List[0].Descriptors[resourceList->List[0].Count-1];
363 descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
365 descriptor->u.Port.MinimumAddress.LowPart = 0x300;
366 descriptor->u.Port.MinimumAddress.HighPart = 0;
367 descriptor->u.Port.MaximumAddress.LowPart = 0x330;
368 descriptor->u.Port.MaximumAddress.HighPart = 0;
369 descriptor->u.Port.Length = 2;
370 descriptor->u.Port.Alignment = 0x10;
371
372 // mpu401 port should be optional. yes, this is severely braindamaged.
373 resourceList->List[0].Count++;
374 descriptor = &resourceList->List[0].Descriptors[resourceList->List[0].Count-1];
377 descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
379 descriptor->u.Port.MinimumAddress.LowPart = 0x0;
380 descriptor->u.Port.MinimumAddress.HighPart = 0;
381 descriptor->u.Port.MaximumAddress.LowPart = 0xFFFF;
382 descriptor->u.Port.MaximumAddress.HighPart = 0;
383 descriptor->u.Port.Length = 1;
384 descriptor->u.Port.Alignment = 0x10;
385
386 DBGPRINT(("number of resource list descriptors: %d", resourceList->List[0].Count));
387
388 pIrp->IoStatus.Information = (ULONG_PTR)resourceList;
389
390 // set the return status
391 pIrp->IoStatus.Status = ntStatus;
392 }
393
394 // Pass the IRPs on to PortCls
395 ntStatus = PcDispatchIrp(pDeviceObject, pIrp);
396
397 return ntStatus;
398}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
#define IO_RESOURCE_ALTERNATIVE
Definition: edit.c:119
#define IO_RESOURCE_PREFERRED
Definition: edit.c:117
struct _IO_RESOURCE_DESCRIPTOR IO_RESOURCE_DESCRIPTOR
struct _IO_RESOURCE_REQUIREMENTS_LIST * PIO_RESOURCE_REQUIREMENTS_LIST
#define DBGPRINT(...)
Definition: pdo.c:21
Definition: list.h:37
static bool CopyResourceDescriptor(PIO_RESOURCE_DESCRIPTOR pInResDescriptor, PIO_RESOURCE_DESCRIPTOR pOutResDescriptor)
Definition: adapter.cpp:269
#define ULONG_PTR
Definition: config.h:101
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define PagedPool
Definition: env_spec_w32.h:308
FxIrp * pIrp
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define CmResourceTypePort
Definition: hwresource.cpp:123
NTSTATUS NTAPI PcDispatchIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.cpp:409
#define ASSERT(a)
Definition: mode.c:44
_In_ PNDIS_STRING _In_ PNDIS_STRING _Out_ PDEVICE_OBJECT * pDeviceObject
Definition: ndis.h:4679
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
#define list
Definition: rosglue.h:35
descriptor
Definition: scsi.h:3951
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG Count
Definition: edit.c:124
USHORT Revision
Definition: edit.c:123
USHORT Version
Definition: edit.c:122
IO_RESOURCE_DESCRIPTOR Descriptors[1]
Definition: edit.c:125
IO_RESOURCE_LIST List[1]
Definition: edit.c:135
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
@ CmResourceShareDeviceExclusive
Definition: cmtypes.h:241
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS

Referenced by DriverEntry().

◆ AddDevice()

NTSTATUS NTAPI AddDevice ( PDRIVER_OBJECT  DriverObject,
PDEVICE_OBJECT  PhysicalDeviceObject 
)

Definition at line 259 of file adapter.cpp.

260{
261 PAGED_CODE();
262 DBGPRINT(("AddDevice()"));
263
265}
NTSTATUS NTAPI PcAddAdapterDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject, IN PCPFNSTARTDEVICE StartDevice, IN ULONG MaxObjects, IN ULONG DeviceExtensionSize)
Definition: adapter.cpp:73
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
#define MAX_MINIPORTS
Definition: adapter.cpp:13
static BOOL StartDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DevInfoData OPTIONAL, IN BOOL bEnable, IN DWORD HardwareProfile OPTIONAL, OUT BOOL *bNeedReboot OPTIONAL)
Definition: wizard.c:173
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213

◆ CopyResourceDescriptor()

static bool CopyResourceDescriptor ( PIO_RESOURCE_DESCRIPTOR  pInResDescriptor,
PIO_RESOURCE_DESCRIPTOR  pOutResDescriptor 
)
static

Definition at line 269 of file adapter.cpp.

270{
271 PAGED_CODE();
272 ASSERT(pInResDescriptor);
273 ASSERT(pOutResDescriptor);
274 DBGPRINT(("CopyResourceDescriptor()"));
275
276#if 0
277 RtlCopyMemory(pOutResDescriptor, pInResDescriptor, sizeof(IO_RESOURCE_DESCRIPTOR));
278#else
279 pOutResDescriptor->Type = pInResDescriptor->Type;
280 pOutResDescriptor->ShareDisposition = pInResDescriptor->ShareDisposition;
281 pOutResDescriptor->Flags = pInResDescriptor->Flags;
282 pOutResDescriptor->Option = pInResDescriptor->Option;
283
284 switch (pInResDescriptor->Type) {
287/* // filter crap
288 if ((pInResDescriptor->u.Port.Length == 0) ||
289 ( (pInResDescriptor->u.Port.MinimumAddress.HighPart == pInResDescriptor->u.Port.MaximumAddress.HighPart) && (pInResDescriptor->u.Port.MinimumAddress.LowPart == pInResDescriptor->u.Port.MaximumAddress.LowPart) ) ) {
290 return FALSE;
291 }
292*/ pOutResDescriptor->u.Port.MinimumAddress = pInResDescriptor->u.Port.MinimumAddress;
293 pOutResDescriptor->u.Port.MaximumAddress = pInResDescriptor->u.Port.MaximumAddress;
294 pOutResDescriptor->u.Port.Length = pInResDescriptor->u.Port.Length;
295 pOutResDescriptor->u.Port.Alignment = pInResDescriptor->u.Port.Alignment;
296 DBGPRINT((" Port: min %08x.%08x max %08x.%08x, Length: %x, Option: %x", pOutResDescriptor->u.Port.MinimumAddress.HighPart, pOutResDescriptor->u.Port.MinimumAddress.LowPart,
297 pOutResDescriptor->u.Port.MaximumAddress.HighPart, pOutResDescriptor->u.Port.MaximumAddress.LowPart,
298 pOutResDescriptor->u.Port.Length, pOutResDescriptor->Option));
299 break;
301 pOutResDescriptor->u.Interrupt.MinimumVector = pInResDescriptor->u.Interrupt.MinimumVector;
302 pOutResDescriptor->u.Interrupt.MaximumVector = pInResDescriptor->u.Interrupt.MaximumVector;
303 DBGPRINT((" IRQ: min %x max %x, Option: %d", pOutResDescriptor->u.Interrupt.MinimumVector, pOutResDescriptor->u.Interrupt.MaximumVector, pOutResDescriptor->Option));
304 break;
305 default:
306 return FALSE;
307 }
308 return TRUE;
309#endif
310}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CmResourceTypeNonArbitrated
Definition: hwresource.cpp:129
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
struct _IO_RESOURCE_DESCRIPTOR::@23::@26 Interrupt
struct _IO_RESOURCE_DESCRIPTOR::@23::@24 Port
union _IO_RESOURCE_DESCRIPTOR::@23 u
UCHAR ShareDisposition
Definition: edit.c:61
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by AdapterDispatchPnp().

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( PDRIVER_OBJECT  DriverObject,
PUNICODE_STRING  RegistryPathName 
)

Definition at line 403 of file adapter.cpp.

404{
405 PAGED_CODE();
406 DBGPRINT(("DriverEntry()"));
407
408 NTSTATUS ntStatus;
409
410 //bind the adapter driver to the portclass driver
411 ntStatus = PcInitializeAdapterDriver(DriverObject, RegistryPathName, AddDevice);
412#ifdef UART
413 if(NT_SUCCESS(ntStatus)) {
415 }
416#endif
417#ifdef WAVERT
418 if (!IoIsWdmVersionAvailable(6,0)) {
419 ntStatus = STATUS_UNSUCCESSFUL;
420 }
421#endif
422
423 return ntStatus;
424}
NTSTATUS NTAPI PcInitializeAdapterDriver(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPathName, IN PDRIVER_ADD_DEVICE AddDevice)
Definition: adapter.cpp:29
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI AdapterDispatchPnp(PDEVICE_OBJECT pDeviceObject, PIRP pIrp)
Definition: adapter.cpp:312
BOOLEAN NTAPI IoIsWdmVersionAvailable(IN UCHAR MajorVersion, IN UCHAR MinorVersion)
Definition: util.c:126
DRIVER_ADD_DEVICE AddDevice
Definition: parport.h:72
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

◆ InstallSubdevice()

static NTSTATUS InstallSubdevice ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp,
PWCHAR  Name,
REFGUID  PortClassId,
REFGUID  MiniportClassId,
PFNCREATEINSTANCE  MiniportCreate,
PUNKNOWN  UnknownAdapter,
PRESOURCELIST  ResourceList,
REFGUID  PortInterfaceId,
PUNKNOWN OutPortUnknown 
)
static

Definition at line 38 of file adapter.cpp.

39{
40 PAGED_CODE();
41 DBGPRINT(("InstallSubdevice()"));
42
43 NTSTATUS ntStatus;
44 PPORT Port;
45 PMINIPORT MiniPort;
46
47 ntStatus = PcNewPort(&Port, PortClassId);
48 if (NT_SUCCESS(ntStatus)) {
49 if (MiniportCreate) {
50 ntStatus = MiniportCreate((PUNKNOWN*)&MiniPort, MiniportClassId, NULL, NonPagedPool);
51 } else {
52 ntStatus = PcNewMiniport(&MiniPort, MiniportClassId);
53 }
54 }
55
56 if (!NT_SUCCESS(ntStatus)) {
57 Port->Release();
58 return ntStatus;
59 }
60
61 ntStatus = Port->Init(DeviceObject, Irp, MiniPort, UnknownAdapter, ResourceList);
62 if (NT_SUCCESS(ntStatus)) {
64
65 if (OutPortUnknown && NT_SUCCESS (ntStatus)) {
66 ntStatus = Port->QueryInterface(IID_IUnknown, (PVOID *)OutPortUnknown);
67 }
68 }
69
70 if (MiniPort) {
71 MiniPort->Release();
72 }
73
74 if (Port) {
75 Port->Release();
76 }
77
78 return ntStatus;
79}
NTSTATUS NTAPI PcRegisterSubdevice(IN PDEVICE_OBJECT DeviceObject, IN PWCHAR Name, IN PUNKNOWN Unknown)
Definition: adapter.cpp:206
NTSTATUS NTAPI PcNewMiniport(OUT PMINIPORT *OutMiniport, IN REFCLSID ClassId)
Definition: miniport.cpp:45
const GUID IID_IUnknown
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define NonPagedPool
Definition: env_spec_w32.h:307
CPPORT Port[4]
Definition: headless.c:35
NTSTATUS NTAPI PcNewPort(OUT PPORT *OutPort, IN REFCLSID ClassId)
Definition: port.cpp:17
IPort * PPORT
Definition: portcls.h:1105
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309

◆ ProcessResources()

static NTSTATUS ProcessResources ( PRESOURCELIST  ResourceList,
PRESOURCELIST UartResourceList 
)
static

Definition at line 83 of file adapter.cpp.

84{
85 PAGED_CODE();
87 ASSERT(UartResourceList);
88 DBGPRINT(("ProcessResources()"));
89 DBGPRINT(("NumberOfPorts: %d, NumberOfInterrupts: %d, NumberOfDmas: %d", ResourceList->NumberOfPorts(), ResourceList->NumberOfInterrupts(), ResourceList->NumberOfDmas()));
90#ifdef UART
91 NTSTATUS ntStatus;
92
93 (*UartResourceList) = NULL;
94#endif
95
96 if ((ResourceList->NumberOfPorts() == 0) || (ResourceList->NumberOfPorts() > 2) || (ResourceList->NumberOfInterrupts() != 1) || (ResourceList->NumberOfDmas() != 0)) {
97 DBGPRINT(("Unexpected configuration"));
99 }
100
101#ifdef UART
102 ntStatus = PcNewResourceSublist(UartResourceList, NULL, PagedPool, ResourceList, 2);
103 if (NT_SUCCESS(ntStatus)) {
104 (*UartResourceList)->AddPortFromParent(ResourceList, 1);
105 (*UartResourceList)->AddInterruptFromParent(ResourceList, 0);
106 }
107#endif
108
109 return STATUS_SUCCESS;
110}
#define STATUS_DEVICE_CONFIGURATION_ERROR
Definition: ntstatus.h:619
PORTCLASSAPI NTSTATUS NTAPI PcNewResourceSublist(OUT PRESOURCELIST *OutResourceList, IN PUNKNOWN OuterUnknown OPTIONAL, IN POOL_TYPE PoolType, IN PRESOURCELIST ParentList, IN ULONG MaximumEntries)
Definition: resource.cpp:395

Referenced by StartDevice().

◆ StartDevice()

NTSTATUS NTAPI StartDevice ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp,
PRESOURCELIST  ResourceList 
)

Definition at line 115 of file adapter.cpp.

116{
117 PAGED_CODE();
119 ASSERT(Irp);
121 DBGPRINT(("StartDevice()"));
122
123 NTSTATUS ntStatus;
124 PPORT pPort = 0;
125#ifdef UART
126 ULONG* MPUBase;
127#endif
128
129 ntStatus = PcNewPort(&pPort,CLSID_PortWaveCyclic);
130 if (NT_SUCCESS(ntStatus)) {
131 // not supported in the first edition of win98
132 PPORTEVENTS pPortEvents = 0;
133 ntStatus = pPort->QueryInterface(IID_IPortEvents, (PVOID *)&pPortEvents);
134 if (!NT_SUCCESS(ntStatus)) {
135 DBGPRINT(("ERROR: This driver doesn't work under Win98!"));
136 ntStatus = STATUS_UNSUCCESSFUL;
137 }
138 else
139 {
140 pPortEvents->Release();
141 }
142 pPort->Release ();
143 } else {
144 return ntStatus;
145 }
146
147 // resource validation
148 PRESOURCELIST UartResourceList = NULL;
149 ntStatus = ProcessResources(ResourceList, &UartResourceList);
150 if (!NT_SUCCESS(ntStatus)) {
151 DBGPRINT(("ProcessResources() failed"));
152 return ntStatus;
153 }
154
155 PCMIADAPTER pCMIAdapter = NULL;
156 PUNKNOWN pUnknownCommon = NULL;
157
158 // create the CMIAdapter object
159 ntStatus = NewCMIAdapter(&pUnknownCommon, IID_ICMIAdapter, NULL, NonPagedPool);
160 if (!NT_SUCCESS(ntStatus)) {
161 DBGPRINT(("NewCMIAdapter() failed"));
162 return ntStatus;
163 }
164
165 ntStatus = pUnknownCommon->QueryInterface(IID_ICMIAdapter, (PVOID *)&pCMIAdapter);
166 if (!NT_SUCCESS(ntStatus)) {
167 DBGPRINT(("QueryInterface() for ICMIAdapter failed"));
168 return ntStatus;
169 }
170 ntStatus = pCMIAdapter->init(ResourceList, DeviceObject);
171 if (!NT_SUCCESS(ntStatus)) {
172 DBGPRINT(("CMIAdapter->init() failed"));
173 return ntStatus;
174 }
175
177
178 pUnknownCommon->Release();
179
180 PUNKNOWN unknownWave = NULL;
181 PUNKNOWN unknownTopology = NULL;
182
183 // install the topology miniport.
184 ntStatus = InstallSubdevice(DeviceObject, Irp, L"Topology", CLSID_PortTopology, CLSID_PortTopology, CreateMiniportTopologyCMI, pCMIAdapter, NULL, GUID_NULL, &unknownTopology);
185 if (!NT_SUCCESS (ntStatus)) {
186 DBGPRINT(("Topology miniport installation failed"));
187 return ntStatus;
188 }
189
190#ifdef UART
191 // install the UART miniport - execution order important
192 ntStatus = STATUS_UNSUCCESSFUL;
193 MPUBase = 0;
194 for (int i=0;i<ResourceList->NumberOfPorts();i++) {
195 if (ResourceList->FindTranslatedPort(i)->u.Port.Length == 2) {
196 MPUBase = (UInt32*)ResourceList->FindTranslatedPort(i)->u.Port.Start.QuadPart;
197 }
198 }
199 if (MPUBase != 0) {
200 ntStatus = pCMIAdapter->activateMPU(MPUBase);
201 if (NT_SUCCESS(ntStatus)) {
202 ntStatus = InstallSubdevice(DeviceObject, Irp, L"Uart", CLSID_PortDMus, CLSID_MiniportDriverDMusUART, NULL, pCMIAdapter->getInterruptSync(), UartResourceList, IID_IPortDMus, NULL);
203 }
204 }
205 if (!NT_SUCCESS(ntStatus)) {
206 MPUBase = 0;
207 pCMIAdapter->activateMPU(0);
208 DBGPRINT(("UART miniport installation failed"));
209 }
210 if (UartResourceList) {
211 UartResourceList->Release();
212 }
213#endif
214
215 // install the wave miniport - the order matters here
216#ifdef WAVERT
217 ntStatus = InstallSubdevice(DeviceObject, Irp, L"Wave", CLSID_PortWaveRT, CLSID_PortWaveRT, CreateMiniportWaveCMI, pCMIAdapter, ResourceList, IID_IPortWaveRT, &unknownWave);
218#else
219 ntStatus = InstallSubdevice(DeviceObject, Irp, L"Wave", CLSID_PortWaveCyclic, CLSID_PortWaveCyclic, CreateMiniportWaveCMI, pCMIAdapter, ResourceList, IID_IPortWaveCyclic, &unknownWave);
220#endif
221 if (!NT_SUCCESS(ntStatus)) {
222 DBGPRINT(("Wave miniport installation failed"));
223 return ntStatus;
224 }
225
226 // connect wave and topology pins
228 if (!NT_SUCCESS(ntStatus)) {
229 DBGPRINT(("Cannot connect topology and wave miniport (render)!"));
230 return ntStatus;
231 }
232 ntStatus = PcRegisterPhysicalConnection(DeviceObject, unknownTopology, PIN_WAVEIN_DEST, unknownWave, PIN_WAVE_CAPTURE_SOURCE);
233 if (!NT_SUCCESS(ntStatus)) {
234 DBGPRINT(("Cannot connect topology and wave miniport (capture)!"));
235 return ntStatus;
236 }
237 if (!IoIsWdmVersionAvailable(6,0)) {
238 // this shit fixes the fucking XP mixer and breaks the vista mixer, so we have to check for vista here
240 if (!NT_SUCCESS(ntStatus)) {
241 DBGPRINT(("Cannot connect topology and wave miniport (ac3)!"));
242 }
243 }
244
245 // clean up
246 if (pCMIAdapter) {
247 pCMIAdapter->Release();
248 }
249 if (unknownTopology) {
250 unknownTopology->Release();
251 }
252 if (unknownWave) {
253 unknownWave->Release();
254 }
255
256 return ntStatus;
257}
NTSTATUS NTAPI CreateMiniportTopologyCMI(OUT PUNKNOWN *Unknown, IN REFCLSID, IN PUNKNOWN UnknownOuter OPTIONAL, IN POOL_TYPE PoolType)
NTSTATUS NTAPI CreateMiniportWaveCMI(OUT PUNKNOWN *Unknown, IN REFCLSID, IN PUNKNOWN UnknownOuter OPTIONAL, IN POOL_TYPE PoolType)
NTSTATUS NewCMIAdapter(OUT PUNKNOWN *Unknown, IN REFCLSID, IN PUNKNOWN UnknownOuter OPTIONAL, IN POOL_TYPE PoolType)
DWORD UInt32
Definition: chm_lib.c:104
NTSTATUS NTAPI PcRegisterPhysicalConnection(IN PDEVICE_OBJECT DeviceObject, IN PUNKNOWN FromUnknown, IN ULONG FromPin, IN PUNKNOWN ToUnknown, IN ULONG ToPin)
Definition: connection.cpp:259
static NTSTATUS ProcessResources(PRESOURCELIST ResourceList, PRESOURCELIST *UartResourceList)
Definition: adapter.cpp:83
@ PIN_WAVE_CAPTURE_SOURCE
Definition: interfaces.hpp:445
@ PIN_WAVE_AC3_RENDER_SOURCE
Definition: interfaces.hpp:449
@ PIN_WAVE_RENDER_SOURCE
Definition: interfaces.hpp:447
@ PIN_SPDIF_AC3_SOURCE
Definition: interfaces.hpp:391
ICMIAdapter * PCMIADAPTER
Definition: interfaces.hpp:261
NTSTATUS InstallSubdevice(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ PWSTR Name, _In_ REFGUID PortClassId, _In_ REFGUID MiniportClassId, _In_opt_ PFNCREATEMINIPORT MiniportCreate, _In_opt_ PUNKNOWN UnknownAdapter, _In_opt_ PRESOURCELIST ResourceList, _In_opt_ REFGUID PortInterfaceId, _Out_opt_ PMINIPORT *OutMiniport, _Out_opt_ PUNKNOWN *OutPortUnknown)
Definition: adapter.cpp:48
NTSTATUS NTAPI PcRegisterAdapterPowerManagement(IN PUNKNOWN pUnknown, IN PVOID pvContext)
Definition: power.cpp:16
@ PIN_WAVEOUT_SOURCE
Definition: shared.h:114
@ PIN_WAVEIN_DEST
Definition: shared.h:134
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
ULONG Release()
nsrefcnt Release()
#define GUID_NULL
Definition: ks.h:106
#define L(x)
Definition: ntvdm.h:50
IResourceList * PRESOURCELIST
Definition: portcls.h:442
IPortEvents * PPORTEVENTS
Definition: portcls.h:2121