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