https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a9b97aededc058f415d32…
commit a9b97aededc058f415d32f761095e89e1bd93a7d
Author: Victor Perevertkin <victor(a)perevertkin.ru>
AuthorDate: Sun Nov 10 01:05:47 2019 +0300
Commit: Victor Perevertkin <victor.perevertkin(a)reactos.org>
CommitDate: Fri Jun 12 16:55:27 2020 +0300
[USBSTOR] General refactoring.
Remove unused structures and unused fields in device extensions.
Replaced magic numbers with constants
---
drivers/usb/usbstor/CMakeLists.txt | 3 -
drivers/usb/usbstor/fdo.c | 14 +-
drivers/usb/usbstor/misc.c | 8 +-
drivers/usb/usbstor/pdo.c | 118 +++++------------
drivers/usb/usbstor/scsi.c | 12 --
drivers/usb/usbstor/usbstor.h | 258 ++++++++-----------------------------
6 files changed, 93 insertions(+), 320 deletions(-)
diff --git a/drivers/usb/usbstor/CMakeLists.txt b/drivers/usb/usbstor/CMakeLists.txt
index eaaee54a62f..95ee0c18c58 100644
--- a/drivers/usb/usbstor/CMakeLists.txt
+++ b/drivers/usb/usbstor/CMakeLists.txt
@@ -1,7 +1,4 @@
-add_definitions(-DDEBUG_MODE)
-include_directories(${REACTOS_SOURCE_DIR}/ntoskrnl/include)
-
list(APPEND SOURCE
descriptor.c
disk.c
diff --git a/drivers/usb/usbstor/fdo.c b/drivers/usb/usbstor/fdo.c
index 7b5dfc04c9f..15af86f095a 100644
--- a/drivers/usb/usbstor/fdo.c
+++ b/drivers/usb/usbstor/fdo.c
@@ -42,7 +42,7 @@ USBSTOR_FdoHandleDeviceRelations(
IN PFDO_DEVICE_EXTENSION DeviceExtension,
IN OUT PIRP Irp)
{
- ULONG DeviceCount = 0;
+ INT32 DeviceCount = 0;
LONG Index;
PDEVICE_RELATIONS DeviceRelations;
PIO_STACK_LOCATION IoStack;
@@ -61,7 +61,7 @@ USBSTOR_FdoHandleDeviceRelations(
}
}
- DeviceRelations = (PDEVICE_RELATIONS)AllocateItem(PagedPool,
sizeof(DEVICE_RELATIONS) + (DeviceCount > 1 ? (DeviceCount-1) * sizeof(PDEVICE_OBJECT)
: 0));
+ DeviceRelations = ExFreePoolWithTag(PagedPool, sizeof(DEVICE_RELATIONS) +
(DeviceCount-1) * sizeof(PDEVICE_OBJECT), USB_STOR_TAG);
if (!DeviceRelations)
{
Irp->IoStatus.Information = 0;
@@ -106,7 +106,7 @@ USBSTOR_FdoHandleRemoveDevice(
DPRINT("Handling FDO removal %p\n", DeviceObject);
// FIXME: wait for devices finished processing
- for (Index = 0; Index < 16; Index++)
+ for (Index = 0; Index < USB_MAXCHILDREN; Index++)
{
if (DeviceExtension->ChildPDO[Index] != NULL)
{
@@ -198,17 +198,15 @@ USBSTOR_FdoHandleStartDevice(
ASSERT(InterfaceDesc->bLength == sizeof(USB_INTERFACE_DESCRIPTOR));
DPRINT("bInterfaceSubClass %x\n", InterfaceDesc->bInterfaceSubClass);
- if (InterfaceDesc->bInterfaceProtocol != 0x50)
+ if (InterfaceDesc->bInterfaceProtocol != USB_PROTOCOL_BULK)
{
DPRINT1("USB Device is not a bulk only device and is not currently
supported\n");
return STATUS_NOT_SUPPORTED;
}
- if (InterfaceDesc->bInterfaceSubClass == 0x04) // UFI subclass
+ if (InterfaceDesc->bInterfaceSubClass == USB_SUBCLASS_UFI)
{
- // FIXME: need to pad CDBs to 12 byte
- // mode select commands must be translated from 1AH / 15h to 5AH / 55h
- DPRINT1("[USBSTOR] Error: need to pad CDBs\n");
+ DPRINT1("USB Floppy devices are not supported\n");
return STATUS_NOT_SUPPORTED;
}
diff --git a/drivers/usb/usbstor/misc.c b/drivers/usb/usbstor/misc.c
index 3dbbf160813..040ca568d94 100644
--- a/drivers/usb/usbstor/misc.c
+++ b/drivers/usb/usbstor/misc.c
@@ -208,10 +208,9 @@ USBSTOR_GetMaxLUN(
PUCHAR Buffer;
NTSTATUS Status;
- Buffer = (PUCHAR)AllocateItem(NonPagedPool, sizeof(UCHAR));
+ Buffer = (PUCHAR)ExAllocatePoolWithTag(NonPagedPool, sizeof(UCHAR), USB_STOR_TAG);
if (!Buffer)
{
- FreeItem(Buffer);
return STATUS_INSUFFICIENT_RESOURCES;
}
@@ -221,7 +220,7 @@ USBSTOR_GetMaxLUN(
if (NT_SUCCESS(Status))
{
- if (*Buffer > 0xF)
+ if (*Buffer > MAX_LUN)
{
// invalid response documented in usb mass storage specification
Status = STATUS_DEVICE_DATA_ERROR;
@@ -243,7 +242,7 @@ USBSTOR_GetMaxLUN(
Status = STATUS_SUCCESS;
}
- FreeItem(Buffer);
+ ExFreePoolWithTag(Buffer, USB_STOR_TAG);
return Status;
}
@@ -258,6 +257,7 @@ USBSTOR_ResetDevice(
return Status;
}
+// if somebody wants to add UFI support, here is a useful function
#if 0
BOOLEAN
USBSTOR_IsFloppy(
diff --git a/drivers/usb/usbstor/pdo.c b/drivers/usb/usbstor/pdo.c
index d02c9504583..50996e396c6 100644
--- a/drivers/usb/usbstor/pdo.c
+++ b/drivers/usb/usbstor/pdo.c
@@ -15,107 +15,53 @@
#include <debug.h>
+static
LPCSTR
USBSTOR_GetDeviceType(
- IN PINQUIRYDATA InquiryData,
- IN UCHAR IsFloppy)
+ IN PINQUIRYDATA InquiryData)
{
- if (InquiryData->DeviceType == 0)
- {
- if (IsFloppy)
- {
- // floppy device
- return "SFloppy";
- }
-
- // direct access device
- return "Disk";
- }
-
switch (InquiryData->DeviceType)
{
- case 1:
- {
+ case DIRECT_ACCESS_DEVICE:
+ return "Disk";
+ case SEQUENTIAL_ACCESS_DEVICE:
// sequential device, i.e magnetic tape
return "Sequential";
- }
- case 4:
- {
- // write once device
+ case WRITE_ONCE_READ_MULTIPLE_DEVICE:
return "Worm";
- }
- case 5:
- {
- // CDROM device
+ case READ_ONLY_DIRECT_ACCESS_DEVICE:
return "CdRom";
- }
- case 7:
- {
- // optical memory device
+ case OPTICAL_DEVICE:
return "Optical";
- }
- case 8:
- {
- // medium change device
+ case MEDIUM_CHANGER:
return "Changer";
- }
default:
- {
- // other device
return "Other";
- }
}
}
+static
LPCSTR
USBSTOR_GetGenericType(
- IN PINQUIRYDATA InquiryData,
- IN UCHAR IsFloppy)
+ IN PINQUIRYDATA InquiryData)
{
- if (InquiryData->DeviceType == 0)
- {
- if (IsFloppy)
- {
- // floppy device
- return "GenSFloppy";
- }
-
- // direct access device
- return "GenDisk";
- }
-
switch (InquiryData->DeviceType)
{
- case 1:
- {
+ case DIRECT_ACCESS_DEVICE:
+ return "GenDisk";
+ case SEQUENTIAL_ACCESS_DEVICE:
// sequential device, i.e magnetic tape
return "GenSequential";
- }
- case 4:
- {
- // write once device
+ case WRITE_ONCE_READ_MULTIPLE_DEVICE:
return "GenWorm";
- }
- case 5:
- {
- // CDROM device
+ case READ_ONLY_DIRECT_ACCESS_DEVICE:
return "GenCdRom";
- }
- case 7:
- {
- // optical memory device
+ case OPTICAL_DEVICE:
return "GenOptical";
- }
- case 8:
- {
- // medium change device
+ case MEDIUM_CHANGER:
return "GenChanger";
- }
default:
- {
- // other device
return "UsbstorOther";
- }
}
}
@@ -210,7 +156,7 @@ USBSTOR_PdoHandleQueryDeviceText(
DeviceDescription.Length = 0;
DeviceDescription.MaximumLength = (USHORT)(Offset * sizeof(WCHAR));
- DeviceDescription.Buffer = (LPWSTR)AllocateItem(PagedPool,
DeviceDescription.MaximumLength);
+ DeviceDescription.Buffer = ExAllocatePoolWithTag(PagedPool,
DeviceDescription.MaximumLength, USB_STOR_TAG);
if (!DeviceDescription.Buffer)
{
Irp->IoStatus.Information = 0;
@@ -248,7 +194,7 @@ USBSTOR_PdoHandleQueryDeviceId(
ASSERT(DeviceExtension->InquiryData);
InquiryData = DeviceExtension->InquiryData;
- DeviceType = USBSTOR_GetDeviceType(InquiryData, DeviceExtension->IsFloppy);
+ DeviceType = USBSTOR_GetDeviceType(InquiryData);
// lets create device string
Offset = sprintf(&Buffer[Offset], "USBSTOR\\");
@@ -265,7 +211,7 @@ USBSTOR_PdoHandleQueryDeviceId(
// allocate DeviceId string
DeviceId.Length = 0;
DeviceId.MaximumLength = (USHORT)((strlen((PCHAR)Buffer) + 1) * sizeof(WCHAR));
- DeviceId.Buffer = (LPWSTR)AllocateItem(PagedPool, DeviceId.MaximumLength);
+ DeviceId.Buffer = ExAllocatePoolWithTag(PagedPool, DeviceId.MaximumLength,
USB_STOR_TAG);
if (!DeviceId.Buffer)
{
Irp->IoStatus.Information = 0;
@@ -338,8 +284,8 @@ USBSTOR_PdoHandleQueryHardwareId(
ASSERT(FDODeviceExtension->DeviceDescriptor);
InquiryData = PDODeviceExtension->InquiryData;
- DeviceType = USBSTOR_GetDeviceType(InquiryData, PDODeviceExtension->IsFloppy);
- GenericType = USBSTOR_GetGenericType(InquiryData, PDODeviceExtension->IsFloppy);
+ DeviceType = USBSTOR_GetDeviceType(InquiryData);
+ GenericType = USBSTOR_GetGenericType(InquiryData);
ASSERT(GenericType);
@@ -418,7 +364,7 @@ USBSTOR_PdoHandleQueryHardwareId(
TotalLength = Id1Length + Id2Length + Id3Length + Id4Length + Id5Length + Id6Length +
Id7Length + 1;
- Buffer = (LPWSTR)AllocateItem(PagedPool, TotalLength * sizeof(WCHAR));
+ Buffer = ExAllocatePoolWithTag(PagedPool, TotalLength * sizeof(WCHAR),
USB_STOR_TAG);
if (!Buffer)
{
Irp->IoStatus.Information = 0;
@@ -458,13 +404,13 @@ USBSTOR_PdoHandleQueryCompatibleId(
PDODeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
FDODeviceExtension =
(PFDO_DEVICE_EXTENSION)PDODeviceExtension->LowerDeviceObject->DeviceExtension;
ASSERT(FDODeviceExtension->DeviceDescriptor);
- DeviceType = USBSTOR_GetDeviceType(PDODeviceExtension->InquiryData,
PDODeviceExtension->IsFloppy);
+ DeviceType = USBSTOR_GetDeviceType(PDODeviceExtension->InquiryData);
// format instance id
Length = sprintf(Buffer, "USBSTOR\\%s", DeviceType) + 1;
Length += sprintf(&Buffer[Length], "USBSTOR\\%s", "RAW") +
2;
- InstanceId = (LPWSTR)AllocateItem(PagedPool, Length * sizeof(WCHAR));
+ InstanceId = ExAllocatePoolWithTag(PagedPool, Length * sizeof(WCHAR), USB_STOR_TAG);
if (!InstanceId)
{
Irp->IoStatus.Information = 0;
@@ -508,7 +454,7 @@ USBSTOR_PdoHandleQueryInstanceId(
Length = wcslen(Buffer) + 1;
- InstanceId = (LPWSTR)AllocateItem(PagedPool, Length * sizeof(WCHAR));
+ InstanceId = ExAllocatePoolWithTag(PagedPool, Length * sizeof(WCHAR), USB_STOR_TAG);
if (!InstanceId)
{
Irp->IoStatus.Information = 0;
@@ -542,7 +488,7 @@ USBSTOR_PdoHandleDeviceRelations(
return Irp->IoStatus.Status;
}
- DeviceRelations = (PDEVICE_RELATIONS)AllocateItem(PagedPool,
sizeof(DEVICE_RELATIONS));
+ DeviceRelations = ExAllocatePoolWithTag(PagedPool, sizeof(DEVICE_RELATIONS),
USB_STOR_TAG);
if (!DeviceRelations)
{
return STATUS_INSUFFICIENT_RESOURCES;
@@ -953,13 +899,9 @@ USBSTOR_CreatePDO(
return Status;
}
- if (PDODeviceExtension->InquiryData->DeviceType == DIRECT_ACCESS_DEVICE ||
PDODeviceExtension->InquiryData->DeviceType == READ_ONLY_DIRECT_ACCESS_DEVICE)
- {
- PDODeviceExtension->IsFloppy = FALSE; // TODO: implement the actual check
- }
- else
+ if (PDODeviceExtension->InquiryData->DeviceType != DIRECT_ACCESS_DEVICE
&&
+ PDODeviceExtension->InquiryData->DeviceType !=
READ_ONLY_DIRECT_ACCESS_DEVICE)
{
- // we work only with DIRECT_ACCESS_DEVICE for now
return STATUS_NOT_SUPPORTED;
}
diff --git a/drivers/usb/usbstor/scsi.c b/drivers/usb/usbstor/scsi.c
index be27921bd3a..946065649dd 100644
--- a/drivers/usb/usbstor/scsi.c
+++ b/drivers/usb/usbstor/scsi.c
@@ -137,7 +137,6 @@ USBSTOR_CSWCompletionRoutine(
PPDO_DEVICE_EXTENSION PDODeviceExtension;
PFDO_DEVICE_EXTENSION FDODeviceExtension;
PSCSI_REQUEST_BLOCK Request;
- PUFI_CAPACITY_RESPONSE Response;
Context = (PIRP_CONTEXT)Ctx;
@@ -191,17 +190,6 @@ USBSTOR_CSWCompletionRoutine(
Request->SrbStatus |= SRB_STATUS_AUTOSENSE_VALID;
}
- // read capacity needs special work
- if (Request->Cdb[0] == SCSIOP_READ_CAPACITY)
- {
- // get output buffer
- Response = (PUFI_CAPACITY_RESPONSE)Request->DataBuffer;
-
- // store in pdo
- PDODeviceExtension->BlockLength = NTOHL(Response->BlockLength);
- PDODeviceExtension->LastLogicBlockAddress =
NTOHL(Response->LastLogicalBlockAddress);
- }
-
Irp->IoStatus.Status = USBSTOR_SrbStatusToNtStatus(Request);
}
else if (Context->csw.Status == CSW_STATUS_COMMAND_FAILED)
diff --git a/drivers/usb/usbstor/usbstor.h b/drivers/usb/usbstor/usbstor.h
index 16bd314b56c..9e8b50e5701 100644
--- a/drivers/usb/usbstor/usbstor.h
+++ b/drivers/usb/usbstor/usbstor.h
@@ -8,22 +8,6 @@
#include <classpnp.h>
#define USB_STOR_TAG 'sbsu'
-#define USB_MAXCHILDREN (16)
-#define USBSTOR_DEFAULT_MAX_TRANSFER_LENGTH 0x10000
-
-#define HTONS(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n)
& 0xFF00) >> 8))
-#define NTOHS(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n)
& 0xFF00) >> 8))
-
-#define HTONL(n) (((((unsigned long)(n) & 0xFF)) << 24) | \
- ((((unsigned long)(n) & 0xFF00)) << 8) | \
- ((((unsigned long)(n) & 0xFF0000)) >> 8) | \
- ((((unsigned long)(n) & 0xFF000000)) >> 24))
-
-
-#define NTOHL(n) (((((unsigned long)(n) & 0xFF)) << 24) | \
- ((((unsigned long)(n) & 0xFF00)) << 8) | \
- ((((unsigned long)(n) & 0xFF0000)) >> 8) | \
- ((((unsigned long)(n) & 0xFF000000)) >> 24))
#ifndef BooleanFlagOn
#define BooleanFlagOn(Flags, SingleFlag) ((BOOLEAN)((((Flags) & (SingleFlag)) !=
0)))
@@ -33,9 +17,50 @@
#define SrbGetCdb(srb) ((PCDB)(srb->Cdb))
#endif
+// Storage subclass codes
+
+#define USB_SUBCLASS_RBC 0x01 // Typically, flash devices
+#define USB_SUBCLASS_8020 0x02 // CD-ROM
+#define USB_SUBCLASS_QIC 0x03 // QIC-157 Tapes
+#define USB_SUBCLASS_UFI 0x04 // Floppy
+#define USB_SUBCLASS_8070 0x05 // Removable media
+#define USB_SUBCLASS_SCSI 0x06 // Transparent
+#define USB_SUBCLASS_LOCKABLE 0x07 // Password-protected
+
+#define USB_SUBCLASS_ISD200 0xF0 // ISD200 ATA
+#define USB_SUBCLASS_CYP_ATACB 0xF1 // Cypress ATACB
+#define USB_SUBCLASS_VENDOR 0xFF // Use vendor specific
+
+// Storage protocol codes
+
+#define USB_PROTOCOL_CBI 0x00 // Control/Bulk/Interrupt
+#define USB_PROTOCOL_CB 0x01 // Control/Bulk w/o interrupt
+#define USB_PROTOCOL_BULK 0x50 // bulk only
+#define USB_PROTOCOL_UAS 0x62 // USB Attached SCSI
+#define USB_PROTOCOL_USBAT 0x80 // SCM-ATAPI bridge
+#define USB_PROTOCOL_EUSB_SDDR09 0x81 // SCM-SCSI bridge for SDDR-09
+#define USB_PROTOCOL_SDDR55 0x82 // SDDR-55 (made up)
+
+#define USB_PROTOCOL_DPCM_USB 0xF0 // Combination CB/SDDR09
+#define USB_PROTOCOL_FREECOM 0xF1 // Freecom
+#define USB_PROTOCOL_DATAFAB 0xF2 // Datafab chipsets
+#define USB_PROTOCOL_JUMPSHOT 0xF3 // Lexar Jumpshot
+#define USB_PROTOCOL_ALAUDA 0xF4 // Alauda chipsets
+#define USB_PROTOCOL_KARMA 0xF5 // Rio Karma
+#define USB_PROTOCOL_VENDOR 0xFF // Use vendor specific
+
+// Mass storage class-specific commands
+
+#define USB_BULK_GET_MAX_LUN 0xFE
+#define USB_BULK_RESET_DEVICE 0xFF
+
#define USB_RECOVERABLE_ERRORS (USBD_STATUS_STALL_PID | USBD_STATUS_DEV_NOT_RESPONDING \
| USBD_STATUS_ENDPOINT_HALTED | USBD_STATUS_NO_BANDWIDTH)
+#define USB_MAXCHILDREN 16
+#define MAX_LUN 0xF
+#define USBSTOR_DEFAULT_MAX_TRANSFER_LENGTH 0x10000
+
typedef struct __COMMON_DEVICE_EXTENSION__
{
BOOLEAN IsFDO;
@@ -61,7 +86,7 @@ typedef struct
UCHAR BulkInPipeIndex;
// bulk in pipe index
UCHAR BulkOutPipeIndex;
// bulk out pipe index
UCHAR MaxLUN;
// max lun for device
- PDEVICE_OBJECT ChildPDO[16];
// max 16 child pdo devices
+ PDEVICE_OBJECT ChildPDO[USB_MAXCHILDREN];
// max 16 child pdo devices
KSPIN_LOCK IrpListLock;
// irp list lock
LIST_ENTRY IrpListHead;
// irp list head
ULONG IrpPendingCount;
// count of irp pending
@@ -79,24 +104,17 @@ typedef struct
typedef struct
{
USBSTOR_COMMON_DEVICE_EXTENSION Common;
- PDEVICE_OBJECT LowerDeviceObject;
// points to FDO
+
UCHAR LUN;
// lun id
+ BOOLEAN Claimed;
// indicating if it has been claimed by upper driver
+ PDEVICE_OBJECT LowerDeviceObject;
// points to FDO
PINQUIRYDATA InquiryData;
// USB SCSI inquiry data
- PUCHAR FormatData;
// USB SCSI Read Format Capacity Data
- UCHAR Claimed;
// indicating if it has been claimed by upper driver
- ULONG BlockLength;
// length of block
- ULONG LastLogicBlockAddress;
// last block address
PDEVICE_OBJECT *PDODeviceObject;
// entry in pdo list
PDEVICE_OBJECT Self;
// self
- UCHAR MediumTypeCode;
// floppy medium type code
- UCHAR IsFloppy;
// is device floppy
}PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
-//
-// max lun command identifier
-//
-#define USB_BULK_GET_MAX_LUN 0xFE
-#define USB_BULK_RESET_DEVICE 0xFF
+#define CBW_SIGNATURE 0x43425355
+#define CSW_SIGNATURE 0x53425355
#include <pshpack1.h>
typedef struct
@@ -112,12 +130,6 @@ typedef struct
C_ASSERT(sizeof(CBW) == 31);
-
-#define CBW_SIGNATURE 0x43425355
-#define CSW_SIGNATURE 0x53425355
-
-#define MAX_LUN 0xF
-
#define CSW_STATUS_COMMAND_PASSED 0x00
#define CSW_STATUS_COMMAND_FAILED 0x01
#define CSW_STATUS_PHASE_ERROR 0x02
@@ -130,168 +142,7 @@ typedef struct
UCHAR Status; // CSW status
}CSW, *PCSW;
-//--------------------------------------------------------------------------------------------------------------------------------------------
-//
-// UFI read cmd
-//
-typedef struct
-{
- UCHAR Code; // operation code
- UCHAR LUN; // lun
- UCHAR LogicalBlockByte0; // lba byte 0
- UCHAR LogicalBlockByte1; // lba byte 1
- UCHAR LogicalBlockByte2; // lba byte 2
- UCHAR LogicalBlockByte3; // lba byte 3
- UCHAR Reserved; // reserved 0x00
- UCHAR ContiguousLogicBlocksByte0; // msb contiguous
logic blocks byte
- UCHAR ContiguousLogicBlocksByte1; // msb contiguous
logic blocks
- UCHAR Reserved1[3]; // reserved 0x00
-}UFI_READ_WRITE_CMD;
-
-C_ASSERT(sizeof(UFI_READ_WRITE_CMD) == 12);
-
-#define UFI_READ_WRITE_CMD_LEN (0xA)
-
-//--------------------------------------------------------------------------------------------------------------------------------------------
-//
-// UFI read capacity cmd
-//
-typedef struct
-{
- UCHAR Code; // operation code
0x25
- UCHAR LUN; // lun address
- UCHAR LBA[4]; // logical block
address, should be zero
- UCHAR Reserved1[2]; // reserved 0x00
- UCHAR PMI; // PMI = 0x00
- UCHAR Reserved2[3]; // reserved 0x00
-}UFI_CAPACITY_CMD, *PUFI_CAPACITY_CMD;
-
-C_ASSERT(sizeof(UFI_CAPACITY_CMD) == 12);
-
-#define UFI_CAPACITY_CMD_LEN 0xA //FIXME support length 16 too if requested
-
-//
-// UFI Read Capacity command response
-//
-typedef struct
-{
- ULONG LastLogicalBlockAddress; // last logical
block address
- ULONG BlockLength; // block length in
bytes
-}UFI_CAPACITY_RESPONSE, *PUFI_CAPACITY_RESPONSE;
-
-#define UFI_READ_CAPACITY_CMD_LEN 0xA
-C_ASSERT(sizeof(UFI_CAPACITY_RESPONSE) == 8);
-
-//--------------------------------------------------------------------------------------------------------------------------------------------
-//
-// UFI sense mode cmd
-//
-typedef struct
-{
- UCHAR Code; // operation code
- UCHAR LUN; // lun address
- UCHAR PageCode:6; // page code
selector
- UCHAR PC:2; // type of
parameters to be returned
- UCHAR Reserved[4]; // reserved 0x00
- USHORT AllocationLength; // parameters
length
- UCHAR Reserved1[3];
-}UFI_SENSE_CMD, *PUFI_SENSE_CMD;
-
-C_ASSERT(sizeof(UFI_SENSE_CMD) == 12);
-
-#define UFI_SENSE_CMD_LEN (6)
-
-typedef struct
-{
- USHORT ModeDataLength; // length of
parameters for sense cmd
- UCHAR MediumTypeCode; // 00 for mass
storage, 0x94 for floppy
- UCHAR WP:1; // write protect
bit
- UCHAR Reserved1:2; // reserved 00
- UCHAR DPOFUA:1; // should be zero
- UCHAR Reserved2:4; // reserved
- UCHAR Reserved[4]; // reserved
-}UFI_MODE_PARAMETER_HEADER, *PUFI_MODE_PARAMETER_HEADER;
-
-
-C_ASSERT(sizeof(UFI_MODE_PARAMETER_HEADER) == 8);
-
-typedef struct
-{
- UCHAR PC;
- UCHAR PageLength;
- UCHAR Reserved1;
- UCHAR ITM;
- UCHAR Flags;
- UCHAR Reserved[3];
-}UFI_TIMER_PROTECT_PAGE, *PUFI_TIMER_PROTECT_PAGE;
-C_ASSERT(sizeof(UFI_TIMER_PROTECT_PAGE) == 8);
-
-//--------------------------------------------------------------------------------------------------------------------------------------------
-//
-// UFI read capacity cmd
-//
-
-typedef struct
-{
- UCHAR Code;
- UCHAR LUN;
- UCHAR Reserved[5];
- UCHAR AllocationLengthMsb;
- UCHAR AllocationLengthLsb;
- UCHAR Reserved1[3];
-}UFI_READ_FORMAT_CAPACITY, *PUFI_READ_FORMAT_CAPACITY;
-
-C_ASSERT(sizeof(UFI_READ_FORMAT_CAPACITY) == 12);
-
-#define UFI_READ_FORMAT_CAPACITY_CMD_LEN (10)
-
-typedef struct
-{
- UCHAR Reserved1;
- UCHAR Reserved2;
- UCHAR Reserved3;
- UCHAR CapacityLength;
-}UFI_CAPACITY_FORMAT_HEADER, *PUFI_CAPACITY_FORMAT_HEADER;
-
-C_ASSERT(sizeof(UFI_CAPACITY_FORMAT_HEADER) == 4);
-
-typedef struct
-{
- ULONG BlockCount;
- UCHAR Code;
- UCHAR BlockLengthByte0;
- UCHAR BlockLengthByte1;
- UCHAR BlockLengthByte2;
-}UFI_CAPACITY_DESCRIPTOR, *PUFI_CAPACITY_DESCRIPTOR;
-
-#define UNFORMATTED_MEDIA_CODE_DESCRIPTORY_TYPE (1)
-#define FORMAT_MEDIA_CODE_DESCRIPTOR_TYPE (2)
-#define CARTRIDGE_MEDIA_CODE_DESCRIPTOR_TYPE (3)
-
-
-
-
-//--------------------------------------------------------------------------------------------------------------------------------------------
-//
-// UFI test unit command
-//
-
-typedef struct
-{
- UCHAR Code; // operation code
0x00
- UCHAR LUN; // lun
- UCHAR Reserved[10]; // reserved 0x00
-}UFI_TEST_UNIT_CMD, *PUFI_TEST_UNIT_CMD;
-
-C_ASSERT(sizeof(UFI_TEST_UNIT_CMD) == 12);
-
-#define UFI_TEST_UNIT_CMD_LEN (6)
-
-//-------------------------------------------------------------------------------------------------------------------------------------------
-typedef struct
-{
- UCHAR Bytes[16];
-}UFI_UNKNOWN_CMD, *PUFI_UNKNOWN_CMD;
+#include <poppack.h>
typedef struct
{
@@ -387,12 +238,6 @@ USBSTOR_ResetDevice(
IN PDEVICE_OBJECT DeviceObject,
IN PFDO_DEVICE_EXTENSION DeviceExtension);
-BOOLEAN
-USBSTOR_IsFloppy(
- IN PUCHAR Buffer,
- IN ULONG BufferLength,
- OUT PUCHAR MediumTypeCode);
-
//---------------------------------------------------------------------
//
// descriptor.c routines
@@ -482,7 +327,10 @@ USBSTOR_QueueTerminateRequest(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
-/* error.c */
+//---------------------------------------------------------------------
+//
+// error.c routines
+//
NTSTATUS
USBSTOR_GetEndpointStatus(
IN PDEVICE_OBJECT DeviceObject,
@@ -511,4 +359,4 @@ NTAPI
USBSTOR_QueueResetDevice(
IN PFDO_DEVICE_EXTENSION FDODeviceExtension);
-#endif /* _USBSTOR_H_ */
+#endif // _USBSTOR_H_