-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathadapter.cpp
More file actions
978 lines (869 loc) · 28 KB
/
Copy pathadapter.cpp
File metadata and controls
978 lines (869 loc) · 28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
/*****************************************************************************
* adapter.cpp - HDA adapter driver implementation.
*****************************************************************************
* Copyright (c) 1997-1999 Microsoft Corporation. All rights reserved.
*
* This files does setup and resource allocation/verification for the HDA
* card. It controls which miniports are started and which resources are
* given to each miniport. It also deals with interrupt sharing between
* miniports by hooking the interrupt and calling the correct DPC.
*/
//
// All the GUIDS for all the miniports end up in this object.
//
#define PUT_GUIDS_HERE
#define STR_MODULENAME "HDAAdapter: "
#define DEFINE_DEBUG_VARS
#include "common.h"
/*****************************************************************************
* Defines
*/
#define MAX_MINIPORTS 5
#if (DBG)
#define SUCCEEDS(s) ASSERT(NT_SUCCESS(s))
#else
#define SUCCEEDS(s) (s)
#endif
PDEVICE_OBJECT PDO;
/*****************************************************************************
* Externals
*/
NTSTATUS
CreateMiniportWaveCyclicHDA
(
OUT PUNKNOWN * Unknown,
IN REFCLSID,
IN PUNKNOWN UnknownOuter OPTIONAL,
IN POOL_TYPE PoolType
);
NTSTATUS
CreateMiniportTopologyHDA
(
OUT PUNKNOWN * Unknown,
IN REFCLSID,
IN PUNKNOWN UnknownOuter OPTIONAL,
IN POOL_TYPE PoolType
);
/*****************************************************************************
* Referenced forward
*/
extern "C"
NTSTATUS
AddDevice
(
IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT PhysicalDeviceObject
);
NTSTATUS
StartDevice
(
IN PDEVICE_OBJECT DeviceObject, // Device object.
IN PIRP Irp, // IO request packet.
IN PRESOURCELIST ResourceList // List of hardware resources.
);
BOOLEAN
AdapterISR
(
IN PKINTERRUPT Interrupt,
IN PVOID Context
);
NTSTATUS
AssignResources
(
IN PRESOURCELIST ResourceList, // All resources.
OUT PRESOURCELIST * ResourceListTopology, // Topology resources.
OUT PRESOURCELIST * ResourceListWave, // Wave resources.
OUT PRESOURCELIST * ResourceListWaveTable, // Wave table resources.
OUT PRESOURCELIST * ResourceListFmSynth, // FM synth resources.
OUT PRESOURCELIST * ResourceListUart, // UART resources.
OUT PRESOURCELIST * ResourceListAdapter // a copy needed by the adapter
);
#ifdef DO_RESOURCE_FILTERING
extern "C"
NTSTATUS
AdapterDispatchPnp
(
IN PDEVICE_OBJECT pDeviceObject,
IN PIRP pIrp
);
#endif
#pragma code_seg("INIT")
/*****************************************************************************
* DriverEntry()
*****************************************************************************
* This function is called by the operating system when the driver is loaded.
* All adapter drivers can use this code without change.
*/
extern "C"
NTSTATUS
DriverEntry
(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPathName
)
{
PAGED_CODE();
//
// Tell the class driver to initialize the driver.
//
NTSTATUS ntStatus = PcInitializeAdapterDriver( DriverObject,
RegistryPathName,
AddDevice );
#ifdef DO_RESOURCE_FILTERING
//
// We want to do resource filtering, so we'll install our own PnP IRP handler.
//
if(NT_SUCCESS(ntStatus))
{
DriverObject->MajorFunction[IRP_MJ_PNP] = AdapterDispatchPnp;
}
#endif
return ntStatus;
}
#pragma code_seg("PAGE")
/*****************************************************************************
* AddDevice()
*****************************************************************************
* This function is called by the operating system when the device is added.
* All adapter drivers can use this code without change.
*/
extern "C"
NTSTATUS
AddDevice
(
IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT PhysicalDeviceObject
)
{
PAGED_CODE();
ASSERT(PhysicalDeviceObject != NULL);
DOUT(DBG_SYSINFO, ("PDO 0x%X",
PhysicalDeviceObject));
PDO = PhysicalDeviceObject;
DOUT(DBG_SYSINFO, ("FDO 0x%X",
DriverObject));
//
// Tell the class driver to add the device.
//
return PcAddAdapterDevice( DriverObject,
PhysicalDeviceObject,
PCPFNSTARTDEVICE( StartDevice ),
MAX_MINIPORTS,
0 );
}
/*****************************************************************************
* InstallSubdevice()
*****************************************************************************
* This function creates and registers a subdevice consisting of a port
* driver, a minport driver and a set of resources bound together. It will
* also optionally place a pointer to an interface on the port driver in a
* specified location before initializing the port driver. This is done so
* that a common ISR can have access to the port driver during initialization,
* when the ISR might fire.
*/
NTSTATUS
InstallSubdevice
(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PWCHAR Name,
IN REFGUID PortClassId,
IN REFGUID MiniportClassId,
IN PFNCREATEINSTANCE MiniportCreate OPTIONAL,
IN PUNKNOWN UnknownAdapter OPTIONAL,
IN PRESOURCELIST ResourceList,
IN REFGUID PortInterfaceId,
OUT PUNKNOWN * OutPortInterface, OPTIONAL
OUT PUNKNOWN * OutPortUnknown OPTIONAL
)
{
PAGED_CODE();
_DbgPrintF(DEBUGLVL_VERBOSE, ("InstallSubdevice"));
ASSERT(DeviceObject);
ASSERT(Irp);
ASSERT(Name);
ASSERT(ResourceList);
//
// Create the port driver object
//
PPORT port;
NTSTATUS ntStatus = PcNewPort(&port,PortClassId);
if (NT_SUCCESS(ntStatus))
{
//
// Deposit the port somewhere if it's needed.
//
if (OutPortInterface)
{
//
// Failure here doesn't cause the entire routine to fail.
//
(void) port->QueryInterface
(
PortInterfaceId,
(PVOID *) OutPortInterface
);
}
PUNKNOWN miniport;
if (NT_SUCCESS(ntStatus))
{
//
// Create the miniport object
//
if (MiniportCreate)
{
ntStatus = MiniportCreate
(
&miniport,
MiniportClassId,
NULL,
NonPagedPool
);
}
else
{
ntStatus = PcNewMiniport((PMINIPORT*) &miniport,MiniportClassId);
}
}
if (NT_SUCCESS(ntStatus))
{
//
// Init the port driver and miniport in one go.
//
ntStatus = port->Init( DeviceObject,
Irp,
miniport,
UnknownAdapter,
ResourceList );
if (NT_SUCCESS(ntStatus))
{
//
// Register the subdevice (port/miniport combination).
//
ntStatus = PcRegisterSubdevice( DeviceObject,
Name,
port );
#if DBG
if (!(NT_SUCCESS(ntStatus)))
{
_DbgPrintF(DEBUGLVL_TERSE, ("StartDevice: PcRegisterSubdevice failed"));
}
#endif
}
else
{
_DbgPrintF(DEBUGLVL_TERSE, ("InstallSubdevice: port->Init failed"));
}
//
// We don't need the miniport any more. Either the port has it,
// or we've failed, and it should be deleted.
//
miniport->Release();
}
else
{
_DbgPrintF(DEBUGLVL_TERSE, ("InstallSubdevice: PcNewMiniport failed"));
}
if (NT_SUCCESS(ntStatus))
{
//
// Deposit the port as an unknown if it's needed.
//
if (OutPortUnknown)
{
//
// Failure here doesn't cause the entire routine to fail.
//
(void) port->QueryInterface
(
IID_IUnknown,
(PVOID *) OutPortUnknown
);
}
}
else
{
//
// Retract previously delivered port interface.
//
if (OutPortInterface && (*OutPortInterface))
{
(*OutPortInterface)->Release();
*OutPortInterface = NULL;
}
}
//
// Release the reference which existed when PcNewPort() gave us the
// pointer in the first place. This is the right thing to do
// regardless of the outcome.
//
port->Release();
}
else
{
_DbgPrintF(DEBUGLVL_TERSE, ("InstallSubdevice: PcNewPort failed"));
}
return ntStatus;
}
/*****************************************************************************
* StartDevice()
*****************************************************************************
* This function is called by the operating system when the device is started.
* It is responsible for starting the miniports. This code is specific to
* the adapter because it calls out miniports for functions that are specific
* to the adapter.
*/
NTSTATUS
StartDevice
(
IN PDEVICE_OBJECT DeviceObject, // Device object.
IN PIRP Irp, // IO request packet.
IN PRESOURCELIST ResourceList // List of hardware resources.
)
{
PAGED_CODE();
ASSERT(DeviceObject);
ASSERT(Irp);
ASSERT(ResourceList);
//
// These are the sub-lists of resources that will be handed to the
// miniports.
//
PRESOURCELIST resourceListTopology = NULL;
PRESOURCELIST resourceListWave = NULL;
PRESOURCELIST resourceListWaveTable = NULL;
PRESOURCELIST resourceListFmSynth = NULL;
PRESOURCELIST resourceListUart = NULL;
PRESOURCELIST resourceListAdapter = NULL;
//
// These are the port driver pointers we are keeping around for registering
// physical connections.
//
PUNKNOWN unknownTopology = NULL;
PUNKNOWN unknownWave = NULL;
PUNKNOWN unknownWaveTable = NULL;
PUNKNOWN unknownFmSynth = NULL;
//
// Assign resources to individual miniports. Each sub-list is a copy
// of the resources from the master list. Each sublist must be released.
//
NTSTATUS ntStatus = AssignResources( ResourceList,
&resourceListTopology,
&resourceListWave,
&resourceListWaveTable,
&resourceListFmSynth,
&resourceListUart,
&resourceListAdapter );
//
// if AssignResources succeeded...
//
if(NT_SUCCESS(ntStatus))
{
//
// If the adapter has resources...
//
PADAPTERCOMMON pAdapterCommon = NULL;
if (resourceListAdapter)
{
PUNKNOWN pUnknownCommon;
// create a new adapter common object
ntStatus = NewAdapterCommon( &pUnknownCommon,
IID_IAdapterCommon,
NULL,
NonPagedPool );
if (NT_SUCCESS(ntStatus))
{
ASSERT( pUnknownCommon );
// query for the IAdapterCommon interface
ntStatus = pUnknownCommon->QueryInterface( IID_IAdapterCommon,
(PVOID *)&pAdapterCommon );
if (NT_SUCCESS(ntStatus))
{
// Initialize the object
ntStatus = pAdapterCommon->Init( resourceListAdapter,
DeviceObject, PDO );
if (NT_SUCCESS(ntStatus))
{
// register with PortCls for power-managment services
ntStatus = PcRegisterAdapterPowerManagement( (PUNKNOWN)pAdapterCommon,
DeviceObject );
}
}
// release the IUnknown on adapter common
pUnknownCommon->Release();
}
// release the adapter common resource list
resourceListAdapter->Release();
}
//
// Start the topology miniport if it exists.
//
if (resourceListTopology)
{
if (NT_SUCCESS(ntStatus))
{
ntStatus = InstallSubdevice( DeviceObject,
Irp,
L"Topology",
CLSID_PortTopology,
CLSID_PortTopology, // not used
CreateMiniportTopologyHDA,
pAdapterCommon,
resourceListTopology,
GUID_NULL,
NULL,
&unknownTopology );
}
// release the topology resource list
resourceListTopology->Release();
}
//
// Start the SB wave miniport if it exists.
//
if (resourceListWave)
{
if (NT_SUCCESS(ntStatus))
{
ntStatus = InstallSubdevice( DeviceObject,
Irp,
L"Wave",
CLSID_PortWaveCyclic,
CLSID_PortWaveCyclic, // not used
CreateMiniportWaveCyclicHDA,
pAdapterCommon,
resourceListWave,
IID_IPortWaveCyclic,
pAdapterCommon->WavePortDriverDest(),
&unknownWave );
}
// release the wave resource list
resourceListWave->Release();
}
//everything below this line cannot exist now as it was removed from ProcessResources
// Start the wave table miniport if it exists.
if (resourceListWaveTable)
{
//
// NOTE: The wavetable is not currently supported in this sample driver.
//
// release the wavetable resource list
resourceListWaveTable->Release();
}
//
// Start the FM synth miniport if it exists.
//
if (resourceListFmSynth)
{
//
// Synth not working yet.
// This is supposed to pass an i/o port to the built-in FMSynth miniport
// if we don't have hardware FM this cannot work.
// TODO: build SBEMUL like driver to trap OPL ports & route to Nuked OPL3
//
if (NT_SUCCESS(ntStatus))
{
//
// Failure here is not fatal.
//
InstallSubdevice( DeviceObject,
Irp,
L"FMSynth",
CLSID_PortMidi,
CLSID_MiniportDriverFmSynth,
NULL,
pAdapterCommon,
resourceListFmSynth,
GUID_NULL,
NULL,
&unknownFmSynth );
}
// release the FM synth resource list
resourceListFmSynth->Release();
}
//
// Start the UART miniport if it exists.
//
if (resourceListUart)
{
if (NT_SUCCESS(ntStatus))
{
//
// Failure here is not fatal.
//
InstallSubdevice( DeviceObject,
Irp,
L"Uart",
CLSID_PortDMus,
CLSID_MiniportDriverDMusUART,
NULL,
pAdapterCommon->GetInterruptSync(),
resourceListUart,
IID_IPortDMus,
pAdapterCommon->MidiPortDriverDest(),
NULL ); // not physically connected to anything
}
resourceListUart->Release();
}
//
// Establish physical connections between filters as shown.
//
// +------+ +------+
// | Wave | | Topo |
// Capture <---|0 1|<===|6 2|<--- CD
// | | | |
// Render --->|2 3|===>|0 3|<--- Line In
// +------+ | |
// +------+ | 4|<--- Mic
// | FM | | |
// MIDI --->|0 1|===>|1 5|---> Line Out
// +------+ +------+
//
if (unknownTopology)
{
if (unknownWave)
{
// register wave <=> topology connections
PcRegisterPhysicalConnection( (PDEVICE_OBJECT)DeviceObject,
unknownTopology,
6,
unknownWave,
1 );
PcRegisterPhysicalConnection( (PDEVICE_OBJECT)DeviceObject,
unknownWave,
3,
unknownTopology,
0 );
}
if (unknownFmSynth)
{
// register fmsynth <=> topology connection
PcRegisterPhysicalConnection( (PDEVICE_OBJECT)DeviceObject,
unknownFmSynth,
1,
unknownTopology,
1 );
}
}
//
// Release the adapter common object. It either has other references,
// or we need to delete it anyway.
//
if (pAdapterCommon)
{
pAdapterCommon->Release();
}
//
// Release the unknowns.
//
if (unknownTopology)
{
unknownTopology->Release();
}
if (unknownWave)
{
unknownWave->Release();
}
if (unknownWaveTable)
{
unknownWaveTable->Release();
}
if (unknownFmSynth)
{
unknownFmSynth->Release();
}
}
return ntStatus;
}
/*****************************************************************************
* AssignResources()
*****************************************************************************
* This function assigns the list of resources to the various functions on
* the card. This code is specific to the adapter. All the non-NULL resource
* lists handed back must be released by the caller.
*/
NTSTATUS
AssignResources
(
IN PRESOURCELIST ResourceList, // All resources.
OUT PRESOURCELIST * ResourceListTopology, // Topology resources.
OUT PRESOURCELIST * ResourceListWave, // Wave resources.
OUT PRESOURCELIST * ResourceListWaveTable, // Wave table resources.
OUT PRESOURCELIST * ResourceListFmSynth, // FM synth resources.
OUT PRESOURCELIST * ResourceListUart, // Uart resources.
OUT PRESOURCELIST * ResourceListAdapter // For the adapter
)
{
BOOLEAN detectedWaveTable = FALSE;
BOOLEAN detectedUart = FALSE;
BOOLEAN detectedFmSynth = FALSE;
//
// Get counts for the types of resources.
//
ULONG countIO = ResourceList->NumberOfPorts();
ULONG countIRQ = ResourceList->NumberOfInterrupts();
ULONG countDMA = ResourceList->NumberOfDmas();
//
// Determine the type of card based on port resources.
//
NTSTATUS ntStatus = STATUS_SUCCESS;
switch (countIO)
{
case 0:
//
// HD Audio doesn't use IO ports or 8237 DMA. No FM synth or UART.
if ((countIO != 0) || (countIRQ > 1) || (countDMA != 0))
{
DOUT (DBG_ERROR, ("Unknown configuration!\n"
" IO count: %d\n"
" IRQ count: %d\n"
" DMA count: %d",
countIO, countIRQ, countDMA));
ntStatus = STATUS_DEVICE_CONFIGURATION_ERROR;
} else if (countIRQ == 0){
ntStatus = STATUS_INSUFFICIENT_RESOURCES;
} else {
ntStatus = STATUS_SUCCESS;
}
//removed other cases
break;
default:
ntStatus = STATUS_DEVICE_CONFIGURATION_ERROR;
break;
}
//
// Build list of resources for the topology.
//
*ResourceListTopology = NULL;
if (NT_SUCCESS(ntStatus))
{
ntStatus =
PcNewResourceSublist
(
ResourceListTopology,
NULL,
PagedPool,
ResourceList,
countIRQ + countDMA + 1
);
if (NT_SUCCESS(ntStatus))
{
SUCCEEDS((*ResourceListTopology)->
AddMemoryFromParent(ResourceList,0));
}
}
//
// Build the resource list for the SB wave I/O.
//
*ResourceListWave = NULL;
if (NT_SUCCESS(ntStatus))
{
ntStatus =
PcNewResourceSublist
(
ResourceListWave,
NULL,
PagedPool,
ResourceList,
countDMA + countIRQ + 1
);
if (NT_SUCCESS(ntStatus))
{
ULONG i;
//
// Add the base address
//
SUCCEEDS((*ResourceListWave)->
AddMemoryFromParent(ResourceList,0));
//
// Add the DMA channel(s).
//
for (i = 0; i < countDMA; i++)
{
SUCCEEDS((*ResourceListWave)->
AddDmaFromParent(ResourceList,i));
}
//
// Add the IRQ lines.
//
for (i = 0; i < countIRQ; i++)
{
SUCCEEDS((*ResourceListWave)->
AddInterruptFromParent(ResourceList,i));
}
}
}
//
// Build list of resources for wave table.
//
*ResourceListWaveTable = NULL;
if (NT_SUCCESS(ntStatus) && detectedWaveTable)
{
//
// TODO: Assign wave table resources.
//
}
//
// Build list of resources for UART.
//
*ResourceListUart = NULL;
if (NT_SUCCESS(ntStatus) && detectedUart)
{
ntStatus =
PcNewResourceSublist
(
ResourceListUart,
NULL,
PagedPool,
ResourceList,
2
);
if (NT_SUCCESS(ntStatus))
{
SUCCEEDS((*ResourceListUart)->
AddMemoryFromParent(ResourceList,1));
SUCCEEDS((*ResourceListUart)->
AddInterruptFromParent(ResourceList,0));
}
}
//
// Build list of resources for FM synth.
//
*ResourceListFmSynth = NULL;
if (NT_SUCCESS(ntStatus) && detectedFmSynth)
{
ntStatus =
PcNewResourceSublist
(
ResourceListFmSynth,
NULL,
PagedPool,
ResourceList,
1
);
if (NT_SUCCESS(ntStatus))
{
SUCCEEDS((*ResourceListFmSynth)->
AddMemoryFromParent(ResourceList,detectedUart ? 2 : 1));
}
}
//
// Build list of resources for the adapter.
//
*ResourceListAdapter = NULL;
if (NT_SUCCESS(ntStatus))
{
ntStatus =
PcNewResourceSublist
(
ResourceListAdapter,
NULL,
PagedPool,
ResourceList,
3
);
if (NT_SUCCESS(ntStatus))
{
//
// The interrupt to share.
//
SUCCEEDS((*ResourceListAdapter)->
AddInterruptFromParent(ResourceList,0));
//
// The base IO port (to tell who's interrupt it is)
//
SUCCEEDS((*ResourceListAdapter)->
AddMemoryFromParent(ResourceList,0));
if (detectedUart)
{
//
// The Uart port
//
SUCCEEDS((*ResourceListAdapter)->
AddMemoryFromParent(ResourceList,1));
}
}
}
//
// Clean up if failure occurred.
//
if (! NT_SUCCESS(ntStatus))
{
if (*ResourceListWave)
{
(*ResourceListWave)->Release();
*ResourceListWave = NULL;
}
if (*ResourceListWaveTable)
{
(*ResourceListWaveTable)->Release();
*ResourceListWaveTable = NULL;
}
if (*ResourceListUart)
{
(*ResourceListUart)->Release();
*ResourceListUart = NULL;
}
if (*ResourceListFmSynth)
{
(*ResourceListFmSynth)->Release();
*ResourceListFmSynth = NULL;
}
if(*ResourceListAdapter)
{
(*ResourceListAdapter)->Release();
*ResourceListAdapter = NULL;
}
}
return ntStatus;
}
#ifdef DO_RESOURCE_FILTERING
#pragma code_seg("PAGE")
/*****************************************************************************
* AdapterDispatchPnp()
*****************************************************************************
* Supplying your PnP resource filtering needs.
*/
extern "C"
NTSTATUS
AdapterDispatchPnp
(
IN PDEVICE_OBJECT pDeviceObject,
IN PIRP pIrp
)
{
PAGED_CODE();
ASSERT(pDeviceObject);
ASSERT(pIrp);
NTSTATUS ntStatus = STATUS_SUCCESS;
PIO_STACK_LOCATION pIrpStack =
IoGetCurrentIrpStackLocation(pIrp);
if( pIrpStack->MinorFunction == IRP_MN_FILTER_RESOURCE_REQUIREMENTS )
{
//
// Do your resource requirements filtering here!!
//
_DbgPrintF(DEBUGLVL_VERBOSE,("[AdapterDispatchPnp] - IRP_MN_FILTER_RESOURCE_REQUIREMENTS"));
// set the return status
pIrp->IoStatus.Status = ntStatus;
}
//
// Pass the IRPs on to PortCls
//
ntStatus = PcDispatchIrp( pDeviceObject,
pIrp );
return ntStatus;
}
#endif
#pragma code_seg()
/*****************************************************************************
* _purecall()
*****************************************************************************
* The C++ compiler loves me.
* TODO: Figure out how to put this into portcls.sys
*/
int __cdecl
_purecall( void )
{
ASSERT( !"Pure virtual function called" );
return 0;
}