[STORPORT] Attach copies of the resource lists to the FDO device extension and use...
[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 #define TAG_ACCRESS_RANGE 'RAtS'
30 #define TAG_RESOURCE_LIST 'LRtS'
31
32 typedef enum
33 {
34 dsStopped,
35 dsStarted,
36 dsPaused,
37 dsRemoved,
38 dsSurpriseRemoved
39 } DEVICE_STATE;
40
41 typedef enum
42 {
43 InvalidExtension = 0,
44 DriverExtension,
45 FdoExtension,
46 PdoExtension
47 } EXTENSION_TYPE;
48
49 typedef struct _DRIVER_INIT_DATA
50 {
51 LIST_ENTRY Entry;
52 HW_INITIALIZATION_DATA HwInitData;
53 } DRIVER_INIT_DATA, *PDRIVER_INIT_DATA;
54
55 typedef struct _DRIVER_OBJECT_EXTENSION
56 {
57 EXTENSION_TYPE ExtensionType;
58 PDRIVER_OBJECT DriverObject;
59
60 KSPIN_LOCK AdapterListLock;
61 LIST_ENTRY AdapterListHead;
62 ULONG AdapterCount;
63
64 LIST_ENTRY InitDataListHead;
65 } DRIVER_OBJECT_EXTENSION, *PDRIVER_OBJECT_EXTENSION;
66
67 typedef struct _MINIPORT_DEVICE_EXTENSION
68 {
69 struct _MINIPORT *Miniport;
70 UCHAR HwDeviceExtension[0];
71 } MINIPORT_DEVICE_EXTENSION, *PMINIPORT_DEVICE_EXTENSION;
72
73 typedef struct _MINIPORT
74 {
75 struct _FDO_DEVICE_EXTENSION *DeviceExtension;
76 PHW_INITIALIZATION_DATA InitData;
77 PORT_CONFIGURATION_INFORMATION PortConfig;
78 PMINIPORT_DEVICE_EXTENSION MiniportExtension;
79 } MINIPORT, *PMINIPORT;
80
81 typedef struct _FDO_DEVICE_EXTENSION
82 {
83 EXTENSION_TYPE ExtensionType;
84
85 PDEVICE_OBJECT Device;
86 PDEVICE_OBJECT LowerDevice;
87 PDEVICE_OBJECT PhysicalDevice;
88 PDRIVER_OBJECT_EXTENSION DriverExtension;
89 DEVICE_STATE PnpState;
90 LIST_ENTRY AdapterListEntry;
91 MINIPORT Miniport;
92 ULONG BusNumber;
93 ULONG SlotNumber;
94 PCM_RESOURCE_LIST AllocatedResources;
95 PCM_RESOURCE_LIST TranslatedResources;
96 } FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION;
97
98
99 typedef struct _PDO_DEVICE_EXTENSION
100 {
101 EXTENSION_TYPE ExtensionType;
102
103 PDEVICE_OBJECT AttachedFdo;
104
105 DEVICE_STATE PnpState;
106
107 } PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
108
109
110 /* fdo.c */
111
112 NTSTATUS
113 NTAPI
114 PortFdoPnp(
115 _In_ PDEVICE_OBJECT DeviceObject,
116 _In_ PIRP Irp);
117
118
119 /* miniport.c */
120
121 NTSTATUS
122 MiniportInitialize(
123 _In_ PMINIPORT Miniport,
124 _In_ PFDO_DEVICE_EXTENSION DeviceExtension,
125 _In_ PHW_INITIALIZATION_DATA HwInitializationData);
126
127 NTSTATUS
128 MiniportFindAdapter(
129 _In_ PMINIPORT Miniport);
130
131 NTSTATUS
132 MiniportHwInitialize(
133 _In_ PMINIPORT Miniport);
134
135
136 /* misc.c */
137
138 NTSTATUS
139 ForwardIrpAndWait(
140 _In_ PDEVICE_OBJECT LowerDevice,
141 _In_ PIRP Irp);
142
143 NTSTATUS
144 NTAPI
145 ForwardIrpAndForget(
146 _In_ PDEVICE_OBJECT LowerDevice,
147 _In_ PIRP Irp);
148
149 INTERFACE_TYPE
150 GetBusInterface(
151 PDEVICE_OBJECT DeviceObject);
152
153 PCM_RESOURCE_LIST
154 CopyResourceList(
155 POOL_TYPE PoolType,
156 PCM_RESOURCE_LIST Source);
157
158
159 /* pdo.c */
160
161 NTSTATUS
162 NTAPI
163 PortPdoPnp(
164 _In_ PDEVICE_OBJECT DeviceObject,
165 _In_ PIRP Irp);
166
167
168 /* storport.c */
169
170 PHW_INITIALIZATION_DATA
171 PortGetDriverInitData(
172 PDRIVER_OBJECT_EXTENSION DriverExtension,
173 INTERFACE_TYPE InterfaceType);
174
175 NTSTATUS
176 NTAPI
177 DriverEntry(
178 _In_ PDRIVER_OBJECT DriverObject,
179 _In_ PUNICODE_STRING RegistryPath);
180
181 #endif /* _STORPORT_PCH_ */