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