Added PCI bus driver skeleton
[reactos.git] / reactos / drivers / bus / pci / pci.h
1 /* $Id: pci.h,v 1.1 2001/09/16 13:18:24 chorns Exp $ */
2
3 #ifndef __PCI_H
4 #define __PCI_H
5
6 #include <ddk/ntddk.h>
7 #include <pcidef.h>
8
9
10 typedef enum {
11 pbtUnknown = 0,
12 pbtType1,
13 pbtType2,
14 } PCI_BUS_TYPE;
15
16
17 typedef struct _PCI_DEVICE
18 {
19 // Entry on device list
20 LIST_ENTRY ListEntry;
21 // Physical Device Object of device
22 PDEVICE_OBJECT Pdo;
23 // PCI configuration data
24 PCI_COMMON_CONFIG PciConfig;
25 // Flag used during enumeration to locate removed devices
26 BOOLEAN RemovePending;
27 } PCI_DEVICE, *PPCI_DEVICE;
28
29
30 typedef enum {
31 dsStopped,
32 dsStarted,
33 dsPaused,
34 dsRemoved,
35 dsSurpriseRemoved
36 } PCI_DEVICE_STATE;
37
38
39 typedef struct _COMMON_DEVICE_EXTENSION
40 {
41 // Pointer to device object, this device extension is associated with
42 PDEVICE_OBJECT DeviceObject;
43 // Wether this device extension is for an FDO or PDO
44 BOOLEAN IsFDO;
45 // Wether the device is removed
46 BOOLEAN Removed;
47 // Current device power state for the device
48 DEVICE_POWER_STATE DevicePowerState;
49 } __attribute((packed)) COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION;
50
51 /* Physical Device Object device extension for a child device */
52 typedef struct _PDO_DEVICE_EXTENSION
53 {
54 // Common device data
55 COMMON_DEVICE_EXTENSION;
56 // Device ID
57 UNICODE_STRING DeviceID;
58 // Instance ID
59 UNICODE_STRING InstanceID;
60 // Hardware IDs
61 UNICODE_STRING HardwareIDs;
62 // Compatible IDs
63 UNICODE_STRING CompatibleIDs;
64 // Textual description of device
65 UNICODE_STRING DeviceText;
66 // Textual description of device
67 UNICODE_STRING DeviceTextLocation;
68 } __attribute((packed)) PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
69
70 /* Functional Device Object device extension for the PCI driver device object */
71 typedef struct _FDO_DEVICE_EXTENSION
72 {
73 // Common device data
74 COMMON_DEVICE_EXTENSION;
75 // Physical Device Object
76 PDEVICE_OBJECT Pdo;
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 // PCI bus number
86 ULONG BusNumber;
87 // Lower device object
88 PDEVICE_OBJECT Ldo;
89 } __attribute((packed)) FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION;
90
91
92 /* fdo.c */
93
94 NTSTATUS
95 FdoPnpControl(
96 PDEVICE_OBJECT DeviceObject,
97 PIRP Irp);
98
99 NTSTATUS
100 FdoPowerControl(
101 PDEVICE_OBJECT DeviceObject,
102 PIRP Irp);
103
104 /* pci.c */
105
106 extern PCI_BUS_TYPE PciBusConfigType;
107
108 PCI_BUS_TYPE
109 PciGetBusConfigType(VOID);
110
111 BOOLEAN
112 PciCreateUnicodeString(
113 PUNICODE_STRING Destination,
114 PWSTR Source,
115 POOL_TYPE PoolType);
116
117 /* pdo.c */
118
119 NTSTATUS
120 PdoPnpControl(
121 PDEVICE_OBJECT DeviceObject,
122 PIRP Irp);
123
124 NTSTATUS
125 PdoPowerControl(
126 PDEVICE_OBJECT DeviceObject,
127 PIRP Irp);
128
129 #endif /* __PCI_H */