350ca6854df1a5d94fb7d994b98177aff010e60b
[reactos.git] / drivers / storage / port / storport / precomp.h
1 /*
2 * PROJECT: ReactOS Storport Driver
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Storport driver common header file
5 * COPYRIGHT: Copyright 2017 Eric Kohl (eric.kohl@reactos.org)
6 */
7
8 #ifndef _STORPORT_PCH_
9 #define _STORPORT_PCH_
10
11 #include <wdm.h>
12 #include <ntddk.h>
13 #include <stdio.h>
14 #include <memory.h>
15
16 /* Declare STORPORT_API functions as exports rather than imports */
17 #define _STORPORT_
18 #include <storport.h>
19
20 #include <ntddscsi.h>
21 #include <ntdddisk.h>
22 #include <mountdev.h>
23 #include <wdmguid.h>
24
25 /* Memory Tags */
26 #define TAG_GLOBAL_DATA 'DGtS'
27 #define TAG_INIT_DATA 'DItS'
28 #define TAG_MINIPORT_DATA 'DMtS'
29
30 typedef enum
31 {
32 dsStopped,
33 dsStarted,
34 dsPaused,
35 dsRemoved,
36 dsSurpriseRemoved
37 } DEVICE_STATE;
38
39 typedef enum
40 {
41 InvalidExtension = 0,
42 DriverExtension,
43 FdoExtension,
44 PdoExtension
45 } EXTENSION_TYPE;
46
47 typedef struct _DRIVER_INIT_DATA
48 {
49 LIST_ENTRY Entry;
50 HW_INITIALIZATION_DATA HwInitData;
51 } DRIVER_INIT_DATA, *PDRIVER_INIT_DATA;
52
53 typedef struct _DRIVER_OBJECT_EXTENSION
54 {
55 EXTENSION_TYPE ExtensionType;
56 PDRIVER_OBJECT DriverObject;
57
58 KSPIN_LOCK AdapterListLock;
59 LIST_ENTRY AdapterListHead;
60 ULONG AdapterCount;
61
62 LIST_ENTRY InitDataListHead;
63 } DRIVER_OBJECT_EXTENSION, *PDRIVER_OBJECT_EXTENSION;
64
65 typedef struct _MINIPORT_DEVICE_EXTENSION
66 {
67 struct _MINIPORT *Miniport;
68 UCHAR HwDeviceExtension[0];
69 } MINIPORT_DEVICE_EXTENSION, *PMINIPORT_DEVICE_EXTENSION;
70
71 typedef struct _MINIPORT
72 {
73 struct _FDO_DEVICE_EXTENSION *DeviceExtension;
74 PHW_INITIALIZATION_DATA InitData;
75 PMINIPORT_DEVICE_EXTENSION MiniportExtension;
76 } MINIPORT, *PMINIPORT;
77
78 typedef struct _FDO_DEVICE_EXTENSION
79 {
80 EXTENSION_TYPE ExtensionType;
81
82 PDEVICE_OBJECT Device;
83 PDEVICE_OBJECT LowerDevice;
84 PDEVICE_OBJECT PhysicalDevice;
85
86 PDRIVER_OBJECT_EXTENSION DriverExtension;
87
88 DEVICE_STATE PnpState;
89 LIST_ENTRY AdapterListEntry;
90
91 MINIPORT Miniport;
92
93 } FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION;
94
95
96 typedef struct _PDO_DEVICE_EXTENSION
97 {
98 EXTENSION_TYPE ExtensionType;
99
100 PDEVICE_OBJECT AttachedFdo;
101
102 DEVICE_STATE PnpState;
103
104 } PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
105
106
107 /* fdo.c */
108
109 NTSTATUS
110 NTAPI
111 PortFdoPnp(
112 _In_ PDEVICE_OBJECT DeviceObject,
113 _In_ PIRP Irp);
114
115
116 /* miniport.c */
117
118 NTSTATUS
119 MiniportInitialize(
120 _In_ PMINIPORT Miniport,
121 _In_ PFDO_DEVICE_EXTENSION DeviceExtension,
122 _In_ PHW_INITIALIZATION_DATA HwInitializationData);
123
124 NTSTATUS
125 MiniportFindAdapter(
126 _In_ PMINIPORT Miniport);
127
128 NTSTATUS
129 MiniportHwInitialize(
130 _In_ PMINIPORT Miniport);
131
132
133 /* misc.c */
134
135 NTSTATUS
136 ForwardIrpAndWait(
137 _In_ PDEVICE_OBJECT LowerDevice,
138 _In_ PIRP Irp);
139
140 NTSTATUS
141 NTAPI
142 ForwardIrpAndForget(
143 _In_ PDEVICE_OBJECT LowerDevice,
144 _In_ PIRP Irp);
145
146 INTERFACE_TYPE
147 GetBusInterface(
148 PDEVICE_OBJECT DeviceObject);
149
150 /* pdo.c */
151
152 NTSTATUS
153 NTAPI
154 PortPdoPnp(
155 _In_ PDEVICE_OBJECT DeviceObject,
156 _In_ PIRP Irp);
157
158
159 /* storport.c */
160
161 PHW_INITIALIZATION_DATA
162 PortGetDriverInitData(
163 PDRIVER_OBJECT_EXTENSION DriverExtension,
164 INTERFACE_TYPE InterfaceType);
165
166 NTSTATUS
167 NTAPI
168 DriverEntry(
169 _In_ PDRIVER_OBJECT DriverObject,
170 _In_ PUNICODE_STRING RegistryPath);
171
172 #endif /* _STORPORT_PCH_ */