3ce937ba57d530e683c1b2cc9193527509a4111e
[reactos.git] / reactos / drivers / bus / pcix / pci.h
1 /*
2 * PROJECT: ReactOS PCI Bus Driver
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: drivers/bus/pci/pci.h
5 * PURPOSE: Main Header File
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9 #include <initguid.h>
10 #include <ntifs.h>
11 #include <ntagp.h>
12 #include <wdmguid.h>
13 #include <wchar.h>
14 #include <acpiioct.h>
15 #include <drivers/pci/pci.h>
16 #include <drivers/acpi/acpi.h>
17 #include "halfuncs.h"
18 #include "rtlfuncs.h"
19 #include "vffuncs.h"
20 #include "bugcodes.h"
21
22 //
23 // Tag used in all pool allocations (Pci Bus)
24 //
25 #define PCI_POOL_TAG 'BicP'
26
27 //
28 // Checks if the specified FDO is the FDO for the Root PCI Bus
29 //
30 #define PCI_IS_ROOT_FDO(x) ((x)->BusRootFdoExtension == x)
31
32 //
33 // Assertions to make sure we are dealing with the right kind of extension
34 //
35 #define ASSERT_FDO(x) ASSERT((x)->ExtensionType == PciFdoExtensionType);
36 #define ASSERT_PDO(x) ASSERT((x)->ExtensionType == PciPdoExtensionType);
37
38 //
39 // PCI Hack Entry Name Lengths
40 //
41 #define PCI_HACK_ENTRY_SIZE sizeof(L"VVVVdddd") - sizeof(UNICODE_NULL)
42 #define PCI_HACK_ENTRY_REV_SIZE sizeof(L"VVVVddddRR") - sizeof(UNICODE_NULL)
43 #define PCI_HACK_ENTRY_SUBSYS_SIZE sizeof(L"VVVVddddssssIIII") - sizeof(UNICODE_NULL)
44 #define PCI_HACK_ENTRY_FULL_SIZE sizeof(L"VVVVddddssssIIIIRR") - sizeof(UNICODE_NULL)
45
46 //
47 // PCI Hack Entry Flags
48 //
49 #define PCI_HACK_HAS_REVISION_INFO 0x01
50 #define PCI_HACK_HAS_SUBSYSTEM_INFO 0x02
51
52 //
53 // PCI Interface Flags
54 //
55 #define PCI_INTERFACE_PDO 0x01
56 #define PCI_INTERFACE_FDO 0x02
57 #define PCI_INTERFACE_ROOT 0x04
58
59 //
60 // PCI Skip Function Flags
61 //
62 #define PCI_SKIP_DEVICE_ENUMERATION 0x01
63 #define PCI_SKIP_RESOURCE_ENUMERATION 0x02
64
65 //
66 // PCI Apply Hack Flags
67 //
68 #define PCI_HACK_FIXUP_BEFORE_CONFIGURATION 0x00
69 #define PCI_HACK_FIXUP_AFTER_CONFIGURATION 0x01
70 #define PCI_HACK_FIXUP_BEFORE_UPDATE 0x03
71
72 //
73 // PCI Debugging Device Support
74 //
75 #define MAX_DEBUGGING_DEVICES_SUPPORTED 0x04
76
77 //
78 // PCI Driver Verifier Failures
79 //
80 #define PCI_VERIFIER_CODES 0x04
81
82 //
83 // Device Extension, Interface, Translator and Arbiter Signatures
84 //
85 typedef enum _PCI_SIGNATURE
86 {
87 PciPdoExtensionType = 'icP0',
88 PciFdoExtensionType = 'icP1',
89 PciArb_Io = 'icP2',
90 PciArb_Memory = 'icP3',
91 PciArb_Interrupt = 'icP4',
92 PciArb_BusNumber = 'icP5',
93 PciTrans_Interrupt = 'icP6',
94 PciInterface_BusHandler = 'icP7',
95 PciInterface_IntRouteHandler = 'icP8',
96 PciInterface_PciCb = 'icP9',
97 PciInterface_LegacyDeviceDetection = 'icP:',
98 PciInterface_PmeHandler = 'icP;',
99 PciInterface_DevicePresent = 'icP<',
100 PciInterface_NativeIde = 'icP=',
101 PciInterface_AgpTarget = 'icP>',
102 PciInterface_Location = 'icP?'
103 } PCI_SIGNATURE, *PPCI_SIGNATURE;
104
105 //
106 // Device Extension Logic States
107 //
108 typedef enum _PCI_STATE
109 {
110 PciNotStarted,
111 PciStarted,
112 PciDeleted,
113 PciStopped,
114 PciSurpriseRemoved,
115 PciSynchronizedOperation,
116 PciMaxObjectState
117 } PCI_STATE;
118
119 //
120 // IRP Dispatch Logic Style
121 //
122 typedef enum _PCI_DISPATCH_STYLE
123 {
124 IRP_COMPLETE,
125 IRP_DOWNWARD,
126 IRP_UPWARD,
127 IRP_DISPATCH,
128 } PCI_DISPATCH_STYLE;
129
130 //
131 // PCI Hack Entry Information
132 //
133 typedef struct _PCI_HACK_ENTRY
134 {
135 USHORT VendorID;
136 USHORT DeviceID;
137 USHORT SubVendorID;
138 USHORT SubSystemID;
139 ULONGLONG HackFlags;
140 USHORT RevisionID;
141 UCHAR Flags;
142 } PCI_HACK_ENTRY, *PPCI_HACK_ENTRY;
143
144 //
145 // Power State Information for Device Extension
146 //
147 typedef struct _PCI_POWER_STATE
148 {
149 SYSTEM_POWER_STATE CurrentSystemState;
150 DEVICE_POWER_STATE CurrentDeviceState;
151 SYSTEM_POWER_STATE SystemWakeLevel;
152 DEVICE_POWER_STATE DeviceWakeLevel;
153 DEVICE_POWER_STATE SystemStateMapping[7];
154 PIRP WaitWakeIrp;
155 PVOID SavedCancelRoutine;
156 LONG Paging;
157 LONG Hibernate;
158 LONG CrashDump;
159 } PCI_POWER_STATE, *PPCI_POWER_STATE;
160
161 //
162 // Internal PCI Lock Structure
163 //
164 typedef struct _PCI_LOCK
165 {
166 LONG Atom;
167 BOOLEAN OldIrql;
168 } PCI_LOCK, *PPCI_LOCK;
169
170 //
171 // Device Extension for a Bus FDO
172 //
173 typedef struct _PCI_FDO_EXTENSION
174 {
175 SINGLE_LIST_ENTRY List;
176 ULONG ExtensionType;
177 struct _PCI_MJ_DISPATCH_TABLE *IrpDispatchTable;
178 BOOLEAN DeviceState;
179 BOOLEAN TentativeNextState;
180 KEVENT SecondaryExtLock;
181 PDEVICE_OBJECT PhysicalDeviceObject;
182 PDEVICE_OBJECT FunctionalDeviceObject;
183 PDEVICE_OBJECT AttachedDeviceObject;
184 KEVENT ChildListLock;
185 struct _PCI_PDO_EXTENSION *ChildPdoList;
186 struct _PCI_FDO_EXTENSION *BusRootFdoExtension;
187 struct _PCI_FDO_EXTENSION *ParentFdoExtension;
188 struct _PCI_PDO_EXTENSION *ChildBridgePdoList;
189 PPCI_BUS_INTERFACE_STANDARD PciBusInterface;
190 BOOLEAN MaxSubordinateBus;
191 BUS_HANDLER *BusHandler;
192 BOOLEAN BaseBus;
193 BOOLEAN Fake;
194 BOOLEAN ChildDelete;
195 BOOLEAN Scanned;
196 BOOLEAN ArbitersInitialized;
197 BOOLEAN BrokenVideoHackApplied;
198 BOOLEAN Hibernated;
199 PCI_POWER_STATE PowerState;
200 SINGLE_LIST_ENTRY SecondaryExtension;
201 LONG ChildWaitWakeCount;
202 PPCI_COMMON_CONFIG PreservedConfig;
203 PCI_LOCK Lock;
204 struct
205 {
206 BOOLEAN Acquired;
207 BOOLEAN CacheLineSize;
208 BOOLEAN LatencyTimer;
209 BOOLEAN EnablePERR;
210 BOOLEAN EnableSERR;
211 } HotPlugParameters;
212 LONG BusHackFlags;
213 } PCI_FDO_EXTENSION, *PPCI_FDO_EXTENSION;
214
215 typedef struct _PCI_FUNCTION_RESOURCES
216 {
217 IO_RESOURCE_DESCRIPTOR Limit[7];
218 CM_PARTIAL_RESOURCE_DESCRIPTOR Current[7];
219 } PCI_FUNCTION_RESOURCES, *PPCI_FUNCTION_RESOURCES;
220
221 typedef union _PCI_HEADER_TYPE_DEPENDENT
222 {
223 struct
224 {
225 UCHAR Spare[4];
226 } type0;
227 struct
228 {
229 UCHAR PrimaryBus;
230 UCHAR SecondaryBus;
231 UCHAR SubordinateBus;
232 UCHAR SubtractiveDecode:1;
233 UCHAR IsaBitSet:1;
234 UCHAR VgaBitSet:1;
235 UCHAR WeChangedBusNumbers:1;
236 UCHAR IsaBitRequired:1;
237 } type1;
238 struct
239 {
240 UCHAR Spare[4];
241 } type2;
242 } PCI_HEADER_TYPE_DEPENDENT, *PPCI_HEADER_TYPE_DEPENDENT;
243
244 typedef struct _PCI_PDO_EXTENSION
245 {
246 PVOID Next;
247 ULONG ExtensionType;
248 struct _PCI_MJ_DISPATCH_TABLE *IrpDispatchTable;
249 BOOLEAN DeviceState;
250 BOOLEAN TentativeNextState;
251
252 KEVENT SecondaryExtLock;
253 PCI_SLOT_NUMBER Slot;
254 PDEVICE_OBJECT PhysicalDeviceObject;
255 PPCI_FDO_EXTENSION ParentFdoExtension;
256 SINGLE_LIST_ENTRY SecondaryExtension;
257 LONG BusInterfaceReferenceCount;
258 LONG AgpInterfaceReferenceCount;
259 USHORT VendorId;
260 USHORT DeviceId;
261 USHORT SubsystemVendorId;
262 USHORT SubsystemId;
263 BOOLEAN RevisionId;
264 BOOLEAN ProgIf;
265 BOOLEAN SubClass;
266 BOOLEAN BaseClass;
267 BOOLEAN AdditionalResourceCount;
268 BOOLEAN AdjustedInterruptLine;
269 BOOLEAN InterruptPin;
270 BOOLEAN RawInterruptLine;
271 BOOLEAN CapabilitiesPtr;
272 BOOLEAN SavedLatencyTimer;
273 BOOLEAN SavedCacheLineSize;
274 BOOLEAN HeaderType;
275 BOOLEAN NotPresent;
276 BOOLEAN ReportedMissing;
277 BOOLEAN ExpectedWritebackFailure;
278 BOOLEAN NoTouchPmeEnable;
279 BOOLEAN LegacyDriver;
280 BOOLEAN UpdateHardware;
281 BOOLEAN MovedDevice;
282 BOOLEAN DisablePowerDown;
283 BOOLEAN NeedsHotPlugConfiguration;
284 BOOLEAN SwitchedIDEToNativeMode;
285 BOOLEAN BIOSAllowsIDESwitchToNativeMode;
286 BOOLEAN IoSpaceUnderNativeIdeControl;
287 BOOLEAN OnDebugPath;
288 PCI_POWER_STATE PowerState;
289 PCI_HEADER_TYPE_DEPENDENT Dependent;
290 ULONGLONG HackFlags;
291 PCI_FUNCTION_RESOURCES *Resources;
292 PCI_FDO_EXTENSION *BridgeFdoExtension;
293 struct _PCI_PDO_EXTENSION *NextBridge;
294 struct _PCI_PDO_EXTENSION *NextHashEntry;
295 PCI_LOCK Lock;
296 PCI_PMC PowerCapabilities;
297 BOOLEAN TargetAgpCapabilityId;
298 USHORT CommandEnables;
299 USHORT InitialCommand;
300 } PCI_PDO_EXTENSION, *PPCI_PDO_EXTENSION;
301
302 //
303 // IRP Dispatch Function Type
304 //
305 typedef NTSTATUS (NTAPI *PCI_DISPATCH_FUNCTION)(
306 IN PIRP Irp,
307 IN PIO_STACK_LOCATION IoStackLocation,
308 IN PVOID DeviceExtension
309 );
310
311 //
312 // IRP Dispatch Minor Table
313 //
314 typedef struct _PCI_MN_DISPATCH_TABLE
315 {
316 PCI_DISPATCH_STYLE DispatchStyle;
317 PCI_DISPATCH_FUNCTION DispatchFunction;
318 } PCI_MN_DISPATCH_TABLE, *PPCI_MN_DISPATCH_TABLE;
319
320 //
321 // IRP Dispatch Major Table
322 //
323 typedef struct _PCI_MJ_DISPATCH_TABLE
324 {
325 ULONG PnpIrpMaximumMinorFunction;
326 PPCI_MN_DISPATCH_TABLE PnpIrpDispatchTable;
327 ULONG PowerIrpMaximumMinorFunction;
328 PPCI_MN_DISPATCH_TABLE PowerIrpDispatchTable;
329 PCI_DISPATCH_STYLE SystemControlIrpDispatchStyle;
330 PCI_DISPATCH_FUNCTION SystemControlIrpDispatchFunction;
331 PCI_DISPATCH_STYLE OtherIrpDispatchStyle;
332 PCI_DISPATCH_FUNCTION OtherIrpDispatchFunction;
333 } PCI_MJ_DISPATCH_TABLE, *PPCI_MJ_DISPATCH_TABLE;
334
335 //
336 // Generic PCI Interface Constructor and Initializer
337 //
338 struct _PCI_INTERFACE;
339 typedef NTSTATUS (NTAPI *PCI_INTERFACE_CONSTRUCTOR)(
340 IN PVOID DeviceExtension,
341 IN PVOID Instance,
342 IN PVOID InterfaceData,
343 IN USHORT Version,
344 IN USHORT Size,
345 IN PINTERFACE Interface
346 );
347
348 typedef NTSTATUS (NTAPI *PCI_INTERFACE_INITIALIZER)(
349 IN PVOID Instance
350 );
351
352 //
353 // Generic PCI Interface (Interface, Translator, Arbiter)
354 //
355 typedef struct _PCI_INTERFACE
356 {
357 CONST GUID *InterfaceType;
358 USHORT MinSize;
359 USHORT MinVersion;
360 USHORT MaxVersion;
361 USHORT Flags;
362 LONG ReferenceCount;
363 PCI_SIGNATURE Signature;
364 PCI_INTERFACE_CONSTRUCTOR Constructor;
365 PCI_INTERFACE_INITIALIZER Initializer;
366 } PCI_INTERFACE, *PPCI_INTERFACE;
367
368 //
369 // Generic Secondary Extension Instance Header (Interface, Translator, Arbiter)
370 //
371 typedef struct PCI_SECONDARY_EXTENSION
372 {
373 SINGLE_LIST_ENTRY List;
374 PCI_SIGNATURE ExtensionType;
375 PVOID Destructor;
376 } PCI_SECONDARY_EXTENSION, *PPCI_SECONDARY_EXTENSION;
377
378 //
379 // PCI Arbiter Instance
380 //
381 typedef struct PCI_ARBITER_INSTANCE
382 {
383 PCI_SECONDARY_EXTENSION Header;
384 PPCI_INTERFACE Interface;
385 PPCI_FDO_EXTENSION BusFdoExtension;
386 WCHAR InstanceName[24];
387 //ARBITER_INSTANCE CommonInstance; FIXME: Need Arbiter Headers
388 } PCI_ARBITER_INSTANCE, *PPCI_ARBITER_INSTANCE;
389
390 //
391 // PCI Verifier Data
392 //
393 typedef struct _PCI_VERIFIER_DATA
394 {
395 ULONG FailureCode;
396 VF_FAILURE_CLASS FailureClass;
397 ULONG AssertionControl;
398 PCHAR DebuggerMessageText;
399 } PCI_VERIFIER_DATA, *PPCI_VERIFIER_DATA;
400
401 //
402 // IRP Dispatch Routines
403 //
404 NTSTATUS
405 NTAPI
406 PciDispatchIrp(
407 IN PDEVICE_OBJECT DeviceObject,
408 IN PIRP Irp
409 );
410
411 NTSTATUS
412 NTAPI
413 PciIrpNotSupported(
414 IN PIRP Irp,
415 IN PIO_STACK_LOCATION IoStackLocation,
416 IN PPCI_FDO_EXTENSION DeviceExtension
417 );
418
419 NTSTATUS
420 NTAPI
421 PciPassIrpFromFdoToPdo(
422 IN PPCI_FDO_EXTENSION DeviceExtension,
423 IN PIRP Irp
424 );
425
426 NTSTATUS
427 NTAPI
428 PciCallDownIrpStack(
429 IN PPCI_FDO_EXTENSION DeviceExtension,
430 IN PIRP Irp
431 );
432
433 NTSTATUS
434 NTAPI
435 PciIrpInvalidDeviceRequest(
436 IN PIRP Irp,
437 IN PIO_STACK_LOCATION IoStackLocation,
438 IN PPCI_FDO_EXTENSION DeviceExtension
439 );
440
441 //
442 // Power Routines
443 //
444 NTSTATUS
445 NTAPI
446 PciFdoWaitWake(
447 IN PIRP Irp,
448 IN PIO_STACK_LOCATION IoStackLocation,
449 IN PPCI_FDO_EXTENSION DeviceExtension
450 );
451
452 NTSTATUS
453 NTAPI
454 PciFdoSetPowerState(
455 IN PIRP Irp,
456 IN PIO_STACK_LOCATION IoStackLocation,
457 IN PPCI_FDO_EXTENSION DeviceExtension
458 );
459
460 NTSTATUS
461 NTAPI
462 PciFdoIrpQueryPower(
463 IN PIRP Irp,
464 IN PIO_STACK_LOCATION IoStackLocation,
465 IN PPCI_FDO_EXTENSION DeviceExtension
466 );
467
468 NTSTATUS
469 NTAPI
470 PciSetPowerManagedDevicePowerState(
471 IN PPCI_PDO_EXTENSION DeviceExtension,
472 IN DEVICE_POWER_STATE DeviceState,
473 IN BOOLEAN IrpSet
474 );
475
476 //
477 // Bus FDO Routines
478 //
479 NTSTATUS
480 NTAPI
481 PciAddDevice(
482 IN PDRIVER_OBJECT DriverObject,
483 IN PDEVICE_OBJECT PhysicalDeviceObject
484 );
485
486 NTSTATUS
487 NTAPI
488 PciFdoIrpStartDevice(
489 IN PIRP Irp,
490 IN PIO_STACK_LOCATION IoStackLocation,
491 IN PPCI_FDO_EXTENSION DeviceExtension
492 );
493
494 NTSTATUS
495 NTAPI
496 PciFdoIrpQueryRemoveDevice(
497 IN PIRP Irp,
498 IN PIO_STACK_LOCATION IoStackLocation,
499 IN PPCI_FDO_EXTENSION DeviceExtension
500 );
501
502 NTSTATUS
503 NTAPI
504 PciFdoIrpRemoveDevice(
505 IN PIRP Irp,
506 IN PIO_STACK_LOCATION IoStackLocation,
507 IN PPCI_FDO_EXTENSION DeviceExtension
508 );
509
510 NTSTATUS
511 NTAPI
512 PciFdoIrpCancelRemoveDevice(
513 IN PIRP Irp,
514 IN PIO_STACK_LOCATION IoStackLocation,
515 IN PPCI_FDO_EXTENSION DeviceExtension
516 );
517
518 NTSTATUS
519 NTAPI
520 PciFdoIrpStopDevice(
521 IN PIRP Irp,
522 IN PIO_STACK_LOCATION IoStackLocation,
523 IN PPCI_FDO_EXTENSION DeviceExtension
524 );
525
526 NTSTATUS
527 NTAPI
528 PciFdoIrpQueryStopDevice(
529 IN PIRP Irp,
530 IN PIO_STACK_LOCATION IoStackLocation,
531 IN PPCI_FDO_EXTENSION DeviceExtension
532 );
533
534 NTSTATUS
535 NTAPI
536 PciFdoIrpCancelStopDevice(
537 IN PIRP Irp,
538 IN PIO_STACK_LOCATION IoStackLocation,
539 IN PPCI_FDO_EXTENSION DeviceExtension
540 );
541
542 NTSTATUS
543 NTAPI
544 PciFdoIrpQueryDeviceRelations(
545 IN PIRP Irp,
546 IN PIO_STACK_LOCATION IoStackLocation,
547 IN PPCI_FDO_EXTENSION DeviceExtension
548 );
549
550 NTSTATUS
551 NTAPI
552 PciFdoIrpQueryInterface(
553 IN PIRP Irp,
554 IN PIO_STACK_LOCATION IoStackLocation,
555 IN PPCI_FDO_EXTENSION DeviceExtension
556 );
557
558 NTSTATUS
559 NTAPI
560 PciFdoIrpQueryCapabilities(
561 IN PIRP Irp,
562 IN PIO_STACK_LOCATION IoStackLocation,
563 IN PPCI_FDO_EXTENSION DeviceExtension
564 );
565
566 NTSTATUS
567 NTAPI
568 PciFdoIrpDeviceUsageNotification(
569 IN PIRP Irp,
570 IN PIO_STACK_LOCATION IoStackLocation,
571 IN PPCI_FDO_EXTENSION DeviceExtension
572 );
573
574 NTSTATUS
575 NTAPI
576 PciFdoIrpSurpriseRemoval(
577 IN PIRP Irp,
578 IN PIO_STACK_LOCATION IoStackLocation,
579 IN PPCI_FDO_EXTENSION DeviceExtension
580 );
581
582 NTSTATUS
583 NTAPI
584 PciFdoIrpQueryLegacyBusInformation(
585 IN PIRP Irp,
586 IN PIO_STACK_LOCATION IoStackLocation,
587 IN PPCI_FDO_EXTENSION DeviceExtension
588 );
589
590 //
591 // Device PDO Routines
592 //
593 NTSTATUS
594 NTAPI
595 PciPdoCreate(
596 IN PPCI_FDO_EXTENSION DeviceExtension,
597 IN PCI_SLOT_NUMBER Slot,
598 OUT PDEVICE_OBJECT *PdoDeviceObject
599 );
600
601 NTSTATUS
602 NTAPI
603 PciPdoWaitWake(
604 IN PIRP Irp,
605 IN PIO_STACK_LOCATION IoStackLocation,
606 IN PPCI_PDO_EXTENSION DeviceExtension
607 );
608
609 NTSTATUS
610 NTAPI
611 PciPdoSetPowerState(
612 IN PIRP Irp,
613 IN PIO_STACK_LOCATION IoStackLocation,
614 IN PPCI_PDO_EXTENSION DeviceExtension
615 );
616
617 NTSTATUS
618 NTAPI
619 PciPdoIrpQueryPower(
620 IN PIRP Irp,
621 IN PIO_STACK_LOCATION IoStackLocation,
622 IN PPCI_PDO_EXTENSION DeviceExtension
623 );
624
625 NTSTATUS
626 NTAPI
627 PciPdoIrpStartDevice(
628 IN PIRP Irp,
629 IN PIO_STACK_LOCATION IoStackLocation,
630 IN PPCI_PDO_EXTENSION DeviceExtension
631 );
632
633 NTSTATUS
634 NTAPI
635 PciPdoIrpQueryRemoveDevice(
636 IN PIRP Irp,
637 IN PIO_STACK_LOCATION IoStackLocation,
638 IN PPCI_PDO_EXTENSION DeviceExtension
639 );
640
641 NTSTATUS
642 NTAPI
643 PciPdoIrpRemoveDevice(
644 IN PIRP Irp,
645 IN PIO_STACK_LOCATION IoStackLocation,
646 IN PPCI_PDO_EXTENSION DeviceExtension
647 );
648
649 NTSTATUS
650 NTAPI
651 PciPdoIrpCancelRemoveDevice(
652 IN PIRP Irp,
653 IN PIO_STACK_LOCATION IoStackLocation,
654 IN PPCI_PDO_EXTENSION DeviceExtension
655 );
656
657 NTSTATUS
658 NTAPI
659 PciPdoIrpStopDevice(
660 IN PIRP Irp,
661 IN PIO_STACK_LOCATION IoStackLocation,
662 IN PPCI_PDO_EXTENSION DeviceExtension
663 );
664
665 NTSTATUS
666 NTAPI
667 PciPdoIrpQueryStopDevice(
668 IN PIRP Irp,
669 IN PIO_STACK_LOCATION IoStackLocation,
670 IN PPCI_PDO_EXTENSION DeviceExtension
671 );
672
673 NTSTATUS
674 NTAPI
675 PciPdoIrpCancelStopDevice(
676 IN PIRP Irp,
677 IN PIO_STACK_LOCATION IoStackLocation,
678 IN PPCI_PDO_EXTENSION DeviceExtension
679 );
680
681 NTSTATUS
682 NTAPI
683 PciPdoIrpQueryDeviceRelations(
684 IN PIRP Irp,
685 IN PIO_STACK_LOCATION IoStackLocation,
686 IN PPCI_PDO_EXTENSION DeviceExtension
687 );
688
689 NTSTATUS
690 NTAPI
691 PciPdoIrpQueryInterface(
692 IN PIRP Irp,
693 IN PIO_STACK_LOCATION IoStackLocation,
694 IN PPCI_PDO_EXTENSION DeviceExtension
695 );
696
697 NTSTATUS
698 NTAPI
699 PciPdoIrpQueryCapabilities(
700 IN PIRP Irp,
701 IN PIO_STACK_LOCATION IoStackLocation,
702 IN PPCI_PDO_EXTENSION DeviceExtension
703 );
704
705 NTSTATUS
706 NTAPI
707 PciPdoIrpQueryResources(
708 IN PIRP Irp,
709 IN PIO_STACK_LOCATION IoStackLocation,
710 IN PPCI_PDO_EXTENSION DeviceExtension
711 );
712
713 NTSTATUS
714 NTAPI
715 PciPdoIrpQueryResourceRequirements(
716 IN PIRP Irp,
717 IN PIO_STACK_LOCATION IoStackLocation,
718 IN PPCI_PDO_EXTENSION DeviceExtension
719 );
720
721 NTSTATUS
722 NTAPI
723 PciPdoIrpQueryDeviceText(
724 IN PIRP Irp,
725 IN PIO_STACK_LOCATION IoStackLocation,
726 IN PPCI_PDO_EXTENSION DeviceExtension
727 );
728
729 NTSTATUS
730 NTAPI
731 PciPdoIrpReadConfig(
732 IN PIRP Irp,
733 IN PIO_STACK_LOCATION IoStackLocation,
734 IN PPCI_PDO_EXTENSION DeviceExtension
735 );
736
737 NTSTATUS
738 NTAPI
739 PciPdoIrpWriteConfig(
740 IN PIRP Irp,
741 IN PIO_STACK_LOCATION IoStackLocation,
742 IN PPCI_PDO_EXTENSION DeviceExtension
743 );
744
745 NTSTATUS
746 NTAPI
747 PciPdoIrpQueryId(
748 IN PIRP Irp,
749 IN PIO_STACK_LOCATION IoStackLocation,
750 IN PPCI_PDO_EXTENSION DeviceExtension
751 );
752
753 NTSTATUS
754 NTAPI
755 PciPdoIrpQueryDeviceState(
756 IN PIRP Irp,
757 IN PIO_STACK_LOCATION IoStackLocation,
758 IN PPCI_PDO_EXTENSION DeviceExtension
759 );
760
761 NTSTATUS
762 NTAPI
763 PciPdoIrpQueryBusInformation(
764 IN PIRP Irp,
765 IN PIO_STACK_LOCATION IoStackLocation,
766 IN PPCI_PDO_EXTENSION DeviceExtension
767 );
768
769 NTSTATUS
770 NTAPI
771 PciPdoIrpDeviceUsageNotification(
772 IN PIRP Irp,
773 IN PIO_STACK_LOCATION IoStackLocation,
774 IN PPCI_PDO_EXTENSION DeviceExtension
775 );
776
777 NTSTATUS
778 NTAPI
779 PciPdoIrpSurpriseRemoval(
780 IN PIRP Irp,
781 IN PIO_STACK_LOCATION IoStackLocation,
782 IN PPCI_PDO_EXTENSION DeviceExtension
783 );
784
785 NTSTATUS
786 NTAPI
787 PciPdoIrpQueryLegacyBusInformation(
788 IN PIRP Irp,
789 IN PIO_STACK_LOCATION IoStackLocation,
790 IN PPCI_PDO_EXTENSION DeviceExtension
791 );
792
793
794 //
795 // HAL Callback/Hook Routines
796 //
797 VOID
798 NTAPI
799 PciHookHal(
800 VOID
801 );
802
803 //
804 // PCI Verifier Routines
805 //
806 VOID
807 NTAPI
808 PciVerifierInit(
809 IN PDRIVER_OBJECT DriverObject
810 );
811
812 PPCI_VERIFIER_DATA
813 NTAPI
814 PciVerifierRetrieveFailureData(
815 IN ULONG FailureCode
816 );
817
818 //
819 // Utility Routines
820 //
821 BOOLEAN
822 NTAPI
823 PciStringToUSHORT(
824 IN PWCHAR String,
825 OUT PUSHORT Value
826 );
827
828 BOOLEAN
829 NTAPI
830 PciIsDatacenter(
831 VOID
832 );
833
834 NTSTATUS
835 NTAPI
836 PciBuildDefaultExclusionLists(
837 VOID
838 );
839
840 BOOLEAN
841 NTAPI
842 PciUnicodeStringStrStr(
843 IN PUNICODE_STRING InputString,
844 IN PCUNICODE_STRING EqualString,
845 IN BOOLEAN CaseInSensitive
846 );
847
848 BOOLEAN
849 NTAPI
850 PciOpenKey(
851 IN PWCHAR KeyName,
852 IN HANDLE RootKey,
853 IN ACCESS_MASK DesiredAccess,
854 OUT PHANDLE KeyHandle,
855 OUT PNTSTATUS KeyStatus
856 );
857
858 NTSTATUS
859 NTAPI
860 PciGetRegistryValue(
861 IN PWCHAR ValueName,
862 IN PWCHAR KeyName,
863 IN HANDLE RootHandle,
864 IN ULONG Type,
865 OUT PVOID *OutputBuffer,
866 OUT PULONG OutputLength
867 );
868
869 PPCI_FDO_EXTENSION
870 NTAPI
871 PciFindParentPciFdoExtension(
872 IN PDEVICE_OBJECT DeviceObject,
873 IN PKEVENT Lock
874 );
875
876 VOID
877 NTAPI
878 PciInsertEntryAtTail(
879 IN PSINGLE_LIST_ENTRY ListHead,
880 IN PPCI_FDO_EXTENSION DeviceExtension,
881 IN PKEVENT Lock
882 );
883
884 NTSTATUS
885 NTAPI
886 PciGetDeviceProperty(
887 IN PDEVICE_OBJECT DeviceObject,
888 IN DEVICE_REGISTRY_PROPERTY DeviceProperty,
889 OUT PVOID *OutputBuffer
890 );
891
892 NTSTATUS
893 NTAPI
894 PciSendIoctl(
895 IN PDEVICE_OBJECT DeviceObject,
896 IN ULONG IoControlCode,
897 IN PVOID InputBuffer,
898 IN ULONG InputBufferLength,
899 IN PVOID OutputBuffer,
900 IN ULONG OutputBufferLength
901 );
902
903 VOID
904 NTAPI
905 PcipLinkSecondaryExtension(
906 IN PSINGLE_LIST_ENTRY List,
907 IN PVOID Lock,
908 IN PPCI_SECONDARY_EXTENSION SecondaryExtension,
909 IN PCI_SIGNATURE ExtensionType,
910 IN PVOID Destructor
911 );
912
913 PPCI_SECONDARY_EXTENSION
914 NTAPI
915 PciFindNextSecondaryExtension(
916 IN PSINGLE_LIST_ENTRY ListHead,
917 IN PCI_SIGNATURE ExtensionType
918 );
919
920 ULONGLONG
921 NTAPI
922 PciGetHackFlags(
923 IN USHORT VendorId,
924 IN USHORT DeviceId,
925 IN USHORT SubVendorId,
926 IN USHORT SubSystemId,
927 IN UCHAR RevisionId
928 );
929
930 PPCI_PDO_EXTENSION
931 NTAPI
932 PciFindPdoByFunction(
933 IN PPCI_FDO_EXTENSION DeviceExtension,
934 IN ULONG FunctionNumber,
935 IN PPCI_COMMON_HEADER PciData
936 );
937
938 BOOLEAN
939 NTAPI
940 PciIsCriticalDeviceClass(
941 IN UCHAR BaseClass,
942 IN UCHAR SubClass
943 );
944
945 BOOLEAN
946 NTAPI
947 PciIsDeviceOnDebugPath(
948 IN PPCI_PDO_EXTENSION DeviceExtension
949 );
950
951 NTSTATUS
952 NTAPI
953 PciGetBiosConfig(
954 IN PPCI_PDO_EXTENSION DeviceExtension,
955 OUT PPCI_COMMON_HEADER PciData
956 );
957
958 NTSTATUS
959 NTAPI
960 PciSaveBiosConfig(
961 IN PPCI_PDO_EXTENSION DeviceExtension,
962 OUT PPCI_COMMON_HEADER PciData
963 );
964
965 UCHAR
966 NTAPI
967 PciReadDeviceCapability(
968 IN PPCI_PDO_EXTENSION DeviceExtension,
969 IN UCHAR Offset,
970 IN ULONG CapabilityId,
971 OUT PPCI_CAPABILITIES_HEADER Buffer,
972 IN ULONG Length
973 );
974
975 BOOLEAN
976 NTAPI
977 PciCanDisableDecodes(
978 IN PPCI_PDO_EXTENSION DeviceExtension,
979 IN PPCI_COMMON_HEADER Config,
980 IN ULONGLONG HackFlags,
981 IN BOOLEAN ForPowerDown
982 );
983
984 BOOLEAN
985 NTAPI
986 PciIsSlotPresentInParentMethod(
987 IN PPCI_PDO_EXTENSION PdoExtension,
988 IN ULONG Method
989 );
990
991 VOID
992 NTAPI
993 PciDecodeEnable(
994 IN PPCI_PDO_EXTENSION PdoExtension,
995 IN BOOLEAN Enable,
996 OUT PUSHORT Command
997 );
998
999 //
1000 // Configuration Routines
1001 //
1002 NTSTATUS
1003 NTAPI
1004 PciGetConfigHandlers(
1005 IN PPCI_FDO_EXTENSION FdoExtension
1006 );
1007
1008 VOID
1009 NTAPI
1010 PciReadSlotConfig(
1011 IN PPCI_FDO_EXTENSION DeviceExtension,
1012 IN PCI_SLOT_NUMBER Slot,
1013 IN PVOID Buffer,
1014 IN ULONG Offset,
1015 IN ULONG Length
1016 );
1017
1018 VOID
1019 NTAPI
1020 PciWriteDeviceConfig(
1021 IN PPCI_PDO_EXTENSION DeviceExtension,
1022 IN PVOID Buffer,
1023 IN ULONG Offset,
1024 IN ULONG Length
1025 );
1026
1027 VOID
1028 NTAPI
1029 PciReadDeviceConfig(
1030 IN PPCI_PDO_EXTENSION DeviceExtension,
1031 IN PVOID Buffer,
1032 IN ULONG Offset,
1033 IN ULONG Length
1034 );
1035
1036 UCHAR
1037 NTAPI
1038 PciGetAdjustedInterruptLine(
1039 IN PPCI_PDO_EXTENSION PdoExtension
1040 );
1041
1042 //
1043 // State Machine Logic Transition Routines
1044 //
1045 VOID
1046 NTAPI
1047 PciInitializeState(
1048 IN PPCI_FDO_EXTENSION DeviceExtension
1049 );
1050
1051 NTSTATUS
1052 NTAPI
1053 PciBeginStateTransition(
1054 IN PPCI_FDO_EXTENSION DeviceExtension,
1055 IN PCI_STATE NewState
1056 );
1057
1058 NTSTATUS
1059 NTAPI
1060 PciCancelStateTransition(
1061 IN PPCI_FDO_EXTENSION DeviceExtension,
1062 IN PCI_STATE NewState
1063 );
1064
1065 VOID
1066 NTAPI
1067 PciCommitStateTransition(
1068 IN PPCI_FDO_EXTENSION DeviceExtension,
1069 IN PCI_STATE NewState
1070 );
1071
1072
1073 //
1074 // Arbiter Support
1075 //
1076 NTSTATUS
1077 NTAPI
1078 PciInitializeArbiters(
1079 IN PPCI_FDO_EXTENSION FdoExtension
1080 );
1081
1082 NTSTATUS
1083 NTAPI
1084 PciInitializeArbiterRanges(
1085 IN PPCI_FDO_EXTENSION DeviceExtension,
1086 IN PCM_RESOURCE_LIST Resources
1087 );
1088
1089 //
1090 // Debug Helpers
1091 //
1092 BOOLEAN
1093 NTAPI
1094 PciDebugIrpDispatchDisplay(
1095 IN PIO_STACK_LOCATION IoStackLocation,
1096 IN PPCI_FDO_EXTENSION DeviceExtension,
1097 IN USHORT MaxMinor
1098 );
1099
1100 VOID
1101 NTAPI
1102 PciDebugDumpCommonConfig(
1103 IN PPCI_COMMON_HEADER PciData
1104 );
1105
1106 //
1107 // Interface Support
1108 //
1109 NTSTATUS
1110 NTAPI
1111 PciQueryInterface(
1112 IN PPCI_FDO_EXTENSION DeviceExtension,
1113 IN CONST GUID* InterfaceType,
1114 IN ULONG Size,
1115 IN ULONG Version,
1116 IN PVOID InterfaceData,
1117 IN PINTERFACE Interface,
1118 IN BOOLEAN LastChance
1119 );
1120
1121 NTSTATUS
1122 NTAPI
1123 PciPmeInterfaceInitializer(
1124 IN PVOID Instance
1125 );
1126
1127 NTSTATUS
1128 NTAPI
1129 routeintrf_Initializer(
1130 IN PVOID Instance
1131 );
1132
1133 NTSTATUS
1134 NTAPI
1135 arbusno_Initializer(
1136 IN PVOID Instance
1137 );
1138
1139 NTSTATUS
1140 NTAPI
1141 agpintrf_Initializer(
1142 IN PVOID Instance
1143 );
1144
1145 NTSTATUS
1146 NTAPI
1147 tranirq_Initializer(
1148 IN PVOID Instance
1149 );
1150
1151 NTSTATUS
1152 NTAPI
1153 busintrf_Initializer(
1154 IN PVOID Instance
1155 );
1156
1157 NTSTATUS
1158 NTAPI
1159 armem_Initializer(
1160 IN PVOID Instance
1161 );
1162
1163 NTSTATUS
1164 NTAPI
1165 ario_Initializer(
1166 IN PVOID Instance
1167 );
1168
1169 NTSTATUS
1170 NTAPI
1171 locintrf_Initializer(
1172 IN PVOID Instance
1173 );
1174
1175 NTSTATUS
1176 NTAPI
1177 pcicbintrf_Initializer(
1178 IN PVOID Instance
1179 );
1180
1181 NTSTATUS
1182 NTAPI
1183 lddintrf_Initializer(
1184 IN PVOID Instance
1185 );
1186
1187 NTSTATUS
1188 NTAPI
1189 devpresent_Initializer(
1190 IN PVOID Instance
1191 );
1192
1193 NTSTATUS
1194 NTAPI
1195 agpintrf_Constructor(
1196 IN PVOID DeviceExtension,
1197 IN PVOID Instance,
1198 IN PVOID InterfaceData,
1199 IN USHORT Version,
1200 IN USHORT Size,
1201 IN PINTERFACE Interface
1202 );
1203
1204 NTSTATUS
1205 NTAPI
1206 arbusno_Constructor(
1207 IN PVOID DeviceExtension,
1208 IN PVOID Instance,
1209 IN PVOID InterfaceData,
1210 IN USHORT Version,
1211 IN USHORT Size,
1212 IN PINTERFACE Interface
1213 );
1214
1215 NTSTATUS
1216 NTAPI
1217 tranirq_Constructor(
1218 IN PVOID DeviceExtension,
1219 IN PVOID Instance,
1220 IN PVOID InterfaceData,
1221 IN USHORT Version,
1222 IN USHORT Size,
1223 IN PINTERFACE Interface
1224 );
1225
1226 NTSTATUS
1227 NTAPI
1228 armem_Constructor(
1229 IN PVOID DeviceExtension,
1230 IN PVOID Instance,
1231 IN PVOID InterfaceData,
1232 IN USHORT Version,
1233 IN USHORT Size,
1234 IN PINTERFACE Interface
1235 );
1236
1237 NTSTATUS
1238 NTAPI
1239 busintrf_Constructor(
1240 IN PVOID DeviceExtension,
1241 IN PVOID Instance,
1242 IN PVOID InterfaceData,
1243 IN USHORT Version,
1244 IN USHORT Size,
1245 IN PINTERFACE Interface
1246 );
1247
1248 NTSTATUS
1249 NTAPI
1250 ario_Constructor(
1251 IN PVOID DeviceExtension,
1252 IN PVOID Instance,
1253 IN PVOID InterfaceData,
1254 IN USHORT Version,
1255 IN USHORT Size,
1256 IN PINTERFACE Interface
1257 );
1258
1259 VOID
1260 NTAPI
1261 ario_ApplyBrokenVideoHack(
1262 IN PPCI_FDO_EXTENSION FdoExtension
1263 );
1264
1265 NTSTATUS
1266 NTAPI
1267 pcicbintrf_Constructor(
1268 IN PVOID DeviceExtension,
1269 IN PVOID Instance,
1270 IN PVOID InterfaceData,
1271 IN USHORT Version,
1272 IN USHORT Size,
1273 IN PINTERFACE Interface
1274 );
1275
1276 NTSTATUS
1277 NTAPI
1278 lddintrf_Constructor(
1279 IN PVOID DeviceExtension,
1280 IN PVOID Instance,
1281 IN PVOID InterfaceData,
1282 IN USHORT Version,
1283 IN USHORT Size,
1284 IN PINTERFACE Interface
1285 );
1286
1287 NTSTATUS
1288 NTAPI
1289 locintrf_Constructor(
1290 IN PVOID DeviceExtension,
1291 IN PVOID Instance,
1292 IN PVOID InterfaceData,
1293 IN USHORT Version,
1294 IN USHORT Size,
1295 IN PINTERFACE Interface
1296 );
1297
1298 NTSTATUS
1299 NTAPI
1300 PciPmeInterfaceConstructor(
1301 IN PVOID DeviceExtension,
1302 IN PVOID Instance,
1303 IN PVOID InterfaceData,
1304 IN USHORT Version,
1305 IN USHORT Size,
1306 IN PINTERFACE Interface
1307 );
1308
1309 NTSTATUS
1310 NTAPI
1311 routeintrf_Constructor(
1312 IN PVOID DeviceExtension,
1313 IN PVOID Instance,
1314 IN PVOID InterfaceData,
1315 IN USHORT Version,
1316 IN USHORT Size,
1317 IN PINTERFACE Interface
1318 );
1319
1320 NTSTATUS
1321 NTAPI
1322 devpresent_Constructor(
1323 IN PVOID DeviceExtension,
1324 IN PVOID Instance,
1325 IN PVOID InterfaceData,
1326 IN USHORT Version,
1327 IN USHORT Size,
1328 IN PINTERFACE Interface
1329 );
1330
1331 //
1332 // PCI Enumeration and Resources
1333 //
1334 NTSTATUS
1335 NTAPI
1336 PciQueryDeviceRelations(
1337 IN PPCI_FDO_EXTENSION DeviceExtension,
1338 IN OUT PDEVICE_RELATIONS *pDeviceRelations
1339 );
1340
1341 //
1342 // Identification Functions
1343 //
1344 PWCHAR
1345 NTAPI
1346 PciGetDeviceDescriptionMessage(
1347 IN UCHAR BaseClass,
1348 IN UCHAR SubClass
1349 );
1350
1351 //
1352 // External Resources
1353 //
1354 extern SINGLE_LIST_ENTRY PciFdoExtensionListHead;
1355 extern KEVENT PciGlobalLock;
1356 extern PPCI_INTERFACE PciInterfaces[];
1357 extern PCI_INTERFACE ArbiterInterfaceBusNumber;
1358 extern PCI_INTERFACE ArbiterInterfaceMemory;
1359 extern PCI_INTERFACE ArbiterInterfaceIo;
1360 extern PCI_INTERFACE BusHandlerInterface;
1361 extern PCI_INTERFACE PciRoutingInterface;
1362 extern PCI_INTERFACE PciCardbusPrivateInterface;
1363 extern PCI_INTERFACE PciLegacyDeviceDetectionInterface;
1364 extern PCI_INTERFACE PciPmeInterface;
1365 extern PCI_INTERFACE PciDevicePresentInterface;
1366 //extern PCI_INTERFACE PciNativeIdeInterface;
1367 extern PCI_INTERFACE PciLocationInterface;
1368 extern PCI_INTERFACE AgpTargetInterface;
1369 extern PCI_INTERFACE TranslatorInterfaceInterrupt;
1370 extern PDRIVER_OBJECT PciDriverObject;
1371 extern PWATCHDOG_TABLE WdTable;
1372 extern PPCI_HACK_ENTRY PciHackTable;
1373 extern BOOLEAN PciEnableNativeModeATA;
1374
1375 /* Exported by NTOS, should this go in the NDK? */
1376 extern NTSYSAPI BOOLEAN InitSafeBootMode;
1377
1378 /* EOF */