Synchronize with trunk revision 59781.
[reactos.git] / drivers / bus / pci / pci.h
1 #include <ntifs.h>
2 #include <wdmguid.h>
3 #include <stdio.h>
4 #include <ntddk.h>
5
6 #define TAG_PCI '0ICP'
7
8 typedef struct _PCI_DEVICE
9 {
10 // Entry on device list
11 LIST_ENTRY ListEntry;
12 // Physical Device Object of device
13 PDEVICE_OBJECT Pdo;
14 // PCI bus number
15 ULONG BusNumber;
16 // PCI slot number
17 PCI_SLOT_NUMBER SlotNumber;
18 // PCI configuration data
19 PCI_COMMON_CONFIG PciConfig;
20 // Enable memory space
21 BOOLEAN EnableMemorySpace;
22 // Enable I/O space
23 BOOLEAN EnableIoSpace;
24 // Enable bus master
25 BOOLEAN EnableBusMaster;
26 } PCI_DEVICE, *PPCI_DEVICE;
27
28
29 typedef enum {
30 dsStopped,
31 dsStarted,
32 dsPaused,
33 dsRemoved,
34 dsSurpriseRemoved
35 } PCI_DEVICE_STATE;
36
37
38 typedef struct _COMMON_DEVICE_EXTENSION
39 {
40 // Pointer to device object, this device extension is associated with
41 PDEVICE_OBJECT DeviceObject;
42 // Wether this device extension is for an FDO or PDO
43 BOOLEAN IsFDO;
44 // Wether the device is removed
45 BOOLEAN Removed;
46 // Current device power state for the device
47 DEVICE_POWER_STATE DevicePowerState;
48 } COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION;
49
50 /* Physical Device Object device extension for a child device */
51 typedef struct _PDO_DEVICE_EXTENSION
52 {
53 // Common device data
54 COMMON_DEVICE_EXTENSION Common;
55 // Functional device object
56 PDEVICE_OBJECT Fdo;
57 // Pointer to PCI Device informations
58 PPCI_DEVICE PciDevice;
59 // Device ID
60 UNICODE_STRING DeviceID;
61 // Instance ID
62 UNICODE_STRING InstanceID;
63 // Hardware IDs
64 UNICODE_STRING HardwareIDs;
65 // Compatible IDs
66 UNICODE_STRING CompatibleIDs;
67 // Textual description of device
68 UNICODE_STRING DeviceDescription;
69 // Textual description of device location
70 UNICODE_STRING DeviceLocation;
71 // Number of interfaces references
72 LONG References;
73 } PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
74
75 /* Functional Device Object device extension for the PCI driver device object */
76 typedef struct _FDO_DEVICE_EXTENSION
77 {
78 // Common device data
79 COMMON_DEVICE_EXTENSION Common;
80 // Entry on device list
81 LIST_ENTRY ListEntry;
82 // PCI bus number serviced by this FDO
83 ULONG BusNumber;
84 // Current state of the driver
85 PCI_DEVICE_STATE State;
86 // Namespace device list
87 LIST_ENTRY DeviceListHead;
88 // Number of (not removed) devices in device list
89 ULONG DeviceListCount;
90 // Lock for namespace device list
91 KSPIN_LOCK DeviceListLock;
92 // Lower device object
93 PDEVICE_OBJECT Ldo;
94 } FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION;
95
96
97 /* Driver extension associated with PCI driver */
98 typedef struct _PCI_DRIVER_EXTENSION
99 {
100 //
101 LIST_ENTRY BusListHead;
102 // Lock for namespace bus list
103 KSPIN_LOCK BusListLock;
104 } PCI_DRIVER_EXTENSION, *PPCI_DRIVER_EXTENSION;
105
106
107 /* We need a global variable to get the driver extension,
108 * because at least InterfacePciDevicePresent has no
109 * other way to get it... */
110 extern PPCI_DRIVER_EXTENSION DriverExtension;
111
112 /* fdo.c */
113
114 NTSTATUS
115 FdoPnpControl(
116 PDEVICE_OBJECT DeviceObject,
117 PIRP Irp);
118
119 NTSTATUS
120 FdoPowerControl(
121 PDEVICE_OBJECT DeviceObject,
122 PIRP Irp);
123
124 /* pci.c */
125
126 NTSTATUS
127 PciCreateDeviceIDString(
128 PUNICODE_STRING DeviceID,
129 PPCI_DEVICE Device);
130
131 NTSTATUS
132 PciCreateInstanceIDString(
133 PUNICODE_STRING InstanceID,
134 PPCI_DEVICE Device);
135
136 NTSTATUS
137 PciCreateHardwareIDsString(
138 PUNICODE_STRING HardwareIDs,
139 PPCI_DEVICE Device);
140
141 NTSTATUS
142 PciCreateCompatibleIDsString(
143 PUNICODE_STRING HardwareIDs,
144 PPCI_DEVICE Device);
145
146 NTSTATUS
147 PciCreateDeviceDescriptionString(
148 PUNICODE_STRING DeviceDescription,
149 PPCI_DEVICE Device);
150
151 NTSTATUS
152 PciCreateDeviceLocationString(
153 PUNICODE_STRING DeviceLocation,
154 PPCI_DEVICE Device);
155
156 NTSTATUS
157 PciDuplicateUnicodeString(
158 IN ULONG Flags,
159 IN PCUNICODE_STRING SourceString,
160 OUT PUNICODE_STRING DestinationString);
161
162 /* pdo.c */
163
164 NTSTATUS
165 PdoPnpControl(
166 PDEVICE_OBJECT DeviceObject,
167 PIRP Irp);
168
169 NTSTATUS
170 PdoPowerControl(
171 PDEVICE_OBJECT DeviceObject,
172 PIRP Irp);
173
174 NTSTATUS
175 NTAPI
176 DriverEntry(
177 IN PDRIVER_OBJECT DriverObject,
178 IN PUNICODE_STRING RegistryPath);