Author: janderwald
Date: Thu May 5 00:39:00 2011
New Revision: 51585
URL:
http://svn.reactos.org/svn/reactos?rev=51585&view=rev
Log:
[USBSTOR]
- Rename common device extension, it conflicts with classpnp.h header structures
- Start implementing disk ioctls
- Implement SRB_FUNCTION_CLAIM_DEVICE, SRB_FUNCTION_RELEASE_DEVICE
Added:
branches/usb-bringup/drivers/usb/usbstor/disk.c (with props)
Modified:
branches/usb-bringup/drivers/usb/usbstor/CMakeLists.txt
branches/usb-bringup/drivers/usb/usbstor/usbstor.c
branches/usb-bringup/drivers/usb/usbstor/usbstor.h
Modified: branches/usb-bringup/drivers/usb/usbstor/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbstor/CMakeLists.txt [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbstor/CMakeLists.txt [iso-8859-1] Thu May 5
00:39:00 2011
@@ -3,7 +3,7 @@
include_directories(${REACTOS_SOURCE_DIR}/ntoskrnl/include)
-add_library(usbstor SHARED descriptor.c fdo.c misc.c pdo.c scsi.c usbstor.c usbstor.rc)
+add_library(usbstor SHARED descriptor.c disk.c fdo.c misc.c pdo.c scsi.c usbstor.c
usbstor.rc)
set_module_type(usbstor kernelmodedriver)
add_importlibs(usbstor ntoskrnl hal usbd)
Added: branches/usb-bringup/drivers/usb/usbstor/disk.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbstor/disk.c (added)
+++ branches/usb-bringup/drivers/usb/usbstor/disk.c [iso-8859-1] Thu May 5 00:39:00 2011
@@ -1,0 +1,169 @@
+/*
+ * PROJECT: ReactOS Universal Serial Bus Bulk Storage Driver
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: drivers/usb/usbstor/disk.c
+ * PURPOSE: USB block storage device driver.
+ * PROGRAMMERS:
+ * James Tabor
+ * Michael Martin (michael.martin(a)reactos.org)
+ * Johannes Anderwald (johannes.anderwald(a)reactos.org)
+ */
+
+#include "usbstor.h"
+
+NTSTATUS
+USBSTOR_HandleExecuteSCSI(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp,
+ IN OUT PSCSI_REQUEST_BLOCK Request,
+ IN PPDO_DEVICE_EXTENSION PDODeviceExtension)
+{
+ DPRINT1("USBSTOR_HandleExecuteSCSI\n");
+
+ DbgBreakPoint();
+
+ Request->SrbStatus = SRB_STATUS_ERROR;
+ return STATUS_NOT_SUPPORTED;
+}
+
+NTSTATUS
+USBSTOR_HandleInternalDeviceControl(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ PIO_STACK_LOCATION IoStack;
+ PSCSI_REQUEST_BLOCK Request;
+ PPDO_DEVICE_EXTENSION PDODeviceExtension;
+ NTSTATUS Status;
+
+ //
+ // get current stack location
+ //
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+
+ //
+ // get request block
+ //
+ Request = (PSCSI_REQUEST_BLOCK)IoStack->Parameters.Others.Argument1;
+
+ //
+ // get device extension
+ //
+ PDODeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+ //
+ // sanity check
+ //
+ ASSERT(Request);
+ ASSERT(PDODeviceExtension);
+
+ switch(Request->Function)
+ {
+ case SRB_FUNCTION_EXECUTE_SCSI:
+ {
+ DPRINT1("SRB_FUNCTION_EXECUTE_SCSI\n");
+ Status = USBSTOR_HandleExecuteSCSI(DeviceObject, Irp, Request,
PDODeviceExtension);
+
+ }
+ case SRB_FUNCTION_RELEASE_DEVICE:
+ {
+ DPRINT1("SRB_FUNCTION_RELEASE_DEVICE\n");
+ //
+ // sanity check
+ //
+ ASSERT(PDODeviceExtension->Claimed == TRUE);
+
+ //
+ // release claim
+ //
+ PDODeviceExtension->Claimed = TRUE;
+ Status = STATUS_SUCCESS;
+ break;
+ }
+ case SRB_FUNCTION_CLAIM_DEVICE:
+ {
+ DPRINT1("SRB_FUNCTION_CLAIM_DEVICE\n");
+ //
+ // check if the device has been claimed
+ //
+ if (PDODeviceExtension->Claimed)
+ {
+ //
+ // device has already been claimed
+ //
+ Status = STATUS_DEVICE_BUSY;
+ Request->SrbStatus = SRB_STATUS_BUSY;
+ break;
+ }
+
+ //
+ // claim device
+ //
+ PDODeviceExtension->Claimed = TRUE;
+
+ //
+ // output device object
+ //
+ Request->DataBuffer = DeviceObject;
+
+ //
+ // completed successfully
+ //
+ Status = STATUS_SUCCESS;
+ break;
+ }
+ case SRB_FUNCTION_RELEASE_QUEUE:
+ {
+ DPRINT1("SRB_FUNCTION_RELEASE_QUEUE UNIMPLEMENTED\n");
+ Status = STATUS_NOT_IMPLEMENTED;
+ break;
+ }
+ case SRB_FUNCTION_FLUSH:
+ {
+ DPRINT1("SRB_FUNCTION_FLUSH UNIMPLEMENTED\n");
+ Status = STATUS_NOT_IMPLEMENTED;
+ break;
+ }
+ case SRB_FUNCTION_SET_LINK_TIMEOUT:
+ {
+ DPRINT1("SRB_FUNCTION_FLUSH UNIMPLEMENTED\n");
+ Status = STATUS_NOT_IMPLEMENTED;
+ break;
+ }
+ default:
+ {
+ //
+ // not supported
+ //
+ Status = STATUS_NOT_SUPPORTED;
+ Request->SrbStatus = SRB_STATUS_ERROR;
+ }
+ }
+
+ return Status;
+}
+
+NTSTATUS
+USBSTOR_HandleDeviceControl(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ PIO_STACK_LOCATION IoStack;
+
+ //
+ // get current stack location
+ //
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+
+ DPRINT1("USBSTOR_HandleDeviceControl IoControl %x\n",
IoStack->Parameters.DeviceIoControl.IoControlCode);
+ DPRINT1("USBSTOR_HandleDeviceControl InputBufferLength %x\n",
IoStack->Parameters.DeviceIoControl.InputBufferLength);
+ DPRINT1("USBSTOR_HandleDeviceControl OutputBufferLength %x\n",
IoStack->Parameters.DeviceIoControl.OutputBufferLength);
+ DPRINT1("USBSTOR_HandleDeviceControl InputBuffer %x\n",
IoStack->Parameters.DeviceIoControl.Type3InputBuffer);
+ DPRINT1("USBSTOR_HandleDeviceControl SystemBuffer %x\n",
Irp->AssociatedIrp.SystemBuffer);
+ DPRINT1("USBSTOR_HandleDeviceControl UserBuffer %x\n",
Irp->UserBuffer);
+ DPRINT1("USBSTOR_HandleDeviceControl MdlAddress %x\n",
Irp->MdlAddress);
+
+ //IOCTL_STORAGE_QUERY_PROPERTY
+
+ return STATUS_NOT_SUPPORTED;
+}
Propchange: branches/usb-bringup/drivers/usb/usbstor/disk.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: branches/usb-bringup/drivers/usb/usbstor/usbstor.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbstor/usbstor.c [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbstor/usbstor.c [iso-8859-1] Thu May 5 00:39:00
2011
@@ -134,11 +134,16 @@
PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
- DPRINT1("USBSTOR_DispatchDeviceControl\n");
- Irp->IoStatus.Information = 0;
- Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_SUCCESS;
+ NTSTATUS Status;
+
+ //
+ // handle requests
+ //
+ Status = USBSTOR_HandleDeviceControl(DeviceObject, Irp);
+
+ Irp->IoStatus.Information = 0;
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
}
@@ -148,12 +153,17 @@
PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
- DPRINT1("USBSTOR_DispatchScsi\n");
-
- Irp->IoStatus.Information = 0;
- Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_SUCCESS;
+ NTSTATUS Status;
+
+ //
+ // handle requests
+ //
+ Status = USBSTOR_HandleInternalDeviceControl(DeviceObject, Irp);
+
+ Irp->IoStatus.Information = 0;
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return Status;
}
NTSTATUS
@@ -165,7 +175,6 @@
//
// read write ioctl is not supported
//
- DPRINT1("USBSTOR_DispatchReadWrite\n");
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
@@ -178,12 +187,12 @@
PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
- PCOMMON_DEVICE_EXTENSION DeviceExtension;
+ PUSBSTOR_COMMON_DEVICE_EXTENSION DeviceExtension;
//
// get common device extension
//
- DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ DeviceExtension =
(PUSBSTOR_COMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
//
// is it for the FDO
Modified: branches/usb-bringup/drivers/usb/usbstor/usbstor.h
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbstor/usbstor.h [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbstor/usbstor.h [iso-8859-1] Thu May 5 00:39:00
2011
@@ -13,7 +13,7 @@
#include <usbdlib.h>
#include <stdio.h>
#include <wdmguid.h>
-
+#include <classpnp.h>
#define USB_STOR_TAG 'sbsu'
#define USB_MAXCHILDREN (16)
@@ -24,15 +24,15 @@
IN PDEVICE_OBJECT TargetDevice,
OUT PDEVICE_OBJECT *AttachedToDeviceObject);
-typedef struct _COMMON_DEVICE_EXTENSION
+typedef struct __COMMON_DEVICE_EXTENSION__
{
BOOLEAN IsFDO;
-}COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION;
-
-typedef struct
-{
- COMMON_DEVICE_EXTENSION Common;
// common device extension
+}USBSTOR_COMMON_DEVICE_EXTENSION, *PUSBSTOR_COMMON_DEVICE_EXTENSION;
+
+typedef struct
+{
+ USBSTOR_COMMON_DEVICE_EXTENSION Common;
// common device extension
PDEVICE_OBJECT FunctionalDeviceObject;
// functional device object
PDEVICE_OBJECT PhysicalDeviceObject;
// physical device object
@@ -50,12 +50,12 @@
typedef struct
{
- COMMON_DEVICE_EXTENSION Common;
+ USBSTOR_COMMON_DEVICE_EXTENSION Common;
PDEVICE_OBJECT LowerDeviceObject;
// points to FDO
UCHAR LUN;
// lun id
PVOID InquiryData;
// USB SCSI inquiry data
+ UCHAR Claimed;
// indicating if it has been claimed by upper driver
}PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
-
//
// max lun command identifier
@@ -213,3 +213,18 @@
NTSTATUS
USBSTOR_SendInquiryCmd(
IN PDEVICE_OBJECT DeviceObject);
+
+
+//---------------------------------------------------------------------
+//
+// disk.c routines
+//
+NTSTATUS
+USBSTOR_HandleInternalDeviceControl(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp);
+
+NTSTATUS
+USBSTOR_HandleDeviceControl(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp);