Implement IRP_MJ_PNP / IRP_MN_QUERY_INTERFACE for GUID_BUS_INTERFACE_STANDARD
[reactos.git] / reactos / drivers / bus / pci / pci.h
1 #ifndef __PCI_H
2 #define __PCI_H
3
4
5 typedef enum {
6 pbtUnknown = 0,
7 pbtType1,
8 pbtType2,
9 } PCI_BUS_TYPE;
10
11
12 typedef struct _PCI_DEVICE
13 {
14 // Entry on device list
15 LIST_ENTRY ListEntry;
16 // Physical Device Object of device
17 PDEVICE_OBJECT Pdo;
18 // PCI bus number
19 ULONG BusNumber;
20 // PCI slot number
21 PCI_SLOT_NUMBER SlotNumber;
22 // PCI configuration data
23 PCI_COMMON_CONFIG PciConfig;
24 // Flag used during enumeration to locate removed devices
25 BOOLEAN RemovePending;
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 // 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 /* fdo.c */
96
97 NTSTATUS
98 FdoPnpControl(
99 PDEVICE_OBJECT DeviceObject,
100 PIRP Irp);
101
102 NTSTATUS
103 FdoPowerControl(
104 PDEVICE_OBJECT DeviceObject,
105 PIRP Irp);
106
107 /* pci.c */
108
109 NTSTATUS
110 PciCreateDeviceIDString(
111 PUNICODE_STRING DeviceID,
112 PPCI_DEVICE Device);
113
114 NTSTATUS
115 PciCreateInstanceIDString(
116 PUNICODE_STRING InstanceID,
117 PPCI_DEVICE Device);
118
119 NTSTATUS
120 PciCreateHardwareIDsString(
121 PUNICODE_STRING HardwareIDs,
122 PPCI_DEVICE Device);
123
124 NTSTATUS
125 PciCreateCompatibleIDsString(
126 PUNICODE_STRING HardwareIDs,
127 PPCI_DEVICE Device);
128
129 NTSTATUS
130 PciCreateDeviceDescriptionString(
131 PUNICODE_STRING DeviceDescription,
132 PPCI_DEVICE Device);
133
134 NTSTATUS
135 PciCreateDeviceLocationString(
136 PUNICODE_STRING DeviceLocation,
137 PPCI_DEVICE Device);
138
139 /* pdo.c */
140
141 NTSTATUS
142 PdoPnpControl(
143 PDEVICE_OBJECT DeviceObject,
144 PIRP Irp);
145
146 NTSTATUS
147 PdoPowerControl(
148 PDEVICE_OBJECT DeviceObject,
149 PIRP Irp);
150
151 NTSTATUS
152 STDCALL
153 DriverEntry(
154 IN PDRIVER_OBJECT DriverObject,
155 IN PUNICODE_STRING RegistryPath);
156
157 #endif /* __PCI_H */