xref: /reactos/drivers/bus/isapnp/isapnp.h (revision b8dd046e)
1 #ifndef _ISAPNP_PCH_
2 #define _ISAPNP_PCH_
3 
4 #include <wdm.h>
5 #include <ntstrsafe.h>
6 #include <isapnphw.h>
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 #define TAG_ISAPNP 'PNPI'
13 
14 typedef enum {
15     dsStopped,
16     dsStarted
17 } ISAPNP_DEVICE_STATE;
18 
19 typedef struct _ISAPNP_IO {
20     USHORT CurrentBase;
21     ISAPNP_IO_DESCRIPTION Description;
22 } ISAPNP_IO, PISAPNP_IO;
23 
24 typedef struct _ISAPNP_IRQ {
25     UCHAR CurrentNo;
26     UCHAR CurrentType;
27     ISAPNP_IRQ_DESCRIPTION Description;
28 } ISAPNP_IRQ, *PISAPNP_IRQ;
29 
30 typedef struct _ISAPNP_DMA {
31     UCHAR CurrentChannel;
32     ISAPNP_DMA_DESCRIPTION Description;
33 } ISAPNP_DMA, *PISAPNP_DMA;
34 
35 typedef struct _ISAPNP_LOGICAL_DEVICE {
36     PDEVICE_OBJECT Pdo;
37     ISAPNP_LOGDEVID LogDevId;
38     UCHAR VendorId[3];
39     USHORT ProdId;
40     ULONG SerialNumber;
41     ISAPNP_IO Io[8];
42     ISAPNP_IRQ Irq[2];
43     ISAPNP_DMA Dma[2];
44     UCHAR CSN;
45     UCHAR LDN;
46     LIST_ENTRY ListEntry;
47 } ISAPNP_LOGICAL_DEVICE, *PISAPNP_LOGICAL_DEVICE;
48 
49 typedef struct _ISAPNP_COMMON_EXTENSION {
50     PDEVICE_OBJECT Self;
51     BOOLEAN IsFdo;
52     ISAPNP_DEVICE_STATE State;
53 } ISAPNP_COMMON_EXTENSION, *PISAPNP_COMMON_EXTENSION;
54 
55 typedef struct _ISAPNP_FDO_EXTENSION {
56     ISAPNP_COMMON_EXTENSION Common;
57     PDEVICE_OBJECT Ldo;
58     PDEVICE_OBJECT Pdo;
59     PDEVICE_OBJECT DataPortPdo;
60     LIST_ENTRY DeviceListHead;
61     ULONG DeviceCount;
62     PDRIVER_OBJECT DriverObject;
63     PUCHAR ReadDataPort;
64     KSPIN_LOCK Lock;
65 } ISAPNP_FDO_EXTENSION, *PISAPNP_FDO_EXTENSION;
66 
67 typedef struct _ISAPNP_PDO_EXTENSION {
68     ISAPNP_COMMON_EXTENSION Common;
69     PISAPNP_LOGICAL_DEVICE IsaPnpDevice;
70     PISAPNP_FDO_EXTENSION FdoExt;
71     UNICODE_STRING DeviceID;
72     UNICODE_STRING HardwareIDs;
73     UNICODE_STRING CompatibleIDs;
74     UNICODE_STRING InstanceID;
75     PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList;
76     PCM_RESOURCE_LIST ResourceList;
77     ULONG ResourceListSize;
78 } ISAPNP_PDO_EXTENSION, *PISAPNP_PDO_EXTENSION;
79 
80 /* isapnp.c */
81 
82 #define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE         1
83 #define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING   2
84 
85 NTSTATUS
86 NTAPI
87 IsaPnpDuplicateUnicodeString(
88     IN ULONG Flags,
89     IN PCUNICODE_STRING SourceString,
90     OUT PUNICODE_STRING DestinationString);
91 
92 NTSTATUS
93 NTAPI
94 IsaPnpFillDeviceRelations(
95     IN PISAPNP_FDO_EXTENSION FdoExt,
96     IN PIRP Irp,
97     IN BOOLEAN IncludeDataPort);
98 
99 DRIVER_INITIALIZE DriverEntry;
100 
101 NTSTATUS
102 NTAPI
103 DriverEntry(
104     IN PDRIVER_OBJECT DriverObject,
105     IN PUNICODE_STRING RegistryPath);
106 
107 NTSTATUS
108 NTAPI
109 IsaForwardIrpSynchronous(
110     IN PISAPNP_FDO_EXTENSION FdoExt,
111     IN PIRP Irp);
112 
113 /* fdo.c */
114 NTSTATUS
115 NTAPI
116 IsaFdoPnp(
117     IN PISAPNP_FDO_EXTENSION FdoExt,
118     IN PIRP Irp,
119     IN PIO_STACK_LOCATION IrpSp);
120 
121 /* pdo.c */
122 NTSTATUS
123 NTAPI
124 IsaPdoPnp(
125     IN PISAPNP_PDO_EXTENSION PdoDeviceExtension,
126     IN PIRP Irp,
127     IN PIO_STACK_LOCATION IrpSp);
128 
129 /* hardware.c */
130 NTSTATUS
131 NTAPI
132 IsaHwTryReadDataPort(
133     IN PUCHAR ReadDataPort);
134 
135 NTSTATUS
136 NTAPI
137 IsaHwFillDeviceList(
138     IN PISAPNP_FDO_EXTENSION FdoExt);
139 
140 NTSTATUS
141 NTAPI
142 IsaHwDeactivateDevice(
143     IN PISAPNP_LOGICAL_DEVICE LogicalDevice);
144 
145 NTSTATUS
146 NTAPI
147 IsaHwActivateDevice(
148     IN PISAPNP_LOGICAL_DEVICE LogicalDevice);
149 
150 #ifdef __cplusplus
151 }
152 #endif
153 
154 #endif /* _ISAPNP_PCH_ */
155