Added scsi class driver skeleton.

svn path=/trunk/; revision=2087
This commit is contained in:
Eric Kohl 2001-07-23 06:13:48 +00:00
parent 9859f23c21
commit 3df0bbbfce
11 changed files with 639 additions and 3 deletions

View file

@ -0,0 +1,265 @@
/* $Id: class2.c,v 1.1 2001/07/23 06:12:07 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: services/storage/class2/class2.c
* PURPOSE: SCSI class driver
* PROGRAMMER: Eric Kohl (ekohl@rz-online.de)
*/
#include <ddk/ntddk.h>
#include "../include/scsi.h"
#include "../include/class2.h"
#define UNIMPLEMENTED do {DbgPrint("%s:%d: Function not implemented", __FILE__, __LINE__); for(;;);} while (0)
#define VERSION "0.0.1"
// ------------------------------------------------------- Public Interface
// DriverEntry
//
// DESCRIPTION:
// This function initializes the driver.
//
// RUN LEVEL:
// PASSIVE_LEVEL
//
// ARGUMENTS:
// IN PDRIVER_OBJECT DriverObject System allocated Driver Object
// for this driver
// IN PUNICODE_STRING RegistryPath Name of registry driver service
// key
//
// RETURNS:
// NTSTATUS
NTSTATUS STDCALL
DriverEntry(IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath)
{
DbgPrint("ScsiPort Driver %s\n", VERSION);
return(STATUS_SUCCESS);
}
VOID
ScsiClassDebugPrint(IN ULONG DebugPrintLevel,
IN PCHAR DebugMessage,
...)
{
char Buffer[256];
va_list ap;
#if 0
if (DebugPrintLevel > InternalDebugLevel)
return;
#endif
va_start(ap, DebugMessage);
vsprintf(Buffer, DebugMessage, ap);
va_end(ap);
DbgPrint(Buffer);
}
NTSTATUS STDCALL
ScsiClassAsynchronousCompletion(PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PVOID Context)
{
UNIMPLEMENTED;
}
VOID STDCALL
ScsiClassBuildRequest(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
UNIMPLEMENTED;
}
NTSTATUS STDCALL
ScsiClassClaimDevice(PDEVICE_OBJECT PortDeviceObject,
PSCSI_INQUIRY_DATA LunInfo,
BOOLEAN Release,
PDEVICE_OBJECT *NewPortDeviceObject OPTIONAL)
{
UNIMPLEMENTED;
}
NTSTATUS STDCALL
ScsiClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
IN PCCHAR ObjectNameBuffer,
IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
IN OUT PDEVICE_OBJECT *DeviceObject,
IN PCLASS_INIT_DATA InitializationData)
{
UNIMPLEMENTED;
}
NTSTATUS STDCALL
ScsiClassDeviceControl(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
UNIMPLEMENTED;
}
PVOID STDCALL
ScsiClassFindModePage(PCHAR ModeSenseBuffer,
ULONG Length,
UCHAR PageMode,
BOOLEAN Use6Byte)
{
UNIMPLEMENTED;
}
ULONG STDCALL
ScsiClassFindUnclaimedDevices(PCLASS_INIT_DATA InitializationData,
PSCSI_ADAPTER_BUS_INFO AdapterInformation)
{
UNIMPLEMENTED;
}
NTSTATUS STDCALL
ScsiClassGetCapabilities(PDEVICE_OBJECT PortDeviceObject,
PIO_SCSI_CAPABILITIES *PortCapabilities)
{
UNIMPLEMENTED;
}
NTSTATUS STDCALL
ScsiClassGetInquiryData(PDEVICE_OBJECT PortDeviceObject,
PSCSI_ADAPTER_BUS_INFO *ConfigInfo)
{
UNIMPLEMENTED;
}
ULONG STDCALL
ScsiClassInitialize(PVOID Argument1,
PVOID Argument2,
PCLASS_INIT_DATA InitializationData)
{
UNIMPLEMENTED;
}
VOID STDCALL
ScsiClassInitializeSrbLookasideList(PDEVICE_EXTENSION DeviceExtension,
ULONG NumberElements)
{
UNIMPLEMENTED;
}
NTSTATUS STDCALL
ScsiClassInternalIoControl(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
UNIMPLEMENTED;
}
BOOLEAN STDCALL
ScsiClassInterpretSenseInfo(PDEVICE_OBJECT DeviceObject,
PSCSI_REQUEST_BLOCK Srb,
UCHAR MajorFunctionCode,
ULONG IoDeviceCode,
ULONG RetryCount,
NTSTATUS *Status)
{
UNIMPLEMENTED;
}
NTSTATUS STDCALL
ScsiClassIoComplete(PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PVOID Context)
{
UNIMPLEMENTED;
}
NTSTATUS STDCALL
ScsiClassIoCompleteAssociated(PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PVOID Context)
{
UNIMPLEMENTED;
}
ULONG STDCALL
ScsiClassModeSense(PDEVICE_OBJECT DeviceObject,
CHAR ModeSenseBuffer,
ULONG Length,
UCHAR PageMode)
{
UNIMPLEMENTED;
}
ULONG STDCALL
ScsiClassQueryTimeOutRegistryValue(PUNICODE_STRING RegistryPath)
{
UNIMPLEMENTED;
}
NTSTATUS STDCALL
ScsiClassReadDriveCapacity(PDEVICE_OBJECT DeviceObject)
{
UNIMPLEMENTED;
}
VOID STDCALL
ScsiClassReleaseQueue(PDEVICE_OBJECT DeviceObject)
{
UNIMPLEMENTED;
}
NTSTATUS STDCALL
ScsiClassSendSrbAsynchronous(PDEVICE_OBJECT DeviceObject,
PSCSI_REQUEST_BLOCK Srb,
PIRP Irp,
PVOID BufferAddress,
ULONG BufferLength,
BOOLEAN WriteToDevice)
{
UNIMPLEMENTED;
}
NTSTATUS STDCALL
ScsiClassSendSrbSynchronous(PDEVICE_OBJECT DeviceObject,
PSCSI_REQUEST_BLOCK Srb,
PVOID BufferAddress,
ULONG BufferLength,
BOOLEAN WriteToDevice)
{
UNIMPLEMENTED;
}
VOID STDCALL
ScsiClassSplitRequest(PDEVICE_OBJECT DeviceObject,
PIRP Irp,
ULONG MaximumBytes)
{
UNIMPLEMENTED;
}
/* EOF */

View file

@ -0,0 +1,29 @@
; $Id: class2.def,v 1.1 2001/07/23 06:12:07 ekohl Exp $
;
; class2.def - export definition file for scsi class driver
;
LIBRARY CLASS2.SYS
EXPORTS
ScsiClassAsynchronousCompletion@12
ScsiClassBuildRequest@8
ScsiClassClaimDevice@16
ScsiClassCreateDeviceObject@20
ScsiClassDeviceControl@8
ScsiClassFindModePage@16
ScsiClassFindUnclaimedDevices@8
ScsiClassGetCapabilities@8
ScsiClassGetInquiryData@8
ScsiClassInitialize@12
ScsiClassInitializeSrbLookasideList@8
ScsiClassInternalIoControl@8
ScsiClassInterpretSenseInfo@24
ScsiClassIoComplete@12
ScsiClassIoCompleteAssociated@12
ScsiClassModeSense@16
ScsiClassQueryTimeOutRegistryValue@4
ScsiClassReadDriveCapacity@4
ScsiClassReleaseQueue@4
ScsiClassSendSrbAsynchronous@24
ScsiClassSendSrbSynchronous@20
ScsiClassSplitRequest@12
;EOF

View file

@ -0,0 +1,29 @@
; $Id: class2.edf,v 1.1 2001/07/23 06:12:07 ekohl Exp $
;
; class2.edf - export definition file for scsi class driver
;
LIBRARY CLASS2.SYS
EXPORTS
ScsiClassAsynchronousCompletion=ScsiClassAsynchronousCompletion@12
ScsiClassBuildRequest=ScsiClassBuildRequest@8
ScsiClassClaimDevice=ScsiClassClaimDevice@16
ScsiClassCreateDeviceObject=ScsiClassCreateDeviceObject@20
ScsiClassDeviceControl=ScsiClassDeviceControl@8
ScsiClassFindModePage=ScsiClassFindModePage@16
ScsiClassFindUnclaimedDevices=ScsiClassFindUnclaimedDevices@8
ScsiClassGetCapabilities=ScsiClassGetCapabilities@8
ScsiClassGetInquiryData=ScsiClassGetInquiryData@8
ScsiClassInitialize=ScsiClassInitialize@12
ScsiClassInitializeSrbLookasideList=ScsiClassInitializeSrbLookasideList@8
ScsiClassInternalIoControl=ScsiClassInternalIoControl@8
ScsiClassInterpretSenseInfo=ScsiClassInterpretSenseInfo@24
ScsiClassIoComplete=ScsiClassIoComplete@12
ScsiClassIoCompleteAssociated=ScsiClassIoCompleteAssociated@12
ScsiClassModeSense=ScsiClassModeSense@16
ScsiClassQueryTimeOutRegistryValue=ScsiClassQueryTimeOutRegistryValue@4
ScsiClassReadDriveCapacity=ScsiClassReadDriveCapacity@4
ScsiClassReleaseQueue=ScsiClassReleaseQueue@4
ScsiClassSendSrbAsynchronous=ScsiClassSendSrbAsynchronous@24
ScsiClassSendSrbSynchronous=ScsiClassSendSrbSynchronous@20
ScsiClassSplitRequest=ScsiClassSplitRequest@12
;EOF

View file

@ -0,0 +1,38 @@
#include <defines.h>
#include <reactos/resource.h>
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
VS_VERSION_INFO VERSIONINFO
FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", RES_STR_COMPANY_NAME
VALUE "FileDescription", "SCSI Port Driver\0"
VALUE "FileVersion", "0.0.0\0"
VALUE "InternalName", "scsiport\0"
VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
VALUE "OriginalFilename", "scsiport.sys\0"
VALUE "ProductName", RES_STR_PRODUCT_NAME
VALUE "ProductVersion", RES_STR_PRODUCT_VERSION
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

View file

@ -0,0 +1,46 @@
# $Id: makefile,v 1.1 2001/07/23 06:12:07 ekohl Exp $
#
#
PATH_TO_TOP = ../../..
TARGET=class2
OBJECTS = $(TARGET).o $(TARGET).coff
LIBS = $(PATH_TO_TOP)/ntoskrnl/ntoskrnl.a
CFLAGS = -D__NTDRIVER__ -I$(PATH_TO_TOP)/include
all: $(TARGET).sys $(TARGET).sys.unstripped $(TARGET).a
.phony: all
clean:
- $(RM) *.o $(TARGET).a $(TARGET).coff junk.tmp base.tmp temp.exp $(TARGET).sys $(TARGET).sys.unstripped
.phony: clean
install: $(FLOPPY_DIR)/drivers/$(TARGET).sys
$(FLOPPY_DIR)/drivers/$(TARGET).sys: $(TARGET).sys
$(CP) $(TARGET).sys $(FLOPPY_DIR)/drivers/$(TARGET).sys
dist: $(PATH_TO_TOP)/$(DIST_DIR)/drivers/$(TARGET).sys
$(PATH_TO_TOP)/$(DIST_DIR)/drivers/$(TARGET).sys: $(TARGET).sys
$(CP) $(TARGET).sys $(PATH_TO_TOP)/$(DIST_DIR)/drivers/$(TARGET).sys
$(TARGET).sys $(TARGET).sys.unstripped: $(OBJECTS) $(LIBS)
$(TARGET).a: $(TARGET).def
$(DLLTOOL) \
--dllname $(TARGET).sys \
--def $(TARGET).def \
--kill-at \
--output-lib $(TARGET).a
WARNINGS_ARE_ERRORS = yes
include $(PATH_TO_TOP)/rules.mak

View file

@ -0,0 +1,122 @@
/* $Id: class2.h,v 1.1 2001/07/23 06:12:34 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: services/storage/include/class2.h
* PURPOSE: SCSI class driver definitions
* PROGRAMMER: Eric Kohl (ekohl@rz-online.de)
*/
#ifndef __STORAGE_INCLUDE_CLASS2_H
#define __STORAGE_INCLUDE_CLASS2_H
#include "ntddscsi.h"
#include "srb.h"
struct _CLASS_INIT_DATA;
typedef VOID STDCALL
(*PCLASS_ERROR)(IN PDEVICE_OBJECT DeviceObject,
IN PSCSI_REQUEST_BLOCK Srb,
IN OUT NTSTATUS *Status,
IN OUT BOOLEAN *Retry);
typedef BOOLEAN STDCALL
(*PCLASS_DEVICE_CALLBACK)(IN PINQUIRYDATA);
typedef NTSTATUS STDCALL
(*PCLASS_READ_WRITE)(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
typedef BOOLEAN STDCALL
(*PCLASS_FIND_DEVICES)(IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath,
IN struct _CLASS_INIT_DATA *InitializationData,
IN PDEVICE_OBJECT PortDeviceObject,
IN ULONG PortNumber);
typedef NTSTATUS STDCALL
(*PCLASS_DEVICE_CONTROL)(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
typedef NTSTATUS STDCALL
(*PCLASS_SHUTDOWN_FLUSH)(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
typedef NTSTATUS STDCALL
(*PCLASS_CREATE_CLOSE)(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
typedef struct _CLASS_INIT_DATA
{
ULONG InitializationDataSize;
ULONG DeviceExtensionSize;
DEVICE_TYPE DeviceType;
ULONG DeviceCharacteristics;
PCLASS_ERROR ClassError;
PCLASS_READ_WRITE ClassReadWriteVerification;
PCLASS_DEVICE_CALLBACK ClassFindDeviceCallBack;
PCLASS_FIND_DEVICES ClassFindDevices;
PCLASS_DEVICE_CONTROL ClassDeviceControl;
PCLASS_SHUTDOWN_FLUSH ClassShutdownFlush;
PCLASS_CREATE_CLOSE ClassCreateClose;
PDRIVER_STARTIO ClassStartIo;
} CLASS_INIT_DATA, *PCLASS_INIT_DATA;
typedef struct _DEVICE_EXTENSION
{
ULONG Dummy;
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
/* FUNCTIONS ****************************************************************/
NTSTATUS
STDCALL
ScsiClassAsynchronousCompletion (
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
PVOID Context
);
VOID
STDCALL
ScsiClassBuildRequest (
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);
NTSTATUS
STDCALL
ScsiClassClaimDevice (
IN PDEVICE_OBJECT PortDeviceObject,
IN PSCSI_INQUIRY_DATA LunInfo,
IN BOOLEAN Release,
OUT PDEVICE_OBJECT *NewPortDeviceObject OPTIONAL
);
NTSTATUS
STDCALL
ScsiClassCreateDeviceObject (
IN PDRIVER_OBJECT DriverObject,
IN PCCHAR ObjectNameBuffer,
IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
IN OUT PDEVICE_OBJECT *DeviceObject,
IN PCLASS_INIT_DATA InitializationData
);
NTSTATUS
STDCALL
ScsiClassDeviceControl (
PDEVICE_OBJECT DeviceObject,
PIRP Irp
);
#endif /* __STORAGE_INCLUDE_CLASS2_H */
/* EOF */

View file

@ -0,0 +1,56 @@
/* $Id: ntddscsi.h,v 1.1 2001/07/23 06:12:34 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: services/storage/include/ntddscsi.h
* PURPOSE: Basic SCSI definitions
* PROGRAMMER: Eric Kohl (ekohl@rz-online.de)
*/
#ifndef __STORAGE_INCLUDE_NTDDSCSI_H
#define __STORAGE_INCLUDE_NTDDSCSI_H
typedef struct _SCSI_BUS_DATA
{
UCHAR NumberOfLogicalUnits;
UCHAR InitiatorBusId;
ULONG InquiryDataOffset;
}SCSI_BUS_DATA, *PSCSI_BUS_DATA;
typedef struct _SCSI_ADAPTER_BUS_INFO
{
UCHAR NumberOfBuses;
SCSI_BUS_DATA BusData[1];
} SCSI_ADAPTER_BUS_INFO, *PSCSI_ADAPTER_BUS_INFO;
typedef struct _IO_SCSI_CAPABILITIES
{
ULONG Length;
ULONG MaximumTransferLength;
ULONG MaximumPhysicalPages;
ULONG SupportedAsynchronousEvents;
ULONG AlignmentMask;
BOOLEAN TaggedQueuing;
BOOLEAN AdapterScansDown;
BOOLEAN AdapterUsesPio;
} IO_SCSI_CAPABILITIES, *PIO_SCSI_CAPABILITIES;
typedef struct _SCSI_INQUIRY_DATA
{
UCHAR PathId;
UCHAR TargetId;
UCHAR Lun;
BOOLEAN DeviceClaimed;
ULONG InquiryDataLength;
ULONG NextInquiryDataOffset;
UCHAR InquiryData[1];
}SCSI_INQUIRY_DATA, *PSCSI_INQUIRY_DATA;
#endif /* __STORAGE_INCLUDE_NTDDSCSI_H */
/* EOF */

View file

@ -0,0 +1,42 @@
/* $Id: scsi.h,v 1.1 2001/07/23 06:12:34 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: services/storage/include/scsi.h
* PURPOSE: SCSI class driver definitions
* PROGRAMMER: Eric Kohl (ekohl@rz-online.de)
*/
#ifndef __STORAGE_INCLUDE_SCSI_H
#define __STORAGE_INCLUDE_SCSI_H
typedef struct _INQUIRYDATA
{
UCHAR DeviceType:5;
UCHAR DeviceTypeQualifier:3;
UCHAR DeviceTypeModifier:7;
UCHAR RemovableMedia:1;
UCHAR Versions;
UCHAR ResponseDataFormat;
UCHAR AdditionalLength;
UCHAR Reserved[2];
UCHAR SoftReset:1;
UCHAR CommandQueue:1;
UCHAR Reserved2:1;
UCHAR LinkedCommands:1;
UCHAR Synchronous:1;
UCHAR Wide16Bit:1;
UCHAR Wide32Bit:1;
UCHAR RelativeAddressing:1;
UCHAR VendorId[8];
UCHAR ProductId[16];
UCHAR ProductRevisionLevel[4];
UCHAR VendorSpecific[20];
UCHAR Reserved3[40];
} INQUIRYDATA, *PINQUIRYDATA;
#endif /* __STORAGE_INCLUDE_SCSI_H */
/* EOF */

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.1 2001/07/21 07:30:26 ekohl Exp $
# $Id: makefile,v 1.2 2001/07/23 06:13:48 ekohl Exp $
#
#
PATH_TO_TOP = ../../..
@ -34,6 +34,13 @@ $(PATH_TO_TOP)/$(DIST_DIR)/drivers/$(TARGET).sys: $(TARGET).sys
$(TARGET).sys $(TARGET).sys.unstripped: $(OBJECTS) $(LIBS)
$(TARGET).a: $(TARGET).def
$(DLLTOOL) \
--dllname $(TARGET).sys \
--def $(TARGET).def \
--kill-at \
--output-lib $(TARGET).a
WARNINGS_ARE_ERRORS = yes
include $(PATH_TO_TOP)/rules.mak

View file

@ -1,7 +1,8 @@
; $Id: scsiport.def,v 1.1 2001/07/21 07:30:26 ekohl Exp $
; $Id: scsiport.def,v 1.2 2001/07/23 06:13:48 ekohl Exp $
;
; scsiport.def - export definition file for scsiport driver
;
LIBRARY SCSIPORT.SYS
EXPORTS
ScsiDebugPrint
ScsiPortCompleteRequest@20

View file

@ -1,7 +1,8 @@
; $Id: scsiport.edf,v 1.1 2001/07/21 07:30:26 ekohl Exp $
; $Id: scsiport.edf,v 1.2 2001/07/23 06:13:48 ekohl Exp $
;
; scsiport.def - export definition file for scsiport driver
;
LIBRARY SCSIPORT.SYS
EXPORTS
ScsiDebugPrint
ScsiPortCompleteRequest=ScsiPortCompleteRequest@20