[STORPORT] Initialize the port configuration and pass it to the HwFindAdapter routine.
[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
31 typedef enum
32 {
33 dsStopped,
34 dsStarted,
35 dsPaused,
36 dsRemoved,
37 dsSurpriseRemoved
38 } DEVICE_STATE;
39
40 typedef enum
41 {
42 InvalidExtension = 0,
43 DriverExtension,
44 FdoExtension,
45 PdoExtension
46 } EXTENSION_TYPE;
47
48 typedef struct _DRIVER_INIT_DATA
49 {
50 LIST_ENTRY Entry;
51 HW_INITIALIZATION_DATA HwInitData;
52 } DRIVER_INIT_DATA, *PDRIVER_INIT_DATA;
53
54 typedef struct _DRIVER_OBJECT_EXTENSION
55 {
56 EXTENSION_TYPE ExtensionType;
57 PDRIVER_OBJECT DriverObject;
58
59 KSPIN_LOCK AdapterListLock;
60 LIST_ENTRY AdapterListHead;
61 ULONG AdapterCount;
62
63 LIST_ENTRY InitDataListHead;
64 } DRIVER_OBJECT_EXTENSION, *PDRIVER_OBJECT_EXTENSION;
65
66 typedef struct _MINIPORT_DEVICE_EXTENSION
67 {
68 struct _MINIPORT *Miniport;
69 UCHAR HwDeviceExtension[0];
70 } MINIPORT_DEVICE_EXTENSION, *PMINIPORT_DEVICE_EXTENSION;
71
72 typedef struct _MINIPORT
73 {
74 struct _FDO_DEVICE_EXTENSION *DeviceExtension;
75 PHW_INITIALIZATION_DATA InitData;
76 PORT_CONFIGURATION_INFORMATION PortConfig;
77 PMINIPORT_DEVICE_EXTENSION MiniportExtension;
78 } MINIPORT, *PMINIPORT;
79
80 typedef struct _FDO_DEVICE_EXTENSION
81 {
82 EXTENSION_TYPE ExtensionType;
83
84 PDEVICE_OBJECT Device;
85 PDEVICE_OBJECT LowerDevice;
86 PDEVICE_OBJECT PhysicalDevice;
87 PDRIVER_OBJECT_EXTENSION DriverExtension;
88 DEVICE_STATE PnpState;
89 LIST_ENTRY AdapterListEntry;
90 MINIPORT Miniport;
91 ULONG BusNumber;
92 ULONG SlotNumber;
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_ */