📄 vdiskmp.h
字号:
/////////////////////////////////////////////////////////////////////////////
//
// This source code (including its associated software) is owned by
// StorageCraft and is protected by United States and international
// intellectual property law, including copyright laws, patent laws,
// and treaty provisions.
//
// vdiskmp.h
//
/////////////////////////////////////////////////////////////////////////////
#ifndef _VDISKMP_H
#define _VDISKMP_H
#if DBG
// Print more details about events between work thread and I/O requests.
//#define DEBUGLEVEL1 1
// Print each SRB and 袲B name of the function
//#define DEBUGLEVEL_SCSI 1
#endif
#ifdef DEBUGLEVEL_SCSI
#define IF_SCSI(PrintDebugMessage) PrintDebugMessage
#else
#define IF_SCSI(Print)
#endif
#ifdef DEBUGLEVEL1
#define IF_1(PrintDebugMessage) PrintDebugMessage
#else
#define IF_1(Print)
#endif
// Debugger break
#if DBG
#define DBG_BREAK() do { DbgBreakPoint(); } while(0)
#else
#define DBG_BREAK() do {} while(0)
#endif
// Request codes for VDISK_SYSTEM_REQUEST
#define VDISK_REQUEST_INIT 0
#define VDISK_REQUEST_SHUTDOWN 1
#define VDISK_REQUEST_READ 2
#define VDISK_REQUEST_WRITE 3
// Request to be send to the system thread
typedef struct _VDISK_LUN_REQUEST
{
// List entry to be linked to the list
LIST_ENTRY Entry;
// Request code - see VDISK_REQUEST_xxx above
ULONG RequestCode;
// Request parameters stored by the caller
ULONG Parameter1;
ULONG Parameter2;
ULONG Parameter3;
LARGE_INTEGER Offset;
} VDISK_LUN_REQUEST, *PVDISK_LUN_REQUEST;
#define ParamInitFileName Parameter1
#define ParamInitDiskSize Parameter2
#define ParamInitStatus Parameter1
#define ParamInitEvent Parameter3
#define ParamShutdownEvent Parameter1
#define ParamTransferLen Parameter1
#define ParamTransferBuffer Parameter2
#define ParamTransferSrb Parameter3
// Number of virtual SCSI buses. We use only bus 0.
// VSPORT asks this value during VdiskMpNewDevice()
#define NUMBER_OF_BUSES 1
// Number of targets on a virtual bus.
// VSPORT asks this value during VdiskMpNewDevice()
#define NUMBER_OF_TARGETS 7
// Number of LUNs on a target. It is VSPORT fixed value.
#define NUMBER_OF_LUNS SCSI_MAXIMUM_LOGICAL_UNITS
// Initiator ID
// VSPORT asks this value during VdiskMpNewDevice()
#define INITIATOR_ID NUMBER_OF_TARGETS
//
// VDISK's flags
//
// Set if disk is read only
#define VDISK_LUN_READ_ONLY 1
// Set if SRB_FUNCTION_SHUTDOWN arrives or underlying FS volume dismount detected
#define VDISK_LUN_SHUTDOWN 2
// Set if thread for this Lun is signalted to finish
#define VDISK_LUN_THREAD_FINISHED 4
// Set if the underlying FS volume was noticed as dismounted
#define VDISK_LUN_DISMOUNT 8
#define VDISK_LUN_SIGN 'LunV'
struct _VDISK_DEVICE_EXTENSION;
typedef struct _VDISK_LUN_EXTENSION
{
// Signature
ULONG Sign;
// Lock struct
KSPIN_LOCK SpinLock;
// Device extension to which this LUN belongs
// Thread must know it to complete requests
struct _VDISK_DEVICE_EXTENSION *DeviceExtension;
// VDISK's flags
UCHAR Flags;
// TargetId
UCHAR TargetId;
// LUN
UCHAR LunId;
// Lock protecting it
KSPIN_LOCK RequestQueueLock;
// Event signaled when there are requests on the queue
KEVENT RequestQueueEvent;
// Signal shutdown
KEVENT ShutdownEvent;
// Worker thread object pointer
PVOID ThreadObject;
// File size
ULONG DiskSize;
// Buffer aligment information
FILE_ALIGNMENT_INFORMATION AlignmentInfo;
// Allocated aligned buffer (one page size)
PVOID AlignedBuf;
// Sense data
SENSE_DATA SenseData;
// Request queue
LIST_ENTRY RequestQueue;
// File name
WCHAR SzFileName[256];
} VDISK_LUN_EXTENSION, *PVDISK_LUN_EXTENSION;
// Device extension.
typedef struct _VDISK_DEVICE_EXTENSION
{
// Spinlock to access device extension
KSPIN_LOCK SpinLock;
// Array of LUNs to reset bus
PVDISK_LUN_EXTENSION Luns[NUMBER_OF_TARGETS*NUMBER_OF_LUNS];
} VDISK_DEVICE_EXTENSION, *PVDISK_DEVICE_EXTENSION;
// Device extension
typedef struct _THREAD_STORAGE
{
HANDLE FileHandle;
PVOID AlignedBuf;
} THREAD_STORAGE, *PTHREAD_STORAGE;
#endif // _VDISKMP_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -