2021-03-04 12:42:42 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS ISA PnP Bus driver
|
|
|
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
|
|
|
* PURPOSE: Common header file
|
|
|
|
* COPYRIGHT: Copyright 2010 Cameron Gutman <cameron.gutman@reactos.org>
|
|
|
|
* Copyright 2020 Hervé Poussineau <hpoussin@reactos.org>
|
|
|
|
*/
|
|
|
|
|
2014-02-06 11:18:34 +00:00
|
|
|
#ifndef _ISAPNP_PCH_
|
|
|
|
#define _ISAPNP_PCH_
|
2001-05-01 23:00:05 +00:00
|
|
|
|
2021-03-04 12:48:43 +00:00
|
|
|
#include <ntddk.h>
|
2020-02-10 20:31:28 +00:00
|
|
|
#include <ntstrsafe.h>
|
2021-03-04 12:43:44 +00:00
|
|
|
#include <section_attribs.h>
|
2024-05-03 13:08:09 +00:00
|
|
|
|
2021-03-04 12:42:42 +00:00
|
|
|
#include "isapnphw.h"
|
2024-05-03 13:08:09 +00:00
|
|
|
#include "isapnpres.h"
|
2007-07-06 20:25:30 +00:00
|
|
|
|
2021-03-04 12:47:34 +00:00
|
|
|
#include <initguid.h>
|
|
|
|
#include <wdmguid.h>
|
|
|
|
|
2001-05-01 23:00:05 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-03-04 12:43:19 +00:00
|
|
|
#define TAG_ISAPNP 'pasI'
|
2007-07-06 20:25:30 +00:00
|
|
|
|
2021-03-04 12:42:42 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
2020-03-20 18:19:30 +00:00
|
|
|
dsStopped,
|
|
|
|
dsStarted
|
2010-04-07 20:19:29 +00:00
|
|
|
} ISAPNP_DEVICE_STATE;
|
2001-05-01 23:00:05 +00:00
|
|
|
|
2021-03-04 12:48:43 +00:00
|
|
|
typedef enum _ISAPNP_SIGNATURE
|
|
|
|
{
|
|
|
|
IsaPnpBus = 'odFI',
|
|
|
|
IsaPnpLogicalDevice = 'veDI',
|
|
|
|
IsaPnpReadDataPort = 'pdRI'
|
|
|
|
} ISAPNP_SIGNATURE;
|
|
|
|
|
2021-03-04 12:42:42 +00:00
|
|
|
typedef struct _ISAPNP_COMMON_EXTENSION
|
|
|
|
{
|
2021-03-04 12:48:43 +00:00
|
|
|
ISAPNP_SIGNATURE Signature;
|
2020-03-20 18:19:30 +00:00
|
|
|
PDEVICE_OBJECT Self;
|
|
|
|
ISAPNP_DEVICE_STATE State;
|
2010-04-07 20:19:29 +00:00
|
|
|
} ISAPNP_COMMON_EXTENSION, *PISAPNP_COMMON_EXTENSION;
|
2001-05-01 23:00:05 +00:00
|
|
|
|
2021-03-04 12:42:42 +00:00
|
|
|
typedef struct _ISAPNP_FDO_EXTENSION
|
|
|
|
{
|
2020-03-20 18:19:30 +00:00
|
|
|
ISAPNP_COMMON_EXTENSION Common;
|
|
|
|
PDEVICE_OBJECT Ldo;
|
|
|
|
PDEVICE_OBJECT Pdo;
|
2021-03-04 12:48:43 +00:00
|
|
|
PDEVICE_OBJECT ReadPortPdo; /**< @remarks The pointer is NULL for all inactive FDOs. */
|
2021-03-04 12:47:34 +00:00
|
|
|
ULONG BusNumber;
|
2021-03-04 12:43:44 +00:00
|
|
|
KEVENT DeviceSyncEvent;
|
2021-03-04 12:48:43 +00:00
|
|
|
|
|
|
|
_Guarded_by_(DeviceSyncEvent)
|
2020-03-20 18:19:30 +00:00
|
|
|
LIST_ENTRY DeviceListHead;
|
2021-03-04 12:48:43 +00:00
|
|
|
|
|
|
|
_Guarded_by_(DeviceSyncEvent)
|
2020-03-20 18:19:30 +00:00
|
|
|
ULONG DeviceCount;
|
2021-03-04 12:48:43 +00:00
|
|
|
|
2020-03-20 18:19:30 +00:00
|
|
|
PDRIVER_OBJECT DriverObject;
|
|
|
|
PUCHAR ReadDataPort;
|
2021-03-20 14:50:34 +00:00
|
|
|
ULONG Cards;
|
2021-03-04 12:48:43 +00:00
|
|
|
LIST_ENTRY BusLink;
|
2010-04-07 20:19:29 +00:00
|
|
|
} ISAPNP_FDO_EXTENSION, *PISAPNP_FDO_EXTENSION;
|
2001-05-01 23:00:05 +00:00
|
|
|
|
2021-03-04 12:42:42 +00:00
|
|
|
typedef struct _ISAPNP_PDO_EXTENSION
|
|
|
|
{
|
2020-03-20 18:19:30 +00:00
|
|
|
ISAPNP_COMMON_EXTENSION Common;
|
2020-03-16 18:43:37 +00:00
|
|
|
PISAPNP_FDO_EXTENSION FdoExt;
|
2021-03-04 12:48:43 +00:00
|
|
|
|
|
|
|
ULONG Flags;
|
|
|
|
#define ISAPNP_ENUMERATED 0x00000001 /**< @brief Whether the device has been reported to the PnP manager. */
|
|
|
|
#define ISAPNP_SCANNED_BY_READ_PORT 0x00000002 /**< @brief The bus has been scanned by Read Port PDO. */
|
|
|
|
#define ISAPNP_READ_PORT_ALLOW_FDO_SCAN 0x00000004 /**< @brief Allows the active FDO to scan the bus. */
|
2021-03-28 17:29:02 +00:00
|
|
|
#define ISAPNP_READ_PORT_NEED_REBALANCE 0x00000008 /**< @brief The I/O resource requirements have changed. */
|
2021-03-04 12:48:43 +00:00
|
|
|
|
2023-01-15 16:41:49 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
/* Data belonging to logical devices */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
PISAPNP_LOGICAL_DEVICE IsaPnpDevice;
|
|
|
|
|
|
|
|
PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList;
|
|
|
|
|
|
|
|
PCM_RESOURCE_LIST ResourceList;
|
|
|
|
ULONG ResourceListSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
ULONG SelectedPort;
|
|
|
|
};
|
|
|
|
|
2021-03-04 12:48:43 +00:00
|
|
|
_Write_guarded_by_(_Global_interlock_)
|
|
|
|
volatile LONG SpecialFiles;
|
2020-03-12 10:53:09 +00:00
|
|
|
} ISAPNP_PDO_EXTENSION, *PISAPNP_PDO_EXTENSION;
|
2001-05-01 23:00:05 +00:00
|
|
|
|
2021-03-04 12:48:43 +00:00
|
|
|
extern KEVENT BusSyncEvent;
|
|
|
|
|
|
|
|
_Guarded_by_(BusSyncEvent)
|
|
|
|
extern BOOLEAN ReadPortCreated;
|
|
|
|
|
|
|
|
_Guarded_by_(BusSyncEvent)
|
|
|
|
extern LIST_ENTRY BusListHead;
|
|
|
|
|
|
|
|
_Requires_lock_not_held_(BusSyncEvent)
|
|
|
|
_Acquires_lock_(BusSyncEvent)
|
|
|
|
FORCEINLINE
|
|
|
|
VOID
|
|
|
|
IsaPnpAcquireBusDataLock(VOID)
|
|
|
|
{
|
|
|
|
KeWaitForSingleObject(&BusSyncEvent, Executive, KernelMode, FALSE, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
_Releases_lock_(BusSyncEvent)
|
|
|
|
FORCEINLINE
|
|
|
|
VOID
|
|
|
|
IsaPnpReleaseBusDataLock(VOID)
|
|
|
|
{
|
|
|
|
KeSetEvent(&BusSyncEvent, IO_NO_INCREMENT, FALSE);
|
|
|
|
}
|
|
|
|
|
2021-03-04 12:43:44 +00:00
|
|
|
_Requires_lock_not_held_(FdoExt->DeviceSyncEvent)
|
|
|
|
_Acquires_lock_(FdoExt->DeviceSyncEvent)
|
|
|
|
FORCEINLINE
|
|
|
|
VOID
|
|
|
|
IsaPnpAcquireDeviceDataLock(
|
|
|
|
_In_ PISAPNP_FDO_EXTENSION FdoExt)
|
|
|
|
{
|
|
|
|
KeWaitForSingleObject(&FdoExt->DeviceSyncEvent, Executive, KernelMode, FALSE, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
_Releases_lock_(FdoExt->DeviceSyncEvent)
|
|
|
|
FORCEINLINE
|
|
|
|
VOID
|
|
|
|
IsaPnpReleaseDeviceDataLock(
|
|
|
|
_In_ PISAPNP_FDO_EXTENSION FdoExt)
|
|
|
|
{
|
|
|
|
KeSetEvent(&FdoExt->DeviceSyncEvent, IO_NO_INCREMENT, FALSE);
|
|
|
|
}
|
|
|
|
|
2010-04-07 20:19:29 +00:00
|
|
|
/* isapnp.c */
|
2013-05-09 14:06:21 +00:00
|
|
|
|
2021-03-20 14:51:29 +00:00
|
|
|
CODE_SEG("PAGE")
|
|
|
|
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);
|
|
|
|
|
|
|
|
CODE_SEG("PAGE")
|
|
|
|
BOOLEAN
|
|
|
|
FindIrqDescriptor(
|
|
|
|
_In_ PISAPNP_LOGICAL_DEVICE LogDevice,
|
|
|
|
_In_ ULONG Vector,
|
|
|
|
_Out_opt_ PUCHAR WriteOrder);
|
|
|
|
|
|
|
|
CODE_SEG("PAGE")
|
|
|
|
BOOLEAN
|
|
|
|
FindDmaDescriptor(
|
|
|
|
_In_ PISAPNP_LOGICAL_DEVICE LogDevice,
|
|
|
|
_In_ ULONG Channel,
|
|
|
|
_Out_opt_ PUCHAR WriteOrder);
|
|
|
|
|
|
|
|
CODE_SEG("PAGE")
|
|
|
|
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);
|
|
|
|
|
2021-03-28 17:29:02 +00:00
|
|
|
CODE_SEG("PAGE")
|
2023-01-15 16:41:49 +00:00
|
|
|
PIO_RESOURCE_REQUIREMENTS_LIST
|
2021-03-28 17:29:02 +00:00
|
|
|
IsaPnpCreateReadPortDORequirements(
|
|
|
|
_In_opt_ ULONG SelectedReadPort);
|
|
|
|
|
2023-01-15 16:41:49 +00:00
|
|
|
CODE_SEG("PAGE")
|
|
|
|
PCM_RESOURCE_LIST
|
|
|
|
IsaPnpCreateReadPortDOResources(VOID);
|
|
|
|
|
2021-03-04 12:48:43 +00:00
|
|
|
CODE_SEG("PAGE")
|
|
|
|
VOID
|
|
|
|
IsaPnpRemoveReadPortDO(
|
|
|
|
_In_ PDEVICE_OBJECT Pdo);
|
|
|
|
|
2021-03-04 12:43:44 +00:00
|
|
|
CODE_SEG("PAGE")
|
2020-03-16 17:07:24 +00:00
|
|
|
NTSTATUS
|
|
|
|
IsaPnpFillDeviceRelations(
|
2021-03-04 12:42:42 +00:00
|
|
|
_In_ PISAPNP_FDO_EXTENSION FdoExt,
|
|
|
|
_Inout_ PIRP Irp,
|
|
|
|
_In_ BOOLEAN IncludeDataPort);
|
2020-03-16 17:07:24 +00:00
|
|
|
|
2021-03-04 12:43:44 +00:00
|
|
|
CODE_SEG("INIT")
|
2013-05-09 14:06:21 +00:00
|
|
|
DRIVER_INITIALIZE DriverEntry;
|
|
|
|
|
2010-04-07 20:19:29 +00:00
|
|
|
/* fdo.c */
|
2021-03-04 12:43:44 +00:00
|
|
|
CODE_SEG("PAGE")
|
2010-04-07 20:19:29 +00:00
|
|
|
NTSTATUS
|
|
|
|
IsaFdoPnp(
|
2021-03-04 12:42:42 +00:00
|
|
|
_In_ PISAPNP_FDO_EXTENSION FdoExt,
|
|
|
|
_Inout_ PIRP Irp,
|
|
|
|
_In_ PIO_STACK_LOCATION IrpSp);
|
2001-05-01 23:00:05 +00:00
|
|
|
|
2021-03-04 12:48:43 +00:00
|
|
|
/* interface.c */
|
|
|
|
CODE_SEG("PAGE")
|
|
|
|
NTSTATUS
|
|
|
|
IsaFdoQueryInterface(
|
|
|
|
_In_ PISAPNP_FDO_EXTENSION FdoExt,
|
|
|
|
_In_ PIO_STACK_LOCATION IrpSp);
|
|
|
|
|
2010-04-07 20:19:29 +00:00
|
|
|
/* pdo.c */
|
2021-03-04 12:43:44 +00:00
|
|
|
CODE_SEG("PAGE")
|
2010-04-07 20:19:29 +00:00
|
|
|
NTSTATUS
|
|
|
|
IsaPdoPnp(
|
2021-03-04 12:42:42 +00:00
|
|
|
_In_ PISAPNP_PDO_EXTENSION PdoDeviceExtension,
|
|
|
|
_Inout_ PIRP Irp,
|
|
|
|
_In_ PIO_STACK_LOCATION IrpSp);
|
2001-05-01 23:00:05 +00:00
|
|
|
|
2021-03-04 12:48:43 +00:00
|
|
|
CODE_SEG("PAGE")
|
|
|
|
VOID
|
|
|
|
IsaPnpRemoveLogicalDeviceDO(
|
|
|
|
_In_ PDEVICE_OBJECT Pdo);
|
|
|
|
|
2010-04-07 20:19:29 +00:00
|
|
|
/* hardware.c */
|
2021-03-04 12:43:44 +00:00
|
|
|
CODE_SEG("PAGE")
|
2021-03-20 14:52:40 +00:00
|
|
|
UCHAR
|
2020-03-16 19:58:53 +00:00
|
|
|
IsaHwTryReadDataPort(
|
2021-03-04 12:42:42 +00:00
|
|
|
_In_ PUCHAR ReadDataPort);
|
2001-05-01 23:00:05 +00:00
|
|
|
|
2021-03-20 14:50:34 +00:00
|
|
|
_Requires_lock_held_(FdoExt->DeviceSyncEvent)
|
2021-03-04 12:43:44 +00:00
|
|
|
CODE_SEG("PAGE")
|
2010-04-07 20:19:29 +00:00
|
|
|
NTSTATUS
|
|
|
|
IsaHwFillDeviceList(
|
2021-03-04 12:42:42 +00:00
|
|
|
_In_ PISAPNP_FDO_EXTENSION FdoExt);
|
2001-05-01 23:00:05 +00:00
|
|
|
|
2021-03-20 14:53:54 +00:00
|
|
|
CODE_SEG("PAGE")
|
|
|
|
NTSTATUS
|
|
|
|
IsaHwConfigureDevice(
|
|
|
|
_In_ PISAPNP_FDO_EXTENSION FdoExt,
|
|
|
|
_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice,
|
|
|
|
_In_ PCM_RESOURCE_LIST Resources);
|
|
|
|
|
2021-03-04 12:43:44 +00:00
|
|
|
_IRQL_requires_max_(DISPATCH_LEVEL)
|
2021-03-20 14:52:40 +00:00
|
|
|
VOID
|
|
|
|
IsaHwWakeDevice(
|
|
|
|
_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice);
|
|
|
|
|
|
|
|
_IRQL_requires_max_(DISPATCH_LEVEL)
|
|
|
|
VOID
|
2010-04-07 20:19:29 +00:00
|
|
|
IsaHwDeactivateDevice(
|
2021-03-04 12:42:42 +00:00
|
|
|
_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice);
|
2001-05-01 23:00:05 +00:00
|
|
|
|
2021-03-04 12:43:44 +00:00
|
|
|
_IRQL_requires_max_(DISPATCH_LEVEL)
|
2021-03-20 14:52:40 +00:00
|
|
|
VOID
|
2010-04-07 20:19:29 +00:00
|
|
|
IsaHwActivateDevice(
|
2021-03-20 14:53:06 +00:00
|
|
|
_In_ PISAPNP_FDO_EXTENSION FdoExt,
|
2021-03-04 12:42:42 +00:00
|
|
|
_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice);
|
2005-10-06 21:39:18 +00:00
|
|
|
|
2021-03-20 14:52:40 +00:00
|
|
|
_IRQL_requires_max_(DISPATCH_LEVEL)
|
|
|
|
VOID
|
|
|
|
IsaHwWaitForKey(VOID);
|
|
|
|
|
2001-05-01 23:00:05 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2014-02-06 11:18:34 +00:00
|
|
|
|
|
|
|
#endif /* _ISAPNP_PCH_ */
|