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