|
|
(2 intermediate revisions by the same user not shown) |
Line 7: |
Line 7: |
| '''Ultibo Storage Interface unit''' | | '''Ultibo Storage Interface unit''' |
| | | |
− | This unit provides both the Storage device interface and the generic USB mass storage driver. | + | This unit provides the generic Storage device interface used by all storage drivers. |
− | | + | |
− | '''USB Mass Storage Devices'''
| + | |
− | | + | |
− | The USB Mass Storage Class Control/Bulk/Interrupt (CBI) Transport specification is approved for use only with full-speed floppy disk drives. CBI shall not be used in high-speed capable devices, or in devices other than floppy disk drives. CBI shall not be used in devices that implement LSDFS. Usage of CBI for any new design is discouraged.
| + | |
− | | + | |
− | Therefore the majority of USB Mass Storage devices use the Bulk only interface.
| + | |
− | | + | |
− | USB mass storage class devices normally use the SCSI command set and therefore the USB storage driver consumes the SCSI unit for the protocol and command definitions. USB mass storage devices are registered directly as Storage devices not as SCSI devices.
| + | |
| | | |
| === Constants === | | === Constants === |
Line 213: |
Line 205: |
| </div></div> | | </div></div> |
| <br /> | | <br /> |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''USB storage''' <code> USB_STORAGE_* </code></div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | | <code>USBSTORAGE_STORAGE_DESCRIPTION = 'USB Storage Device';</code>
| |
− | |
| |
− | |-
| |
− | |colspan="2"|
| |
− | |-
| |
− | | <code>USBSTORAGE_DRIVER_NAME = 'USB Mass Storage Driver';</code>
| |
− | | Name of USB storage driver
| |
− | |-
| |
− | |colspan="2"|
| |
− | |-
| |
− | |colspan="2"|''CB/CBI (Control/Bulk/Interrupt) Requests''
| |
− | |-
| |
− | | <code>USB_STORAGE_REQUEST_CBI_ADSC = 0;</code>
| |
− | |
| |
− | |-
| |
− | |colspan="2"|
| |
− | |-
| |
− | |colspan="2"|''BBB (Bulk Only) Requests''
| |
− | |-
| |
− | | <code>USB_STORAGE_REQUEST_BBB_RESET = $FF;</code>
| |
− | |
| |
− | |-
| |
− | | <code>USB_STORAGE_REQUEST_BBB_GET_MAX_LUN = $FE;</code>
| |
− | |
| |
− | |-
| |
− | |colspan="2"|
| |
− | |-
| |
− | |colspan="2"|''Command Block Wrapper''
| |
− | |-
| |
− | | <code>USB_STORAGE_CBW_SIGNATUR = $43425355;</code>
| |
− | |
| |
− | |-
| |
− | |colspan="2"|
| |
− | |-
| |
− | | <code>USB_STORAGE_CBW_FLAGS_OUT = $00;</code>
| |
− | |
| |
− | |-
| |
− | | <code>USB_STORAGE_CBW_FLAGS_IN = $80;</code>
| |
− | |
| |
− | |-
| |
− | |colspan="2"|
| |
− | |-
| |
− | | <code>USB_STORAGE_CBW_CB_LENGTH = 16;</code>
| |
− | |
| |
− | |-
| |
− | |colspan="2"|
| |
− | |-
| |
− | | <code>USB_STORAGE_CBW_SIZE = 31;</code>
| |
− | |
| |
− | |-
| |
− | |colspan="2"|
| |
− | |-
| |
− | |colspan="2"|''Command Status Wrapper''
| |
− | |-
| |
− | | <code>USB_STORAGE_CSW_SIGNATURE = $53425355;</code>
| |
− | |
| |
− | |-
| |
− | |colspan="2"|
| |
− | |-
| |
− | | <code>USB_STORAGE_CSW_STATUS_GOOD = $00;</code>
| |
− | |
| |
− | |-
| |
− | | <code>USB_STORAGE_CSW_STATUS_FAILED = $01;</code>
| |
− | |
| |
− | |-
| |
− | | <code>USB_STORAGE_CSW_STATUS_PHASE = $02;</code>
| |
− | |
| |
− | |-
| |
− | |colspan="2"|
| |
− | |-
| |
− | | <code>USB_STORAGE_CSW_SIZE = 13;</code>
| |
− | |
| |
− | |-
| |
− | |colspan="2"|
| |
− | |-
| |
− | |colspan="2"|''Command Data''
| |
− | |-
| |
− | | <code>USB_STORAGE_COMMAND_MAX_SIZE = 16;</code>
| |
− | |
| |
− | |-
| |
− | |colspan="2"|
| |
− | |-
| |
− | |colspan="2"|''Command Retry Counts''
| |
− | |-
| |
− | | <code>USB_STORAGE_READ_RETRIES = 2;</code>
| |
− | |
| |
− | |-
| |
− | | <code>USB_STORAGE_WRITE_RETRIES = 2;</code>
| |
− | |
| |
− | |-
| |
− | | <code>USB_STORAGE_STATUS_RETRIES = 2;</code>
| |
− | |
| |
− | |-
| |
− | | <code>USB_STORAGE_INQUIRY_RETRIES = 5;</code>
| |
− | |
| |
− | |-
| |
− | | <code>USB_STORAGE_READ_CAPACITY_RETRIES = 3;</code>
| |
− | |
| |
− | |-
| |
− | | <code>USB_STORAGE_TEST_UNIT_READY_RETRIES = 5;</code>
| |
− | | 10; TestingRPi
| |
− | |-
| |
− | |colspan="2"|
| |
− | |-
| |
− | |colspan="2"|''Peripheral Device Types''
| |
− | |-
| |
− | |colspan="2"|''These are a subset of the SCSI Peripheral Device Types''
| |
− | |-
| |
− | | <code>USB_STORAGE_DEVICE_TYPE_DISK = $00;</code>
| |
− | | SBC Direct-access device (e.g., UHD Floppy disk)
| |
− | |-
| |
− | | <code>USB_STORAGE_DEVICE_TYPE_CDROM = $05;</code>
| |
− | | MMC-5 CD-ROM device
| |
− | |-
| |
− | | <code>USB_STORAGE_DEVICE_TYPE_OPTICAL = $07;</code>
| |
− | | Optical memory device (e.g., Non-CD optical disks)
| |
− | |-
| |
− | | <code>USB_STORAGE_DEVICE_TYPE_RBC = $0E;</code>
| |
− | | RBC Direct-access device (e.g., UHD Floppy disk)
| |
− | |-
| |
− | | <code>USB_STORAGE_DEVICE_TYPE_UNKNOWN = $1F;</code>
| |
− | | Unknown or no device type
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
| | | |
| === Type definitions === | | === Type definitions === |
Line 398: |
Line 259: |
| {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" |
| |- | | |- |
− | | <code>TStorageDeviceControl = function(Storage:PStorageDevice; Request:Integer; Argument1:LongWord; var Argument2:LongWord):LongWord;</code> | + | | <code>TStorageDeviceControl = function(Storage:PStorageDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;</code> |
| | style="width: 40%;"| | | | style="width: 40%;"| |
| |- | | |- |
Line 499: |
Line 360: |
| |} | | |} |
| </div></div> | | </div></div> |
− |
| |
− | '''USB command block'''
| |
− |
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
| |
− | <code>PUSBCommandBlock = ^TUSBCommandBlock;</code>
| |
− |
| |
− | <code>TUSBCommandBlock = record</code>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | |colspan="2"|Note: SBC Command Block (Derived from TSCSICommandBlock)
| |
− | |-
| |
− | |colspan="2"|''SCSI Properties''
| |
− | |-
| |
− | | <code>Command:array[0..USB_STORAGE_COMMAND_MAX_SIZE - 1] of Byte;</code>
| |
− | | Command
| |
− | |-
| |
− | | <code>SenseData:array[0..63] of Byte;</code>
| |
− | | Request Sense
| |
− | |-
| |
− | | <code>Status:Byte;</code>
| |
− | | SCSI Status
| |
− | |-
| |
− | | <code>TargetID:Byte;</code>
| |
− | | Target Id
| |
− | |-
| |
− | | <code>TargetLUN:Byte;</code>
| |
− | | Target LUN
| |
− | |-
| |
− | | <code>CommandLength:Byte;</code>
| |
− | | Command Length
| |
− | |-
| |
− | | <code>DataLength:LongWord;</code>
| |
− | | Data Length
| |
− | |-
| |
− | | <code>Data:Pointer;</code>
| |
− | | Pointer to Data
| |
− | |-
| |
− | | <code>MessageOut:array[0..11] of Byte;</code>
| |
− | | Message out buffer
| |
− | |-
| |
− | | <code>MessageIn:array[0..11] of Byte;</code>
| |
− | | Message in buffer
| |
− | |-
| |
− | | <code>SenseCommandLength:Byte;</code>
| |
− | | Sense Command Length
| |
− | |-
| |
− | | <code>SenseDataLength:LongWord;</code>
| |
− | | Sense Data Length
| |
− | |-
| |
− | | <code>SenseCommand:array[0..5] of Byte;</code>
| |
− | | Sense Command
| |
− | |-
| |
− | | <code>ControllerStatus:LongWord;</code>
| |
− | | Controller Status
| |
− | |-
| |
− | | <code>TransferredBytes:LongWord;</code>
| |
− | | Transferred Bytes
| |
− | |-
| |
− | |colspan="2"|''USB Properties''
| |
− | |-
| |
− | | <code>Direction:Byte;</code>
| |
− | | USB Direction (eg USB_DIRECTION_OUT or USB_DIRECTION_IN)
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− |
| |
− | '''USB storage device'''
| |
− |
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
| |
− | <code>PUSBStorageDevice = ^TUSBStorageDevice;</code>
| |
− |
| |
− | <code>TUSBStorageDevice = record</code>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | |colspan="2"|''Storage Properties''
| |
− | |-
| |
− | | <code>Storage:TStorageDevice;</code>
| |
− | |
| |
− | |-
| |
− | |colspan="2"|''USB Properties''
| |
− | |-
| |
− | | <code>Subclass:Byte;</code>
| |
− | |
| |
− | |-
| |
− | | <code>Protocol:Byte;</code>
| |
− | |
| |
− | |-
| |
− | | <code>MaxLUN:Byte;</code>
| |
− | |
| |
− | |-
| |
− | | <code>Sequence:LongWord;</code>
| |
− | | For dCBWTag property
| |
− | |-
| |
− | | <code>Primary:PUSBStorageDevice;</code>
| |
− | | Primary storage device (for multi LUN devices)
| |
− | |-
| |
− | | <code>StorageInterface:PUSBInterface;</code>
| |
− | | USB Mass Storage device Interface
| |
− | |-
| |
− | | <code>ReadWait:TSemaphoreHandle;</code>
| |
− | | Read completed semaphore
| |
− | |-
| |
− | | <code>WriteWait:TSemaphoreHandle;</code>
| |
− | | Write completed semaphore
| |
− | |-
| |
− | | <code>InterruptWait:TSemaphoreHandle;</code>
| |
− | | Interrupt completed semaphore
| |
− | |-
| |
− | | <code>ReadRequest:PUSBRequest;</code>
| |
− | | Bulk IN Request
| |
− | |-
| |
− | | <code>WriteRequest:PUSBRequest;</code>
| |
− | | Bulk OUT Request
| |
− | |-
| |
− | | <code>InterruptRequest:PUSBRequest;</code>
| |
− | | Interrupt IN Request
| |
− | |-
| |
− | | <code>ReadEndpoint:PUSBEndpointDescriptor;</code>
| |
− | | Bulk IN Endpoint
| |
− | |-
| |
− | | <code>WriteEndpoint:PUSBEndpointDescriptor;</code>
| |
− | | Bulk OUT Endpoint
| |
− | |-
| |
− | | <code>InterruptEndpoint:PUSBEndpointDescriptor;</code>
| |
− | | Interrupt IN Endpoint
| |
− | |-
| |
− | | <code>PendingCount:LongWord;</code>
| |
− | | Number of USB requests pending for this storage
| |
− | |-
| |
− | | <code>WaiterThread:TThreadId;</code>
| |
− | | Thread waiting for pending requests to complete (for storage eject)
| |
− | |-
| |
− | |colspan="2"|''SCSI Properties''
| |
− | |-
| |
− | | <code>CommandBlock:TUSBCommandBlock;</code>
| |
− | |
| |
− | |-
| |
− | |colspan="2"|''ATAPI Properties''
| |
− | |-
| |
− | |
| |
− | | style="width: 50%;"|
| |
− | |-
| |
− | |colspan="2"|''RBC Properties''
| |
− | |-
| |
− | |
| |
− | | style="width: 50%;"|
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− |
| |
− | '''USB command block wrapper'''
| |
− |
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
| |
− | <code>PUSBCommandBlockWrapper = ^TUSBCommandBlockWrapper;</code>
| |
− |
| |
− | <code>TUSBCommandBlockWrapper = record</code>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | | <code>dCBWSignature:LongWord;</code>
| |
− | | style="width: 50%;"|
| |
− | |-
| |
− | | <code>dCBWTag:LongWord;</code>
| |
− | |
| |
− | |-
| |
− | | <code>dCBWDataTransferLength:LongWord;</code>
| |
− | |
| |
− | |-
| |
− | | <code>bCBWFlags:Byte;</code>
| |
− | |
| |
− | |-
| |
− | | <code>bCBWLUN:Byte;</code>
| |
− | |
| |
− | |-
| |
− | | <code>bCBWCBLength:Byte;</code>
| |
− | |
| |
− | |-
| |
− | | <code>CBWCB:array[0..USB_STORAGE_CBW_CB_LENGTH - 1] of Byte;</code>
| |
− | |
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− |
| |
− | '''USB command status wrapper'''
| |
− |
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
| |
− | <code>PUSBCommandStatusWrapper = ^TUSBCommandStatusWrapper;</code>
| |
− |
| |
− | <code>TUSBCommandStatusWrapper = record</code>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | | <code>dCSWSignature:LongWord;</code>
| |
− | | style="width: 50%;"|
| |
− | |-
| |
− | | <code>dCSWTag:LongWord;</code>
| |
− | |
| |
− | |-
| |
− | | <code>dCSWDataResidue:LongWord;</code>
| |
− | |
| |
− | |-
| |
− | | <code>bCSWStatus:Byte;</code>
| |
− | |
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
| <br /> | | <br /> |
| | | |
Line 983: |
Line 636: |
| ! Note | | ! Note |
| | None documented | | | None documented |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− |
| |
− | '''USB storage functions'''
| |
− |
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceRead(Storage:PStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | According to 3.4 of USB Mass Storage Bulk Only 1.0, requests must be queued one at a time to a device.
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceWrite(Storage:PStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | According to 3.4 of USB Mass Storage Bulk Only 1.0, requests must be queued one at a time to a device.
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceControl(Storage:PStorageDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | According to 3.4 of USB Mass Storage Bulk Only 1.0, requests must be queued one at a time to a device.
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDriverBind(Device:PUSBDevice; Interrface:PUSBInterface):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Bind the Storage driver to a USB device if it is suitable</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Device
| |
− | | The USB device to attempt to bind to
| |
− | |-
| |
− | ! Interrface
| |
− | | The USB interface to attempt to bind to (or nil for whole device)
| |
− | |-
| |
− | ! Return
| |
− | | USB_STATUS_SUCCESS if completed, USB_STATUS_DEVICE_UNSUPPORTED if unsupported or another error code on failure.
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDriverUnbind(Device:PUSBDevice; Interrface:PUSBInterface):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Unbind the Storage driver from a USB device</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Device
| |
− | | The USB device to unbind from
| |
− | |-
| |
− | ! Interrface
| |
− | | The USB interface to unbind from (or nil for whole device)
| |
− | |-
| |
− | ! Return
| |
− | | USB_STATUS_SUCCESS if completed or another error code on failure
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">procedure USBStorageReadComplete(Request:PUSBRequest);</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Called when a USB request from a USB storage bulk IN endpoint completes</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Request
| |
− | | The USB request which has completed
| |
− | |-
| |
− | ! Note
| |
− | | The thread that submitted the read request will hold the storage lock
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">procedure USBStorageWriteComplete(Request:PUSBRequest);</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Called when a USB request from a USB storage bulk OUT endpoint completes</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Request
| |
− | | The USB request which has completed
| |
− | |-
| |
− | ! Note
| |
− | | The thread that submitted the write request will hold the storage lock
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">procedure USBStorageInterruptComplete(Request:PUSBRequest);</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Called when a USB request from a USB storage IN interrupt endpoint completes</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Request
| |
− | | The USB request which has completed
| |
− | |-
| |
− | ! Note
| |
− | | The thread that submitted the interrupt request will hold the storage lock
| |
| |- | | |- |
| |} | | |} |
Line 1,111: |
Line 644: |
| | | |
| <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> |
− | <pre style="border: 0; padding-bottom:0px;">function StorageGetCount:LongWord; inline;</pre> | + | <pre style="border: 0; padding-bottom:0px;">function StorageGetCount:LongWord;</pre> |
| <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current storage count</div> | | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current storage count</div> |
| <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> |
Line 1,238: |
Line 771: |
| ! Note | | ! Note |
| | None documented | | | None documented |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− |
| |
− | '''USB storage helper functions'''
| |
− |
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageCheckDevice(Device:PUSBDevice):Boolean;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Check if the supplied USB device is suitable for detection as a Mass Storage Device</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Device
| |
− | | The USB device to check
| |
− | |-
| |
− | ! Return
| |
− | | True if the device is suitable or False if it is not
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageCheckSubclass(Subclass:Byte):Boolean;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | None documented
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageCheckProtocol(Protocol:Byte):Boolean;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | None documented
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageBlockSizeToBlockShift(BlockSize:LongWord):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | None documented
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStoragePatchDevice(Device:PUSBDevice; var Subclass,Protocol:Byte):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' A function to adjust the subclass and protocol parameters of known defective devices</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | None documented
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageFixupDevice(Device:PUSBDevice; var Vendor,Product:String):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' A function to adjust the vendor and product parameters of known defective devices</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | None documented
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceLock(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a Prevent Media Removal request to a storage device</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | None documented
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceUnlock(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a Allow Media Removal request to a storage device</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | None documented
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceLoad(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a Start Stop request to a storage device</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | None documented
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceEject(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a Start Stop request to a storage device</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | None documented
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceReset(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a Storage Reset request to a storage device</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | Reset recovery (5.3.4 in USB Mass Storage Bulk Only 1.0)
| |
− | For Reset Recovery the host shall issue in the following order: a) a Bulk-Only Mass Storage Reset b) a Clear Feature HALT to the Bulk-In endpoint c) a Clear Feature HALT to the Bulk-Out endpoint This is done in 3 steps. If the reset doesn't succeed, the device should be port reset.
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceGetInfo(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Obtain basic information about a storage device (Type, Size, State, Product etc)</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | None documented
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceGetStatus(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | Supported by Subclass SCSI/UFI/SFF8070
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceGetMaxLUN(Device:PUSBDevice; Storage:PUSBStorageDevice; var MaxLUN:Byte):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a Get Max LUN request to a storage device</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | None documented
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceClearStall(Device:PUSBDevice; Storage:PUSBStorageDevice; Endpoint:PUSBEndpointDescriptor):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a USB Clear Feature (HALT) to the supplied endpoint on a storage device</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | None documented
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceInquiry(Device:PUSBDevice; Storage:PUSBStorageDevice; var DeviceType,DeviceFlags:LongWord; var Vendor,Product,Revision:PChar):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a SCSI Inquiry command to a LUN on a storage device</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | Supported by Subclass SCSI/UFI/SFF8070
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceRequestSense(Device:PUSBDevice; Storage:PUSBStorageDevice; var SenseKey,ASC,ASCQ:Byte):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a SCSI Request Sense command to a LUN on a storage device</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | Supported by Subclass SCSI/UFI/SFF8070
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceReadCapacity(Device:PUSBDevice; Storage:PUSBStorageDevice; var BlockSize,BlockShift:LongWord; var BlockCount:Int64):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a SCSI Read Capacity command to a LUN on a storage device</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | Supported by Subclass SCSI/UFI/SFF8070
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceTestUnitReady(Device:PUSBDevice; Storage:PUSBStorageDevice; var DeviceFlags:LongWord):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a SCSI Test Unit Ready command to a LUN on a storage device</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | Supported by Subclass SCSI/UFI/SFF8070
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceRead10(Device:PUSBDevice; Storage:PUSBStorageDevice; Start:LongWord;Count:Word; Buffer:Pointer):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a SCSI Read10 command to a LUN on a storage device</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | Supported by Subclass SCSI/UFI/SFF8070
| |
− | Caller must hold the storage lock
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceWrite10(Device:PUSBDevice; Storage:PUSBStorageDevice; Start:LongWord; Count:Word; Buffer:Pointer):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a SCSI Write10 command to a LUN on a storage device</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | Supported by Subclass SCSI/UFI/SFF8070
| |
− | Caller must hold the storage lock
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceRead16(Device:PUSBDevice; Storage:PUSBStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a SCSI Read16 command to a LUN on a storage device</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | Supported by Subclass SCSI only (Only on devices > 2TB)
| |
− | Caller must hold the storage lock
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceWrite16(Device:PUSBDevice; Storage:PUSBStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a SCSI Write16 command to a LUN on a storage device</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | Supported by Subclass SCSI only (Only on devices > 2TB)
| |
− | Caller must hold the storage lock
| |
− | |-
| |
− | |}
| |
− | </div></div>
| |
− | <br />
| |
− | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
| |
− | <pre style="border: 0; padding-bottom:0px;">function USBStorageDeviceTransport(Device:PUSBDevice; Storage:PUSBStorageDevice; Command:PUSBCommandBlock):LongWord;</pre>
| |
− | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' Perform the appropriate transport sequence for the device based on subclass and protocol</div>
| |
− | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
| |
− | {| class="wikitable" style="font-size: 14px; background: white;"
| |
− | |-
| |
− | ! Note
| |
− | | Handles Command/Data/Status phases plus endpoint stall, reset and retry as per the specification. Supported by Subclass SCSI/UFI/SFF8070.
| |
− | Caller must hold the storage lock.
| |
| |- | | |- |
| |} | | |} |
This unit provides the generic Storage device interface used by all storage drivers.