544eb517a7676668a34158d06ac3660874cc3168
[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 } 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 // 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 /* fdo.c */
94
95 NTSTATUS
96 FdoPnpControl(
97 PDEVICE_OBJECT DeviceObject,
98 PIRP Irp);
99
100 NTSTATUS
101 FdoPowerControl(
102 PDEVICE_OBJECT DeviceObject,
103 PIRP Irp);
104
105 /* pci.c */
106
107 NTSTATUS
108 PciCreateDeviceIDString(
109 PUNICODE_STRING DeviceID,
110 PPCI_DEVICE Device);
111
112 NTSTATUS
113 PciCreateInstanceIDString(
114 PUNICODE_STRING InstanceID,
115 PPCI_DEVICE Device);
116
117 NTSTATUS
118 PciCreateHardwareIDsString(
119 PUNICODE_STRING HardwareIDs,
120 PPCI_DEVICE Device);
121
122 NTSTATUS
123 PciCreateCompatibleIDsString(
124 PUNICODE_STRING HardwareIDs,
125 PPCI_DEVICE Device);
126
127 NTSTATUS
128 PciCreateDeviceDescriptionString(
129 PUNICODE_STRING DeviceDescription,
130 PPCI_DEVICE Device);
131
132 NTSTATUS
133 PciCreateDeviceLocationString(
134 PUNICODE_STRING DeviceLocation,
135 PPCI_DEVICE Device);
136
137 /* pdo.c */
138
139 NTSTATUS
140 PdoPnpControl(
141 PDEVICE_OBJECT DeviceObject,
142 PIRP Irp);
143
144 NTSTATUS
145 PdoPowerControl(
146 PDEVICE_OBJECT DeviceObject,
147 PIRP Irp);
148
149 NTSTATUS
150 STDCALL
151 DriverEntry(
152 IN PDRIVER_OBJECT DriverObject,
153 IN PUNICODE_STRING RegistryPath);
154
155 #endif /* __PCI_H */