ReactOS  0.4.15-dev-3217-gc6d1646
isapnp.h
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS ISA PnP Bus driver
3  * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE: Common header file
5  * COPYRIGHT: Copyright 2010 Cameron Gutman <cameron.gutman@reactos.org>
6  * Copyright 2020 HervĂ© Poussineau <hpoussin@reactos.org>
7  */
8 
9 #ifndef _ISAPNP_PCH_
10 #define _ISAPNP_PCH_
11 
12 #include <ntddk.h>
13 #include <ntstrsafe.h>
14 #include <section_attribs.h>
15 #include "isapnphw.h"
16 
17 #include <initguid.h>
18 #include <wdmguid.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #define TAG_ISAPNP 'pasI'
25 
27 #define ISAPNP_MAX_RESOURCEDATA 0x1000
28 
30 #define ISAPNP_MAX_ALTERNATIVES 8
31 
32 typedef enum
33 {
37 
38 typedef struct _ISAPNP_IO
39 {
44 
45 typedef struct _ISAPNP_IRQ
46 {
52 
53 typedef struct _ISAPNP_DMA
54 {
59 
60 typedef struct _ISAPNP_MEMRANGE
61 {
67 
68 typedef struct _ISAPNP_MEMRANGE32
69 {
75 
77 {
82 
83 typedef struct _ISAPNP_ALTERNATIVES
84 {
96 
98  UCHAR Count;
100 
102 {
104 
125 
134 #define ISAPNP_PRESENT 0x00000001
135 #define ISAPNP_HAS_MULTIPLE_LOGDEVS 0x00000002
136 #define ISAPNP_HAS_RESOURCES 0x00000004
138  LIST_ENTRY DeviceLink;
140 
141 typedef enum _ISAPNP_SIGNATURE
142 {
143  IsaPnpBus = 'odFI',
147 
149 {
154 
155 typedef struct _ISAPNP_FDO_EXTENSION
156 {
163 
166 
169 
175 
176 typedef struct _ISAPNP_PDO_EXTENSION
177 {
182 
185 
187 #define ISAPNP_ENUMERATED 0x00000001
188 #define ISAPNP_SCANNED_BY_READ_PORT 0x00000002
189 #define ISAPNP_READ_PORT_ALLOW_FDO_SCAN 0x00000004
190 #define ISAPNP_READ_PORT_NEED_REBALANCE 0x00000008
192  _Write_guarded_by_(_Global_interlock_)
193  volatile LONG SpecialFiles;
195 
196 extern KEVENT BusSyncEvent;
197 
199 extern BOOLEAN ReadPortCreated;
200 
202 extern LIST_ENTRY BusListHead;
203 
207 VOID
208 IsaPnpAcquireBusDataLock(VOID)
209 {
211 }
212 
215 VOID
216 IsaPnpReleaseBusDataLock(VOID)
217 {
219 }
220 
221 _Requires_lock_not_held_(FdoExt->DeviceSyncEvent)
222 _Acquires_lock_(FdoExt->DeviceSyncEvent)
224 VOID
225 IsaPnpAcquireDeviceDataLock(
227 {
228  KeWaitForSingleObject(&FdoExt->DeviceSyncEvent, Executive, KernelMode, FALSE, NULL);
229 }
230 
231 _Releases_lock_(FdoExt->DeviceSyncEvent)
233 VOID
234 IsaPnpReleaseDeviceDataLock(
236 {
237  KeSetEvent(&FdoExt->DeviceSyncEvent, IO_NO_INCREMENT, FALSE);
238 }
239 
241 BOOLEAN
243  _In_ PISAPNP_ALTERNATIVES Alternatives)
244 {
245  return (Alternatives->Io[0].Length != 0);
246 }
247 
249 BOOLEAN
251  _In_ PISAPNP_ALTERNATIVES Alternatives)
252 {
253  return (Alternatives->Irq[0].Mask != 0);
254 }
255 
257 BOOLEAN
259  _In_ PISAPNP_ALTERNATIVES Alternatives)
260 {
261  return (Alternatives->Dma[0].Mask != 0);
262 }
263 
265 BOOLEAN
267  _In_ PISAPNP_ALTERNATIVES Alternatives)
268 {
269  return (Alternatives->MemRange[0].Length != 0);
270 }
271 
273 BOOLEAN
275  _In_ PISAPNP_ALTERNATIVES Alternatives)
276 {
277  return (Alternatives->MemRange32[0].Length != 0);
278 }
279 
280 /* isapnp.c */
281 
282 CODE_SEG("PAGE")
283 BOOLEAN
285  _In_ PISAPNP_LOGICAL_DEVICE LogDevice,
287  _In_ ULONG RangeStart,
288  _In_ ULONG RangeEnd,
291  _Out_opt_ PUCHAR WriteOrder);
292 
293 CODE_SEG("PAGE")
294 BOOLEAN
296  _In_ PISAPNP_LOGICAL_DEVICE LogDevice,
297  _In_ ULONG Vector,
298  _Out_opt_ PUCHAR WriteOrder);
299 
300 CODE_SEG("PAGE")
301 BOOLEAN
303  _In_ PISAPNP_LOGICAL_DEVICE LogDevice,
304  _In_ ULONG Channel,
305  _Out_opt_ PUCHAR WriteOrder);
306 
307 CODE_SEG("PAGE")
308 BOOLEAN
310  _In_ PISAPNP_LOGICAL_DEVICE LogDevice,
311  _In_ ULONG RangeStart,
312  _In_ ULONG RangeEnd,
313  _Out_opt_ PBOOLEAN Memory32,
315  _Out_opt_ PUCHAR WriteOrder);
316 
317 CODE_SEG("PAGE")
318 NTSTATUS
321  _In_opt_ ULONG SelectedReadPort);
322 
323 CODE_SEG("PAGE")
324 VOID
327 
328 CODE_SEG("PAGE")
329 NTSTATUS
332  _Inout_ PIRP Irp,
333  _In_ BOOLEAN IncludeDataPort);
334 
335 CODE_SEG("INIT")
336 DRIVER_INITIALIZE DriverEntry;
337 
338 /* fdo.c */
339 CODE_SEG("PAGE")
340 NTSTATUS
341 IsaFdoPnp(
343  _Inout_ PIRP Irp,
345 
346 /* interface.c */
347 CODE_SEG("PAGE")
348 NTSTATUS
352 
353 /* pdo.c */
354 CODE_SEG("PAGE")
355 NTSTATUS
356 IsaPdoPnp(
357  _In_ PISAPNP_PDO_EXTENSION PdoDeviceExtension,
358  _Inout_ PIRP Irp,
360 
361 CODE_SEG("PAGE")
362 VOID
365 
366 /* hardware.c */
367 CODE_SEG("PAGE")
368 UCHAR
370  _In_ PUCHAR ReadDataPort);
371 
372 _Requires_lock_held_(FdoExt->DeviceSyncEvent)
373 CODE_SEG("PAGE")
374 NTSTATUS
375 IsaHwFillDeviceList(
376  _In_ PISAPNP_FDO_EXTENSION FdoExt);
377 
378 CODE_SEG("PAGE")
379 NTSTATUS
384 
386 VOID
387 IsaHwWakeDevice(
389 
391 VOID
392 IsaHwDeactivateDevice(
394 
396 VOID
397 IsaHwActivateDevice(
400 
402 VOID
403 IsaHwWaitForKey(VOID);
404 
405 #ifdef __cplusplus
406 }
407 #endif
408 
409 #endif /* _ISAPNP_PCH_ */
struct _ISAPNP_FDO_EXTENSION ISAPNP_FDO_EXTENSION
_Field_range_(0, ISAPNP_MAX_ALTERNATIVES) UCHAR Count
UCHAR MemRange32Index
Definition: isapnp.h:95
_IRQL_requires_max_(DISPATCH_LEVEL) VOID IsaHwWakeDevice(_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
Definition: hardware.c:1705
ULONG CurrentLength
Definition: isapnp.h:63
UCHAR Index
Definition: isapnp.h:50
ULONG CurrentBase
Definition: isapnp.h:62
NTSTATUS IsaPnpFillDeviceRelations(_In_ PISAPNP_FDO_EXTENSION FdoExt, _Inout_ PIRP Irp, _In_ BOOLEAN IncludeDataPort)
Definition: isapnp.c:1304
_Requires_lock_not_held_(BusSyncEvent) _Acquires_lock_(BusSyncEvent) FORCEINLINE VOID IsaPnpAcquireBusDataLock(VOID)
Definition: isapnp.h:204
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define _In_opt_
Definition: ms_sal.h:309
FORCEINLINE BOOLEAN HasIoAlternatives(_In_ PISAPNP_ALTERNATIVES Alternatives)
Definition: isapnp.h:242
#define _Inout_
Definition: ms_sal.h:378
static LIST_ENTRY DeviceListHead
Definition: fs.c:52
UCHAR CurrentNo
Definition: isapnp.h:47
ISAPNP_IO_DESCRIPTION Description
Definition: isapnp.h:41
struct _ISAPNP_DMA ISAPNP_DMA
unsigned char * PUCHAR
Definition: retypes.h:3
struct _ISAPNP_LOGICAL_DEVICE ISAPNP_LOGICAL_DEVICE
LONG NTSTATUS
Definition: precomp.h:26
ISAPNP_DEVICE_STATE
Definition: isapnp.h:32
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2386
PUSBHUB_PORT_PDO_EXTENSION NTAPI PdoExt(IN PDEVICE_OBJECT DeviceObject)
Definition: usbhub.c:133
VOID IsaPnpRemoveReadPortDO(_In_ PDEVICE_OBJECT Pdo)
Definition: isapnp.c:1284
UCHAR MemRangeIndex
Definition: isapnp.h:94
UCHAR CurrentType
Definition: isapnp.h:48
ISAPNP_IO Io[8]
Definition: isapnp.h:126
_Guarded_by_(BusSyncEvent) extern BOOLEAN ReadPortCreated
Definition: isapnp.c:23
struct _ISAPNP_ALTERNATIVES ISAPNP_ALTERNATIVES
PDEVICE_OBJECT Pdo
Definition: isapnp.h:159
PISAPNP_LOGICAL_DEVICE IsaPnpDevice
Definition: isapnp.h:179
ISAPNP_COMMON_EXTENSION Common
Definition: isapnp.h:178
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1044
ISAPNP_MEMRANGE32 MemRange32[4]
Definition: isapnp.h:130
BOOLEAN FindIoDescriptor(_In_ PISAPNP_LOGICAL_DEVICE LogDevice, _In_opt_ ULONG Base, _In_ ULONG RangeStart, _In_ ULONG RangeEnd, _Out_opt_ PUCHAR Information, _Out_opt_ PULONG Length, _Out_opt_ PUCHAR WriteOrder)
Definition: isapnp.c:518
FORCEINLINE BOOLEAN HasDmaAlternatives(_In_ PISAPNP_ALTERNATIVES Alternatives)
Definition: isapnp.h:258
BOOLEAN FindMemoryDescriptor(_In_ PISAPNP_LOGICAL_DEVICE LogDevice, _In_ ULONG RangeStart, _In_ ULONG RangeEnd, _Out_opt_ PBOOLEAN Memory32, _Out_opt_ PUCHAR Information, _Out_opt_ PUCHAR WriteOrder)
Definition: isapnp.c:695
NTSTATUS IsaFdoQueryInterface(_In_ PISAPNP_FDO_EXTENSION FdoExt, _In_ PIO_STACK_LOCATION IrpSp)
Definition: interface.c:19
Definition: isapnp.h:76
DRIVER_INITIALIZE DriverEntry
Definition: isapnp.h:336
UCHAR LogVendorId[3]
Definition: isapnp.h:120
PCM_RESOURCE_LIST ResourceList
Definition: isapnp.h:183
_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice
Definition: isapnp.h:399
ISAPNP_DMA_DESCRIPTION Description
Definition: isapnp.h:56
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
long LONG
Definition: pedump.c:60
struct _ISAPNP_COMPATIBLE_ID_ENTRY ISAPNP_COMPATIBLE_ID_ENTRY
ULONG DeviceCount
Definition: mpu401.c:26
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_ WDFDRIVER _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT Pdo
Definition: wdfminiport.h:64
UCHAR IsaHwTryReadDataPort(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:1362
ISAPNP_MEMRANGE_DESCRIPTION MemRange[ISAPNP_MAX_ALTERNATIVES]
Definition: isapnp.h:88
PISAPNP_ALTERNATIVES Alternatives
Definition: isapnp.h:124
unsigned char BOOLEAN
#define _In_
Definition: ms_sal.h:308
ISAPNP_DEVICE_STATE State
Definition: isapnp.h:152
_Requires_lock_held_(FdoExt->DeviceSyncEvent) NTSTATUS IsaHwFillDeviceList(_In_ PISAPNP_FDO_EXTENSION FdoExt)
Definition: hardware.c:1460
ISAPNP_IRQ_DESCRIPTION Irq[ISAPNP_MAX_ALTERNATIVES]
Definition: isapnp.h:86
ISAPNP_DMA_DESCRIPTION Dma[ISAPNP_MAX_ALTERNATIVES]
Definition: isapnp.h:87
UCHAR CurrentChannel
Definition: isapnp.h:55
PDEVICE_OBJECT Pdo
Definition: isapnp.h:103
UCHAR Index
Definition: isapnp.h:65
struct _ISAPNP_COMPATIBLE_ID_ENTRY * PISAPNP_COMPATIBLE_ID_ENTRY
struct _ISAPNP_MEMRANGE ISAPNP_MEMRANGE
struct _ISAPNP_FDO_EXTENSION * PISAPNP_FDO_EXTENSION
int Count
Definition: noreturn.cpp:7
UCHAR Index
Definition: isapnp.h:57
NTSTATUS IsaFdoPnp(_In_ PISAPNP_FDO_EXTENSION FdoExt, _Inout_ PIRP Irp, _In_ PIO_STACK_LOCATION IrpSp)
Definition: fdo.c:123
struct _ISAPNP_IRQ ISAPNP_IRQ
USHORT CurrentBase
Definition: isapnp.h:40
LIST_ENTRY BusLink
Definition: isapnp.h:173
struct _ISAPNP_LOGICAL_DEVICE * PISAPNP_LOGICAL_DEVICE
ISAPNP_COMMON_EXTENSION Common
Definition: isapnp.h:157
struct _ISAPNP_IO * PISAPNP_IO
struct _ISAPNP_PDO_EXTENSION ISAPNP_PDO_EXTENSION
LIST_ENTRY IdLink
Definition: isapnp.h:80
BOOLEAN FindDmaDescriptor(_In_ PISAPNP_LOGICAL_DEVICE LogDevice, _In_ ULONG Channel, _Out_opt_ PUCHAR WriteOrder)
Definition: isapnp.c:639
NTSTATUS IsaHwConfigureDevice(_In_ PISAPNP_FDO_EXTENSION FdoExt, _In_ PISAPNP_LOGICAL_DEVICE LogicalDevice, _In_ PCM_RESOURCE_LIST Resources)
Definition: hardware.c:1603
KEVENT DeviceSyncEvent
Definition: isapnp.h:162
ISAPNP_MEMRANGE32_DESCRIPTION MemRange32[ISAPNP_MAX_ALTERNATIVES]
Definition: isapnp.h:89
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:651
unsigned char UCHAR
Definition: xmlstorage.h:181
char * PBOOLEAN
Definition: retypes.h:11
_Guarded_by_(DeviceSyncEvent) LIST_ENTRY DeviceListHead
ISAPNP_IRQ_DESCRIPTION Description
Definition: isapnp.h:49
struct _ISAPNP_MEMRANGE * PISAPNP_MEMRANGE
Definition: typedefs.h:119
ULONG CurrentLength
Definition: isapnp.h:71
ISAPNP_MEMRANGE_DESCRIPTION Description
Definition: isapnp.h:64
ULONG ResourceListSize
Definition: isapnp.h:184
LIST_ENTRY CompatibleIdList
Definition: isapnp.h:122
USHORT ProdId
Definition: isapnp.h:79
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
ISAPNP_MEMRANGE32_DESCRIPTION Description
Definition: isapnp.h:72
KEVENT BusSyncEvent
Definition: isapnp.c:21
PISAPNP_FDO_EXTENSION FdoExt
Definition: isapnp.h:180
VOID IsaPnpRemoveLogicalDeviceDO(_In_ PDEVICE_OBJECT Pdo)
Definition: pdo.c:820
PDEVICE_OBJECT ReadPortPdo
Definition: isapnp.h:160
struct _ISAPNP_IO ISAPNP_IO
ISAPNP_DMA Dma[2]
Definition: isapnp.h:128
UCHAR Index
Definition: isapnp.h:42
PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList
Definition: isapnp.h:181
struct _ISAPNP_IRQ * PISAPNP_IRQ
PDRIVER_OBJECT DriverObject
Definition: isapnp.h:170
ULONG CurrentBase
Definition: isapnp.h:70
unsigned short USHORT
Definition: pedump.c:61
#define ISAPNP_MAX_ALTERNATIVES
Maximum number of Start DF tags supported by the driver.
Definition: isapnp.h:30
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
NTSTATUS IsaPnpCreateReadPortDORequirements(_In_ PISAPNP_PDO_EXTENSION PdoExt, _In_opt_ ULONG SelectedReadPort)
Definition: isapnp.c:1042
signed char * PSTR
Definition: retypes.h:7
#define FORCEINLINE
Definition: wdftypes.h:67
#define _Out_opt_
Definition: ms_sal.h:346
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
ISAPNP_MEMRANGE MemRange[4]
Definition: isapnp.h:129
struct _ISAPNP_COMMON_EXTENSION ISAPNP_COMMON_EXTENSION
_ISAPNP_SIGNATURE
Definition: isapnp.h:141
ISAPNP_SIGNATURE Signature
Definition: isapnp.h:150
struct _ISAPNP_DMA * PISAPNP_DMA
enum _ISAPNP_SIGNATURE ISAPNP_SIGNATURE
_Releases_lock_(BusSyncEvent) FORCEINLINE VOID IsaPnpReleaseBusDataLock(VOID)
Definition: isapnp.h:213
struct _ISAPNP_MEMRANGE32 ISAPNP_MEMRANGE32
struct _ISAPNP_MEMRANGE32 * PISAPNP_MEMRANGE32
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:598
struct _ISAPNP_ALTERNATIVES * PISAPNP_ALTERNATIVES
struct _ISAPNP_COMMON_EXTENSION * PISAPNP_COMMON_EXTENSION
FORCEINLINE BOOLEAN HasMemory32Alternatives(_In_ PISAPNP_ALTERNATIVES Alternatives)
Definition: isapnp.h:274
PDEVICE_OBJECT Ldo
Definition: isapnp.h:158
#define _Acquires_lock_(lock)
UCHAR VendorId[3]
Definition: isapnp.h:78
PDEVICE_OBJECT Self
Definition: isapnp.h:151
static CODE_SEG("PAGE")
Definition: isapnp.c:1482
NTSTATUS IsaPdoPnp(_In_ PISAPNP_PDO_EXTENSION PdoDeviceExtension, _Inout_ PIRP Irp, _In_ PIO_STACK_LOCATION IrpSp)
Definition: pdo.c:864
struct _ISAPNP_PDO_EXTENSION * PISAPNP_PDO_EXTENSION
FORCEINLINE BOOLEAN HasIrqAlternatives(_In_ PISAPNP_ALTERNATIVES Alternatives)
Definition: isapnp.h:250
FORCEINLINE BOOLEAN HasMemoryAlternatives(_In_ PISAPNP_ALTERNATIVES Alternatives)
Definition: isapnp.h:266
BOOLEAN FindIrqDescriptor(_In_ PISAPNP_LOGICAL_DEVICE LogDevice, _In_ ULONG Vector, _Out_opt_ PUCHAR WriteOrder)
Definition: isapnp.c:583
ISAPNP_IRQ Irq[2]
Definition: isapnp.h:127
ISAPNP_IO_DESCRIPTION Io[ISAPNP_MAX_ALTERNATIVES]
Definition: isapnp.h:85