Added cdrom class driver skeleton.

svn path=/trunk/; revision=2584
This commit is contained in:
Eric Kohl 2002-01-31 15:02:12 +00:00
parent ae35748cfa
commit 8acb48f0de
6 changed files with 328 additions and 4 deletions

View file

@ -58,7 +58,7 @@ NET_DEVICE_DRIVERS = ne2000
#
# storage drivers (don't change the order)
#
STORAGE_DRIVERS = class2 scsiport atapi disk
STORAGE_DRIVERS = class2 scsiport atapi disk cdrom
#
# system applications (required for startup)
@ -70,8 +70,8 @@ SYS_APPS = services shell winlogon
APPS = args hello test cat bench apc shm lpc thread event file gditest \
pteb consume dump_shared_data vmtest regtest alive mstest nptest \
objdir atomtest winhello partinfo mutex stats
#lzexpand mapi32 (missing imports)
#dsound (missing winmm.dll)
WINE_DLLS = rpcrt4 ole32 oleaut32 oledlg olepro32 olecli olesvr \

View file

@ -0,0 +1,5 @@
base.tmp
junk.tmp
temp.exp
cdrom.coff
cdrom.sys.unstripped

View file

@ -0,0 +1,243 @@
/* $Id: cdrom.c,v 1.1 2002/01/31 15:00:00 ekohl Exp $
*
*/
// -------------------------------------------------------------------------
#include <ddk/ntddk.h>
#include "../include/scsi.h"
#include "../include/class2.h"
#include "../include/ntddscsi.h"
//#define NDEBUG
#include <debug.h>
#define VERSION "V0.0.1"
BOOLEAN STDCALL
CdromFindDevices(PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath,
PCLASS_INIT_DATA InitializationData,
PDEVICE_OBJECT PortDeviceObject,
ULONG PortNumber);
NTSTATUS STDCALL
CdromDeviceControl(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
NTSTATUS STDCALL
CdromShutdownFlush(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
// DriverEntry
//
// DESCRIPTION:
// This function initializes the driver, locates and claims
// hardware resources, and creates various NT objects needed
// to process I/O requests.
//
// 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)
{
CLASS_INIT_DATA InitData;
DbgPrint("CD-ROM Class Driver %s\n",
VERSION);
DPRINT("RegistryPath '%wZ'\n",
RegistryPath);
InitData.InitializationDataSize = sizeof(CLASS_INIT_DATA);
InitData.DeviceExtensionSize = sizeof(DEVICE_EXTENSION); // + sizeof(DISK_DATA)
InitData.DeviceType = FILE_DEVICE_CD_ROM;
InitData.DeviceCharacteristics = 0;
InitData.ClassError = NULL; // CdromProcessError;
InitData.ClassReadWriteVerification = NULL; // CdromReadWriteVerification;
InitData.ClassFindDeviceCallBack = NULL; // CdromDeviceVerification;
InitData.ClassFindDevices = CdromFindDevices;
InitData.ClassDeviceControl = CdromDeviceControl;
InitData.ClassShutdownFlush = CdromShutdownFlush;
InitData.ClassCreateClose = NULL;
InitData.ClassStartIo = NULL;
return(ScsiClassInitialize(DriverObject,
RegistryPath,
&InitData));
}
// CdromFindDevices
//
// DESCRIPTION:
// This function searches for device that are attached to the given scsi port.
//
// 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
// IN PCLASS_INIT_DATA InitializationData Pointer to the main initialization data
// IN PDEVICE_OBJECT PortDeviceObject Scsi port device object
// IN ULONG PortNumber Port number
//
// RETURNS:
// TRUE: At least one disk drive was found
// FALSE: No disk drive found
//
BOOLEAN STDCALL
CdromFindDevices(PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath,
PCLASS_INIT_DATA InitializationData,
PDEVICE_OBJECT PortDeviceObject,
ULONG PortNumber)
{
PIO_SCSI_CAPABILITIES PortCapabilities;
PSCSI_ADAPTER_BUS_INFO AdapterBusInfo;
PCHAR Buffer;
#if 0
ULONG DeviceCount;
#endif
ULONG ScsiBus;
NTSTATUS Status;
// PCONFIGURATION_INFORMATION ConfigInfo;
DPRINT1("CdromFindDevices() called.\n");
/* Get port capabilities */
Status = ScsiClassGetCapabilities(PortDeviceObject,
&PortCapabilities);
if (!NT_SUCCESS(Status))
{
DPRINT("ScsiClassGetCapabilities() failed! (Status 0x%lX)\n", Status);
return(FALSE);
}
DPRINT1("MaximumTransferLength: %lu\n", PortCapabilities->MaximumTransferLength);
/* Get inquiry data */
Status = ScsiClassGetInquiryData(PortDeviceObject,
(PSCSI_ADAPTER_BUS_INFO *)&Buffer);
if (!NT_SUCCESS(Status))
{
DPRINT("ScsiClassGetInquiryData() failed! (Status 0x%lX)\n", Status);
return(FALSE);
}
/* Check whether there are unclaimed devices */
AdapterBusInfo = (PSCSI_ADAPTER_BUS_INFO)Buffer;
#if 0
DeviceCount = ScsiClassFindUnclaimedDevices(InitializationData,
AdapterBusInfo);
if (DeviceCount == 0)
{
DPRINT("ScsiClassFindUnclaimedDevices() returned 0!");
return(FALSE);
}
#endif
// ConfigInfo = IoGetConfigurationInformation();
// DPRINT1("Number of SCSI ports: %lu\n", ConfigInfo->ScsiPortCount);
/* Search each bus of this adapter */
for (ScsiBus = 0; ScsiBus < (ULONG)AdapterBusInfo->NumberOfBuses; ScsiBus++)
{
DPRINT("Searching bus %lu\n", ScsiBus);
#if 0
lunInfo = (PVOID)(Buffer + adapterInfo->BusData[scsiBus].InquiryDataOffset);
while (AdapterBusInfo->BusData[ScsiBus].InquiryDataOffset)
{
}
#endif
}
ExFreePool(Buffer);
ExFreePool(PortCapabilities);
return(TRUE);
}
// CdromDeviceControl
//
// DESCRIPTION:
// Answer requests for device control calls
//
// RUN LEVEL:
// PASSIVE_LEVEL
//
// ARGUMENTS:
// Standard dispatch arguments
//
// RETURNS:
// NTSTATUS
//
NTSTATUS STDCALL
CdromDeviceControl(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
DPRINT("CdromDeviceControl() called!\n");
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(STATUS_SUCCESS);
}
// CdromShutdownFlush
//
// DESCRIPTION:
// Answer requests for shutdown and flush calls
//
// RUN LEVEL:
// PASSIVE_LEVEL
//
// ARGUMENTS:
// Standard dispatch arguments
//
// RETURNS:
// NTSTATUS
//
NTSTATUS STDCALL
CdromShutdownFlush(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
DPRINT("CdromShutdownFlush() called!\n");
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(STATUS_SUCCESS);
}
/* EOF */

View file

@ -0,0 +1,39 @@
#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", "CD-ROM Class Driver\0"
VALUE "FileVersion", "0.0.1\0"
VALUE "InternalName", "cdrom\0"
VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
VALUE "OriginalFilename", "cdrom.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,17 @@
# $Id: makefile,v 1.1 2002/01/31 15:00:00 ekohl Exp $
PATH_TO_TOP = ../../..
TARGET_TYPE = driver
TARGET_NAME = cdrom
TARGET_DDKLIBS = class2.a
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -40,6 +40,16 @@ REGEDIT4
[\Registry\Machine\SYSTEM\CurrentControlSet\Control\ServiceGroupOrder]
"List"="SCSI Port;SCSI Miniport;Primary Disk;SCSI Class Helper;SCSI Class;Boot File System;Base;Pointer Port;Keyboard Port;Pointer Class;Keyboard Class;Video;File System"
[\Registry\Machine\SYSTEM\CurrentControlSet\Control\Session Manager]
[\Registry\Machine\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices]
"AUX"="\DosDevices\COM1"
"MAILSLOT"="\Device\MailSlot"
"NUL"="\Device\Null"
"PIPE"="\Device\NamedPipe"
"PRN"="\DosDevices\LPT1"
"UNC"="\Device\Mup"
[\Registry\Machine\SYSTEM\CurrentControlSet\Services]
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Atapi]
@ -54,6 +64,18 @@ REGEDIT4
"Start"=dword:00000001
"Type"=dword:00000001
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Cdfs]
"ImagePath"="system32\drivers\cdfs.sys"
"Group"="File System"
"Start"=dword:00000004
"Type"=dword:00000002
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Cdrom]
"ImagePath"="system32\drivers\cdrom.sys"
"Group"="SCSI Class"
"Start"=dword:00000004
"Type"=dword:00000001
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Class2]
"ImagePath"="system32\drivers\class2.sys"
"Group"="SCSI Class Helper"
@ -107,5 +129,3 @@ REGEDIT4
"Group"="Boot File System"
"Start"=dword:00000000
"Type"=dword:00000002