a78998be1c7cf8c0ef1beb8a206e997708452291
[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 BOOLEAN
116 PciCreateDeviceIDString(
117 PUNICODE_STRING DeviceID,
118 PPCI_DEVICE Device);
119
120 BOOLEAN
121 PciCreateInstanceIDString(
122 PUNICODE_STRING InstanceID,
123 PPCI_DEVICE Device);
124
125 BOOLEAN
126 PciCreateHardwareIDsString(
127 PUNICODE_STRING HardwareIDs,
128 PPCI_DEVICE Device);
129
130 BOOLEAN
131 PciCreateCompatibleIDsString(
132 PUNICODE_STRING HardwareIDs,
133 PPCI_DEVICE Device);
134
135 BOOLEAN
136 PciCreateDeviceDescriptionString(
137 PUNICODE_STRING DeviceDescription,
138 PPCI_DEVICE Device);
139
140 BOOLEAN
141 PciCreateDeviceLocationString(
142 PUNICODE_STRING DeviceLocation,
143 PPCI_DEVICE Device);
144
145 /* pdo.c */
146
147 NTSTATUS
148 PdoPnpControl(
149 PDEVICE_OBJECT DeviceObject,
150 PIRP Irp);
151
152 NTSTATUS
153 PdoPowerControl(
154 PDEVICE_OBJECT DeviceObject,
155 PIRP Irp);
156
157 NTSTATUS
158 STDCALL
159 DriverEntry(
160 IN PDRIVER_OBJECT DriverObject,
161 IN PUNICODE_STRING RegistryPath);
162
163 #endif /* __PCI_H */