migrate substitution keywords to SVN
[reactos.git] / reactos / drivers / bus / pci / pci.h
1 /* $Id$ */
2
3 #ifndef __PCI_H
4 #define __PCI_H
5
6
7 typedef enum {
8 pbtUnknown = 0,
9 pbtType1,
10 pbtType2,
11 } PCI_BUS_TYPE;
12
13
14 typedef struct _PCI_DEVICE
15 {
16 // Entry on device list
17 LIST_ENTRY ListEntry;
18 // Physical Device Object of device
19 PDEVICE_OBJECT Pdo;
20 // PCI bus number
21 ULONG BusNumber;
22 // PCI slot number
23 PCI_SLOT_NUMBER SlotNumber;
24 // PCI configuration data
25 PCI_COMMON_CONFIG PciConfig;
26 // Flag used during enumeration to locate removed devices
27 BOOLEAN RemovePending;
28 } PCI_DEVICE, *PPCI_DEVICE;
29
30
31 typedef enum {
32 dsStopped,
33 dsStarted,
34 dsPaused,
35 dsRemoved,
36 dsSurpriseRemoved
37 } PCI_DEVICE_STATE;
38
39
40 typedef struct _COMMON_DEVICE_EXTENSION
41 {
42 // Pointer to device object, this device extension is associated with
43 PDEVICE_OBJECT DeviceObject;
44 // Wether this device extension is for an FDO or PDO
45 BOOLEAN IsFDO;
46 // Wether the device is removed
47 BOOLEAN Removed;
48 // Current device power state for the device
49 DEVICE_POWER_STATE DevicePowerState;
50 } __attribute((packed)) COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION;
51
52 /* Physical Device Object device extension for a child device */
53 typedef struct _PDO_DEVICE_EXTENSION
54 {
55 // Common device data
56 COMMON_DEVICE_EXTENSION Common;
57 // Functional device object
58 PDEVICE_OBJECT Fdo;
59 // PCI bus number
60 ULONG BusNumber;
61 // PCI slot number
62 PCI_SLOT_NUMBER SlotNumber;
63 // Device ID
64 UNICODE_STRING DeviceID;
65 // Instance ID
66 UNICODE_STRING InstanceID;
67 // Hardware IDs
68 UNICODE_STRING HardwareIDs;
69 // Compatible IDs
70 UNICODE_STRING CompatibleIDs;
71 // Textual description of device
72 UNICODE_STRING DeviceDescription;
73 // Textual description of device location
74 UNICODE_STRING DeviceLocation;
75 } __attribute((packed)) PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
76
77 /* Functional Device Object device extension for the PCI driver device object */
78 typedef struct _FDO_DEVICE_EXTENSION
79 {
80 // Common device data
81 COMMON_DEVICE_EXTENSION Common;
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 } __attribute((packed)) 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 BOOLEAN
110 PciCreateUnicodeString(
111 PUNICODE_STRING Destination,
112 PWSTR Source,
113 POOL_TYPE PoolType);
114
115 NTSTATUS
116 PciDuplicateUnicodeString(
117 PUNICODE_STRING Destination,
118 PUNICODE_STRING Source,
119 POOL_TYPE PoolType);
120
121 BOOLEAN
122 PciCreateDeviceIDString(
123 PUNICODE_STRING DeviceID,
124 PPCI_DEVICE Device);
125
126 BOOLEAN
127 PciCreateInstanceIDString(
128 PUNICODE_STRING InstanceID,
129 PPCI_DEVICE Device);
130
131 BOOLEAN
132 PciCreateHardwareIDsString(
133 PUNICODE_STRING HardwareIDs,
134 PPCI_DEVICE Device);
135
136 BOOLEAN
137 PciCreateCompatibleIDsString(
138 PUNICODE_STRING HardwareIDs,
139 PPCI_DEVICE Device);
140
141 BOOLEAN
142 PciCreateDeviceDescriptionString(
143 PUNICODE_STRING DeviceDescription,
144 PPCI_DEVICE Device);
145
146 BOOLEAN
147 PciCreateDeviceLocationString(
148 PUNICODE_STRING DeviceLocation,
149 PPCI_DEVICE Device);
150
151 /* pdo.c */
152
153 NTSTATUS
154 PdoPnpControl(
155 PDEVICE_OBJECT DeviceObject,
156 PIRP Irp);
157
158 NTSTATUS
159 PdoPowerControl(
160 PDEVICE_OBJECT DeviceObject,
161 PIRP Irp);
162
163 #endif /* __PCI_H */