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