2017-10-12 20:37:43 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Storport Driver
|
|
|
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
|
|
|
* PURPOSE: Storport driver common header file
|
|
|
|
* COPYRIGHT: Copyright 2017 Eric Kohl (eric.kohl@reactos.org)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _STORPORT_PCH_
|
|
|
|
#define _STORPORT_PCH_
|
|
|
|
|
|
|
|
#include <wdm.h>
|
|
|
|
#include <ntddk.h>
|
|
|
|
#include <stdio.h>
|
2017-10-14 17:12:24 +00:00
|
|
|
#include <memory.h>
|
2017-10-12 21:14:08 +00:00
|
|
|
|
|
|
|
/* Declare STORPORT_API functions as exports rather than imports */
|
|
|
|
#define _STORPORT_
|
2017-10-12 20:37:43 +00:00
|
|
|
#include <storport.h>
|
2017-10-12 21:14:08 +00:00
|
|
|
|
2017-10-12 20:37:43 +00:00
|
|
|
#include <ntddscsi.h>
|
|
|
|
#include <ntdddisk.h>
|
|
|
|
#include <mountdev.h>
|
2017-10-14 17:12:24 +00:00
|
|
|
#include <wdmguid.h>
|
|
|
|
|
|
|
|
/* Memory Tags */
|
2017-10-16 22:05:26 +00:00
|
|
|
#define TAG_GLOBAL_DATA 'DGtS'
|
|
|
|
#define TAG_INIT_DATA 'DItS'
|
|
|
|
#define TAG_MINIPORT_DATA 'DMtS'
|
|
|
|
#define TAG_ACCRESS_RANGE 'RAtS'
|
|
|
|
#define TAG_RESOURCE_LIST 'LRtS'
|
|
|
|
#define TAG_ADDRESS_MAPPING 'MAtS'
|
2017-10-12 20:37:43 +00:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
dsStopped,
|
|
|
|
dsStarted,
|
|
|
|
dsPaused,
|
|
|
|
dsRemoved,
|
|
|
|
dsSurpriseRemoved
|
|
|
|
} DEVICE_STATE;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
InvalidExtension = 0,
|
|
|
|
DriverExtension,
|
|
|
|
FdoExtension,
|
|
|
|
PdoExtension
|
|
|
|
} EXTENSION_TYPE;
|
|
|
|
|
2017-10-14 17:12:24 +00:00
|
|
|
typedef struct _DRIVER_INIT_DATA
|
|
|
|
{
|
|
|
|
LIST_ENTRY Entry;
|
|
|
|
HW_INITIALIZATION_DATA HwInitData;
|
|
|
|
} DRIVER_INIT_DATA, *PDRIVER_INIT_DATA;
|
|
|
|
|
2017-10-12 20:37:43 +00:00
|
|
|
typedef struct _DRIVER_OBJECT_EXTENSION
|
|
|
|
{
|
|
|
|
EXTENSION_TYPE ExtensionType;
|
|
|
|
PDRIVER_OBJECT DriverObject;
|
|
|
|
|
|
|
|
KSPIN_LOCK AdapterListLock;
|
|
|
|
LIST_ENTRY AdapterListHead;
|
|
|
|
ULONG AdapterCount;
|
|
|
|
|
2017-10-14 17:12:24 +00:00
|
|
|
LIST_ENTRY InitDataListHead;
|
2017-10-12 20:37:43 +00:00
|
|
|
} DRIVER_OBJECT_EXTENSION, *PDRIVER_OBJECT_EXTENSION;
|
|
|
|
|
2017-10-14 22:06:22 +00:00
|
|
|
typedef struct _MINIPORT_DEVICE_EXTENSION
|
|
|
|
{
|
|
|
|
struct _MINIPORT *Miniport;
|
|
|
|
UCHAR HwDeviceExtension[0];
|
|
|
|
} MINIPORT_DEVICE_EXTENSION, *PMINIPORT_DEVICE_EXTENSION;
|
|
|
|
|
2017-10-14 17:12:24 +00:00
|
|
|
typedef struct _MINIPORT
|
|
|
|
{
|
|
|
|
struct _FDO_DEVICE_EXTENSION *DeviceExtension;
|
|
|
|
PHW_INITIALIZATION_DATA InitData;
|
2017-10-15 11:10:08 +00:00
|
|
|
PORT_CONFIGURATION_INFORMATION PortConfig;
|
2017-10-14 22:06:22 +00:00
|
|
|
PMINIPORT_DEVICE_EXTENSION MiniportExtension;
|
2017-10-14 17:12:24 +00:00
|
|
|
} MINIPORT, *PMINIPORT;
|
|
|
|
|
2017-10-12 20:37:43 +00:00
|
|
|
typedef struct _FDO_DEVICE_EXTENSION
|
|
|
|
{
|
|
|
|
EXTENSION_TYPE ExtensionType;
|
|
|
|
|
|
|
|
PDEVICE_OBJECT Device;
|
|
|
|
PDEVICE_OBJECT LowerDevice;
|
|
|
|
PDEVICE_OBJECT PhysicalDevice;
|
2017-10-14 17:12:24 +00:00
|
|
|
PDRIVER_OBJECT_EXTENSION DriverExtension;
|
|
|
|
DEVICE_STATE PnpState;
|
2017-10-12 20:37:43 +00:00
|
|
|
LIST_ENTRY AdapterListEntry;
|
2017-10-14 17:12:24 +00:00
|
|
|
MINIPORT Miniport;
|
2017-10-15 11:10:08 +00:00
|
|
|
ULONG BusNumber;
|
|
|
|
ULONG SlotNumber;
|
2017-10-15 13:21:56 +00:00
|
|
|
PCM_RESOURCE_LIST AllocatedResources;
|
|
|
|
PCM_RESOURCE_LIST TranslatedResources;
|
2017-10-15 22:13:21 +00:00
|
|
|
BUS_INTERFACE_STANDARD BusInterface;
|
|
|
|
BOOLEAN BusInitialized;
|
2017-10-16 22:05:26 +00:00
|
|
|
PMAPPED_ADDRESS MappedAddressList;
|
2017-10-12 20:37:43 +00:00
|
|
|
} FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _PDO_DEVICE_EXTENSION
|
|
|
|
{
|
|
|
|
EXTENSION_TYPE ExtensionType;
|
|
|
|
|
|
|
|
PDEVICE_OBJECT AttachedFdo;
|
|
|
|
|
|
|
|
DEVICE_STATE PnpState;
|
|
|
|
|
|
|
|
} PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
|
|
|
|
|
|
|
|
|
|
|
|
/* fdo.c */
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
PortFdoPnp(
|
|
|
|
_In_ PDEVICE_OBJECT DeviceObject,
|
|
|
|
_In_ PIRP Irp);
|
|
|
|
|
|
|
|
|
2017-10-14 17:12:24 +00:00
|
|
|
/* miniport.c */
|
|
|
|
|
2017-10-14 22:06:22 +00:00
|
|
|
NTSTATUS
|
2017-10-14 17:12:24 +00:00
|
|
|
MiniportInitialize(
|
|
|
|
_In_ PMINIPORT Miniport,
|
|
|
|
_In_ PFDO_DEVICE_EXTENSION DeviceExtension,
|
|
|
|
_In_ PHW_INITIALIZATION_DATA HwInitializationData);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
MiniportFindAdapter(
|
|
|
|
_In_ PMINIPORT Miniport);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
MiniportHwInitialize(
|
|
|
|
_In_ PMINIPORT Miniport);
|
|
|
|
|
|
|
|
|
2017-10-12 20:37:43 +00:00
|
|
|
/* misc.c */
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ForwardIrpAndWait(
|
|
|
|
_In_ PDEVICE_OBJECT LowerDevice,
|
|
|
|
_In_ PIRP Irp);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
ForwardIrpAndForget(
|
|
|
|
_In_ PDEVICE_OBJECT LowerDevice,
|
|
|
|
_In_ PIRP Irp);
|
|
|
|
|
2017-10-14 17:12:24 +00:00
|
|
|
INTERFACE_TYPE
|
|
|
|
GetBusInterface(
|
|
|
|
PDEVICE_OBJECT DeviceObject);
|
2017-10-12 20:37:43 +00:00
|
|
|
|
2017-10-15 13:21:56 +00:00
|
|
|
PCM_RESOURCE_LIST
|
|
|
|
CopyResourceList(
|
|
|
|
POOL_TYPE PoolType,
|
|
|
|
PCM_RESOURCE_LIST Source);
|
|
|
|
|
2017-10-15 22:13:21 +00:00
|
|
|
NTSTATUS
|
|
|
|
QueryBusInterface(
|
|
|
|
PDEVICE_OBJECT DeviceObject,
|
|
|
|
PGUID Guid,
|
|
|
|
USHORT Size,
|
|
|
|
USHORT Version,
|
|
|
|
PBUS_INTERFACE_STANDARD Interface,
|
|
|
|
PVOID InterfaceSpecificData);
|
|
|
|
|
2017-10-16 22:05:26 +00:00
|
|
|
BOOLEAN
|
|
|
|
TranslateResourceListAddress(
|
|
|
|
PFDO_DEVICE_EXTENSION DeviceExtension,
|
|
|
|
INTERFACE_TYPE BusType,
|
|
|
|
ULONG SystemIoBusNumber,
|
|
|
|
STOR_PHYSICAL_ADDRESS IoAddress,
|
|
|
|
ULONG NumberOfBytes,
|
|
|
|
BOOLEAN InIoSpace,
|
|
|
|
PPHYSICAL_ADDRESS TranslatedAddress);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
AllocateAddressMapping(
|
|
|
|
PMAPPED_ADDRESS *MappedAddressList,
|
|
|
|
STOR_PHYSICAL_ADDRESS IoAddress,
|
|
|
|
PVOID MappedAddress,
|
|
|
|
ULONG NumberOfBytes,
|
|
|
|
ULONG BusNumber);
|
2017-10-15 13:21:56 +00:00
|
|
|
|
2017-10-12 20:37:43 +00:00
|
|
|
/* pdo.c */
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
PortPdoPnp(
|
|
|
|
_In_ PDEVICE_OBJECT DeviceObject,
|
|
|
|
_In_ PIRP Irp);
|
|
|
|
|
|
|
|
|
|
|
|
/* storport.c */
|
|
|
|
|
2017-10-14 17:12:24 +00:00
|
|
|
PHW_INITIALIZATION_DATA
|
|
|
|
PortGetDriverInitData(
|
|
|
|
PDRIVER_OBJECT_EXTENSION DriverExtension,
|
|
|
|
INTERFACE_TYPE InterfaceType);
|
|
|
|
|
2017-10-12 20:37:43 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
DriverEntry(
|
|
|
|
_In_ PDRIVER_OBJECT DriverObject,
|
|
|
|
_In_ PUNICODE_STRING RegistryPath);
|
|
|
|
|
|
|
|
#endif /* _STORPORT_PCH_ */
|