Patch by Jonathon Wilson:
[reactos.git] / reactos / drivers / bus / pci / pci.h
1 /* $Id: pci.h,v 1.3 2003/11/14 17:13:24 weiden 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 Common;
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 Common;
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 ULONG
112 PciGetBusData(ULONG BusNumber,
113 ULONG SlotNumber,
114 PVOID Buffer,
115 ULONG Offset,
116 ULONG Length);
117
118 BOOLEAN
119 PciCreateUnicodeString(
120 PUNICODE_STRING Destination,
121 PWSTR Source,
122 POOL_TYPE PoolType);
123
124 /* pdo.c */
125
126 NTSTATUS
127 PdoPnpControl(
128 PDEVICE_OBJECT DeviceObject,
129 PIRP Irp);
130
131 NTSTATUS
132 PdoPowerControl(
133 PDEVICE_OBJECT DeviceObject,
134 PIRP Irp);
135
136 #endif /* __PCI_H */