Difference between revisions of "Unit Storage"

From Ultibo.org
Jump to: navigation, search
 
(22 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
----
 
----
  
'''Storage Devices'''
+
'''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 ===
 
----
 
----
  
''To be documented''
 
  
=== Type definitions ===
+
<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;">'''Storage specific constants''' <code> STORAGE_* </code></div>
 
+
''To be documented''
+
 
+
=== Public variables ===
+
----
+
 
+
''To be documented''
+
 
+
=== Function declarations ===
+
----
+
 
+
 
+
'''Initialization 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;">procedure StorageInit;</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;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
| <code>STORAGE_NAME_PREFIX = 'Storage';</code>
| To be documented
+
| Name prefix for Storage Devices
 
|-
 
|-
|}
+
|colspan="2"|&nbsp;
</div></div>
+
<br />
+
 
+
'''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 StorageDeviceRead(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'''
+
| <code>STORAGE_STATUS_TIMER_INTERVAL = 1000;</code>
| To be documented
+
| &nbsp;
 
|-
 
|-
 
|}
 
|}
 
</div></div>
 
</div></div>
 
<br />
 
<br />
<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: 20px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceWrite(Storage:PStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;</pre>
+
<div style="font-size: 14px; padding-left: 12px;">'''Storage device type''' <code> STORAGE_TYPE_* </code></div>
<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;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
| <code>STORAGE_TYPE_NONE = 0;</code>
| To be documented
+
| style="width: 50%;"|&nbsp;
 
|-
 
|-
|}
+
| <code>STORAGE_TYPE_HDD = 1;</code>
</div></div>
+
| &nbsp;
<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 StorageDeviceErase(Storage:PStorageDevice; const Start,Count:Int64):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'''
+
| <code>STORAGE_TYPE_FDD = 2;</code>
| To be documented
+
| &nbsp;
 
|-
 
|-
|}
+
| <code>STORAGE_TYPE_CDROM = 3;</code>
</div></div>
+
| &nbsp;
<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 StorageDeviceControl(Storage:PStorageDevice; Request:Integer; Argument1:LongWord; var Argument2: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'''
+
| <code>STORAGE_TYPE_OPTICAL = 4;</code>
| To be documented
+
| &nbsp;
 
|-
 
|-
|}
+
| <code>STORAGE_TYPE_TAPE = 5;</code>
</div></div>
+
| &nbsp;
<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 StorageDeviceSetState(Storage:PStorageDevice; State:LongWord):LongWord;</pre>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the state of the specified storage and send a notification</div>
+
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
+
{| class="wikitable" style="font-size: 14px; background: white;"
+
 
|-
 
|-
! '''Storage'''
+
| <code>STORAGE_TYPE_REMOVABLE = 6;</code>
| The storage to set the state for
+
| &nbsp;
 
|-
 
|-
! '''State'''
+
|colspan="2"|&nbsp;
| The new state to set and notify
+
 
|-
 
|-
!'''Return'''
+
| <code>STORAGE_TYPE_MAX = 6;</code>
| ERROR_SUCCESS if completed or another error code on failure
+
| &nbsp;
 
|-
 
|-
 
|}
 
|}
 
</div></div>
 
</div></div>
 
<br />
 
<br />
<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: 20px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceStartStatus(Storage:PStorageDevice; Interval:LongWord):LongWord;</pre>
+
<div style="font-size: 14px; padding-left: 12px;">'''Storage device state''' <code> STORAGE_STATE_* </code></div>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Start status monitoring on the specified storage for insert/eject notifications</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Storage'''
+
| <code>STORAGE_STATE_EJECTED = 0;</code>
| The storage to start status monitoring for
+
| style="width: 50%;"|&nbsp;
 
|-
 
|-
! '''Interval'''
+
| <code>STORAGE_STATE_EJECTING = 1;</code>
| The status monitoring interval in milliseconds
+
| &nbsp;
 
|-
 
|-
!'''Return'''
+
| <code>STORAGE_STATE_INSERTING = 2;</code>
| ERROR_SUCCESS if completed or another error code on failure
+
| &nbsp;
 
|-
 
|-
|}
+
| <code>STORAGE_STATE_INSERTED = 3;</code>
</div></div>
+
| &nbsp;
<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 StorageDeviceStopStatus(Storage:PStorageDevice):LongWord;</pre>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Stop status monitoring on the specified storage for insert/eject notifications</div>
+
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
+
{| class="wikitable" style="font-size: 14px; background: white;"
+
 
|-
 
|-
! '''Storage'''
+
|colspan="2"|&nbsp;
| The storage to stop status monitoring for
+
 
|-
 
|-
!'''Return'''
+
| <code>STORAGE_STATE_MAX = 3;</code>
| ERROR_SUCCESS if completed or another error code on failure
+
| &nbsp;
 
|-
 
|-
 
|}
 
|}
 
</div></div>
 
</div></div>
 
<br />
 
<br />
<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: 20px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceCreate:PStorageDevice;</pre>
+
<div style="font-size: 14px; padding-left: 12px;">'''Storage device flag''' <code> STORAGE_FLAG_* </code></div>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Create a new Storage entry</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Return'''
+
| <code>STORAGE_FLAG_NONE = $00000000;</code>
| Pointer to new Storage entry or nil if storage could not be created
+
| style="width: 50%;"|&nbsp;
 
|-
 
|-
|}
+
| <code>STORAGE_FLAG_REMOVABLE = $00000001;</code>
</div></div>
+
| &nbsp;
<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 StorageDeviceCreateEx(Size:LongWord):PStorageDevice;</pre>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Create a new Storage entry</div>
+
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
+
{| class="wikitable" style="font-size: 14px; background: white;"
+
 
|-
 
|-
! '''Size'''
+
| <code>STORAGE_FLAG_LBA48 = $00000002;</code>
| Size in bytes to allocate for new storage (Including the storage entry)
+
| &nbsp;
 
|-
 
|-
!'''Return'''
+
| <code>STORAGE_FLAG_NOT_READY = $00000004;</code>
| Pointer to new Storage entry or nil if storage could not be created
+
| &nbsp;
 
|-
 
|-
|}
+
| <code>STORAGE_FLAG_NO_MEDIA = $00000008;</code>
</div></div>
+
| &nbsp;
<br />
+
|-
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
+
| <code>STORAGE_FLAG_READ_ONLY = $00000010;</code>
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceDestroy(Storage:PStorageDevice):LongWord;</pre>
+
| &nbsp;
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Destroy an existing Storage entry</div>
+
|-
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
+
| <code>STORAGE_FLAG_WRITE_ONLY = $00000020;</code>
{| class="wikitable" style="font-size: 14px; background: white;"
+
| &nbsp;
 
|-
 
|-
! '''Note'''
+
| <code>STORAGE_FLAG_ERASEABLE = $00000040;</code>
| To be documented
+
| &nbsp;
 +
|-
 +
| <code>STORAGE_FLAG_LOCKABLE = $00000080;</code>
 +
| &nbsp;
 +
|-
 +
| <code>STORAGE_FLAG_LOCKED = $00000100;</code>
 +
| &nbsp;
 +
|-
 +
| <code>STORAGE_FLAG_EJECTABLE = $00000200;</code>
 +
| &nbsp;
 +
|-
 +
| <code>STORAGE_FLAG_CHANGABLE = $00000400;</code>
 +
| &nbsp;
 
|-
 
|-
 
|}
 
|}
 
</div></div>
 
</div></div>
 
<br />
 
<br />
<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: 20px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceRegister(Storage:PStorageDevice):LongWord;</pre>
+
<div style="font-size: 14px; padding-left: 12px;">'''Storage device control code''' <code> STORAGE_CONTROL_* </code></div>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Register a new Storage in the Storage table</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
| <code>STORAGE_CONTROL_TEST_READY = 1;</code>
| To be documented
+
| Test Unit Ready
 +
|-
 +
| <code>STORAGE_CONTROL_RESET = 2;</code>
 +
| Reset Device
 +
|-
 +
| <code>STORAGE_CONTROL_TEST_MEDIA = 3;</code>
 +
| Test No Media
 +
|-
 +
| <code>STORAGE_CONTROL_LOCK = 4;</code>
 +
| Lock Media
 +
|-
 +
| <code>STORAGE_CONTROL_UNLOCK = 5;</code>
 +
| Unlock Media
 +
|-
 +
| <code>STORAGE_CONTROL_EJECT = 6;</code>
 +
| Eject Media
 +
|-
 +
| <code>STORAGE_CONTROL_TEST_LOCKED = 7;</code>
 +
| Test Media Locked
 +
|-
 +
| <code>STORAGE_CONTROL_TEST_CHANGED = 8;</code>
 +
| Test Media Changed
 +
|-
 +
| <code>STORAGE_CONTROL_GET_VENDORID = 9;</code>
 +
| Get Vendor Id
 +
|-
 +
| <code>STORAGE_CONTROL_GET_PRODUCTID = 10;</code>
 +
| Get Product Id
 +
|-
 +
| <code>STORAGE_CONTROL_GET_SERIAL = 11;</code>
 +
| Get Serial No
 +
|-
 +
| <code>STORAGE_CONTROL_GET_REVISION = 12;</code>
 +
| Get Revision No
 +
|-
 +
| <code>STORAGE_CONTROL_GET_PRODUCT = 13;</code>
 +
| Get Product Name
 +
|-
 +
| <code>STORAGE_CONTROL_GET_MANUFACTURER = 14;</code>
 +
| Get Manufacturer Name
 
|-
 
|-
 
|}
 
|}
 
</div></div>
 
</div></div>
<br />
+
<br />  
<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: 20px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceDeregister(Storage:PStorageDevice):LongWord;</pre>
+
<div style="font-size: 14px; padding-left: 12px;">'''Storage logging''' <code> STORAGE_LOG_* </code></div>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Deregister a Storage from the Storage table</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
| <code>STORAGE_LOG_LEVEL_DEBUG = LOG_LEVEL_DEBUG;</code>
| To be documented
+
| Storage debugging messages
 +
|-
 +
| <code>STORAGE_LOG_LEVEL_INFO = LOG_LEVEL_INFO;</code>
 +
| Storage informational messages, such as a device being attached or detached
 +
|-
 +
| <code>STORAGE_LOG_LEVEL_WARN = LOG_LEVEL_WARN;</code>
 +
| Storage warning messages
 +
|-
 +
| <code>STORAGE_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR;</code>
 +
| Storage error messages
 +
|-
 +
| <code>STORAGE_LOG_LEVEL_NONE = LOG_LEVEL_NONE;</code>
 +
| No Storage messages
 
|-
 
|-
 
|}
 
|}
 
</div></div>
 
</div></div>
 
<br />
 
<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 StorageDeviceFind(StorageId:LongWord):PStorageDevice;</pre>
+
=== Type definitions ===
<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;"
+
 
 +
'''Storage enumeration callback'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 
|-
 
|-
! '''Note'''
+
| <code>TStorageEnumerate = function(Storage:PStorageDevice; Data:Pointer):LongWord;</code>
| To be documented
+
| style="width: 40%;"|
 
|-
 
|-
 
|}
 
|}
</div></div>
+
 
<br />
+
'''Storage notification callback'''
<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 StorageDeviceFindByName(const Name:String):PStorageDevice; inline;</pre>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
<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'''
+
| <code>TStorageNotification = function(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;</code>
| To be documented
+
| style="width: 40%;"|
 
|-
 
|-
 
|}
 
|}
</div></div>
+
 
<br />
+
'''Storage device read'''
<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 StorageDeviceFindByDescription(const Description:String):PStorageDevice; inline;</pre>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
<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'''
+
| <code>TStorageDeviceRead = function(Storage:PStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;</code>
| To be documented
+
| style="width: 40%;"|
 
|-
 
|-
 
|}
 
|}
</div></div>
+
 
<br />
+
'''Storage device write'''
<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 StorageDeviceEnumerate(Callback:TStorageEnumerate; Data:Pointer):LongWord;</pre>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
<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'''
+
| <code>TStorageDeviceWrite = function(Storage:PStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;</code>
| To be documented
+
| style="width: 40%;"|
 
|-
 
|-
 
|}
 
|}
</div></div>
+
 
<br />
+
'''Storage device erase'''
<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 StorageDeviceNotification(Storage:PStorageDevice; Callback:TStorageNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;</pre>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
<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'''
+
| <code>TStorageDeviceErase = function(Storage:PStorageDevice; const Start,Count:Int64):LongWord;</code>
| To be documented
+
| style="width: 40%;"|
 
|-
 
|-
 
|}
 
|}
</div></div>
 
<br />
 
  
'''USB storage functions'''
+
'''Storage device control'''
 
   
 
   
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
<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'''
+
| <code>TStorageDeviceControl = function(Storage:PStorageDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;</code>
| According to 3.4 of USB Mass Storage Bulk Only 1.0, requests must be queued one at a time to a device
+
| style="width: 40%;"|
 
|-
 
|-
|}
+
|}  
</div></div>
+
<br />
+
'''Storage device'''
<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 class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<code>PStorageDevice = ^TStorageDevice;</code>
 +
 
 +
<code>TStorageDevice = record</code>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
|colspan="2"|''Device Properties''
| According to 3.4 of USB Mass Storage Bulk Only 1.0, requests must be queued one at a time to a device
+
 
|-
 
|-
|}
+
| <code>Device:TDevice;</code>
</div></div>
+
| The Device entry for this Storage
<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:LongWord; var Argument2: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'''
+
|colspan="2"|''Storage Properties''
| According to 3.4 of USB Mass Storage Bulk Only 1.0, requests must be queued one at a time to a device
+
 
|-
 
|-
|}
+
| <code>StorageId:LongWord;</code>
</div></div>
+
| Unique Id of this Storage in the Storage table
<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'''
+
| <code>StorageState:LongWord;</code>
| The USB device to attempt to bind to
+
| Storage state (eg STORAGE_STATE_INSERTED)
 
|-
 
|-
! '''Interrface'''
+
| <code>DeviceRead:TStorageDeviceRead;</code>
| The USB interface to attempt to bind to (or nil for whole device)
+
| A Device specific DeviceRead method implementing a standard Storage device interface
 
|-
 
|-
!'''Return'''
+
| <code>DeviceWrite:TStorageDeviceWrite;</code>
| USB_STATUS_SUCCESS if completed, USB_STATUS_DEVICE_UNSUPPORTED if unsupported or another error code on failure
+
| A Device specific DeviceWrite method implementing a standard Storage device interface
 
|-
 
|-
|}
+
| <code>DeviceErase:TStorageDeviceErase;</code>
</div></div>
+
| A Device specific DeviceErase method implementing a standard Storage device interface
<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'''
+
| <code>DeviceControl:TStorageDeviceControl;</code>
| The USB device to unbind from
+
| A Device specific DeviceControl method implementing a standard Storage device interface
 
|-
 
|-
! '''Interrface'''
+
|colspan="2"|''Driver Properties''
| The USB interface to unbind from (or nil for whole device)
+
 
|-
 
|-
!'''Return'''
+
| <code>Lock:TMutexHandle;</code>
| USB_STATUS_SUCCESS if completed or another error code on failure
+
| Storage lock
 
|-
 
|-
|}
+
| <code>TargetID:LongWord;</code>
</div></div>
+
| SCSI Id
<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'''
+
| <code>TargetLUN:LongWord;</code>
| The USB request which has completed
+
| LUN
 
|-
 
|-
!'''Note'''
+
| <code>BlockSize:LongWord;</code>
| The thread that submitted the read request will hold the storage lock
+
| Block Size
 
|-
 
|-
|}
+
| <code>BlockCount:Int64;</code>
</div></div>
+
| Number of Blocks
<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'''
+
| <code>BlockShift:LongWord;</code>
| The USB request which has completed
+
| Shift Count for Blocks to Bytes conversion (eg 9 for 512 byte blocks)
 
|-
 
|-
!'''Note'''
+
| <code>Vendor:PChar;</code>
| The thread that submitted the write request will hold the storage lock
+
| ATA Model, SCSI Vendor
 
|-
 
|-
|}
+
| <code>Product:PChar;</code>
</div></div>
+
| ATA Serial No, SCSI Product
<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'''
+
| <code>Revision:PChar;</code>
| The USB request which has completed
+
| Firmware Revision
 
|-
 
|-
!'''Note'''
+
| <code>StatusTimer:TTimerHandle;</code>
| The thread that submitted the interrupt request will hold the storage lock
+
| Timer for status change detection
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| <code>ReadCount:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ReadErrors:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>WriteCount:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>WriteErrors:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>EraseCount:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>EraseErrors:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Prev:PStorageDevice;</code>
 +
| Previous entry in Storage table
 +
|-
 +
| <code>Next:PStorageDevice;</code>
 +
| Next entry in Storage table
 
|-
 
|-
 
|}
 
|}
</div></div>
+
</div></div>
 
<br />
 
<br />
  
'''Storage helper functions'''
+
=== Public variables ===
 +
----
  
<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>
+
'''Storage logging'''
<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;">
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
{| class="wikitable" style="font-size: 14px; background: white;"
+
 
|-
 
|-
! '''Note'''
+
| <code>STORAGE_DEFAULT_LOG_LEVEL:LongWord = STORAGE_LOG_LEVEL_DEBUG;</code>
| To be documented
+
| style="width: 40%;"|Minimum level for Storage messages. Only messages with level greater than or equal to this will be printed.
 
|-
 
|-
 
|}
 
|}
</div></div>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
<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 StorageDeviceCheck(Storage:PStorageDevice):PStorageDevice;</pre>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Check if the supplied Storage is in the storage table</div>
+
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
+
{| class="wikitable" style="font-size: 14px; background: white;"
+
 
|-
 
|-
! '''Note'''
+
| <code>STORAGE_LOG_ENABLED:Boolean;</code>
| To be documented
+
| style="width: 40%;"|
 
|-
 
|-
 
|}
 
|}
</div></div>
 
 
<br />
 
<br />
 +
 +
=== Function declarations ===
 +
----
 +
 +
 +
'''Initialization functions'''
 +
 
<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 StorageDeviceTypeToString(StorageType:LongWord):String;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure StorageInit;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<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;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
 
</div></div>
 
</div></div>
 
<br />
 
<br />
 +
 +
'''Storage functions'''
 +
 
<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 StorageDeviceStateToString(StorageState:LongWord):String;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceRead(Storage:PStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<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;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 447: Line 416:
 
<br />
 
<br />
 
<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 StorageDeviceStateToNotification(State:LongWord):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceWrite(Storage:PStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Convert a Storage state value into the notification code for device notifications</div>
+
<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;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 459: Line 428:
 
<br />
 
<br />
 
<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;">procedure StorageLog(Level:LongWord; Storage:PStorageDevice; const AText:String);</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceErase(Storage:PStorageDevice; const Start,Count:Int64):LongWord;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<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;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 471: Line 440:
 
<br />
 
<br />
 
<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;">procedure StorageLogInfo(Storage:PStorageDevice; const AText:String);</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceControl(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 style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 483: Line 452:
 
<br />
 
<br />
 
<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;">procedure StorageLogError(Storage:PStorageDevice; const AText:String);</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceSetState(Storage:PStorageDevice; State:LongWord):LongWord;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the state of the specified storage and send a notification</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Storage
| To be documented
+
| The storage to set the state for
 
|-
 
|-
|}
+
! State
</div></div>
+
| The new state to set and notify
<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 StorageLogDebug(Storage:PStorageDevice; const AText:String);</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'''
+
! Return
| To be documented
+
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
 
|}
 
|}
Line 507: Line 470:
 
<br />
 
<br />
 
<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;">procedure StorageStatusTimer(Storage:PStorageDevice);</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceStartStatus(Storage:PStorageDevice; Interval:LongWord):LongWord;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Start status monitoring on the specified storage for insert/eject notifications</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Storage
| To be documented
+
| The storage to start status monitoring for
 +
|-
 +
! Interval
 +
| The status monitoring interval in milliseconds
 +
|-
 +
! Return
 +
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
 
|}
 
|}
 
</div></div>
 
</div></div>
 
<br />
 
<br />
 
'''USB storage helper functions'''
 
 
 
<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 USBStorageCheckSubclass(Subclass:Byte):Boolean;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceStopStatus(Storage:PStorageDevice):LongWord;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Stop status monitoring on the specified storage for insert/eject notifications</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Storage
| To be documented
+
| The storage to stop status monitoring for
 +
|-
 +
! Return
 +
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
 
|}
 
|}
Line 534: Line 503:
 
<br />
 
<br />
 
<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 USBStorageCheckProtocol(Protocol:Byte):Boolean;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceCreate:PStorageDevice;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Create a new Storage entry</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Return
| To be documented
+
| Pointer to new Storage entry or nil if storage could not be created
 
|-
 
|-
 
|}
 
|}
Line 546: Line 515:
 
<br />
 
<br />
 
<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 USBStorageBlockSizeToBlockShift(BlockSize:LongWord):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceCreateEx(Size:LongWord):PStorageDevice;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Create a new Storage entry</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Size
| To be documented
+
| Size in bytes to allocate for new storage (Including the storage entry)
 +
|-
 +
! Return
 +
| Pointer to new Storage entry or nil if storage could not be created
 
|-
 
|-
 
|}
 
|}
Line 558: Line 530:
 
<br />
 
<br />
 
<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 USBStoragePatchDevice(Device:PUSBDevice; var Subclass,Protocol:Byte):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceDestroy(Storage:PStorageDevice):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 style="font-size: 14px; padding-left: 12px;">'''Description:''' Destroy an existing Storage entry</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 570: Line 542:
 
<br />
 
<br />
 
<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 USBStorageFixupDevice(Device:PUSBDevice; var Vendor,Product:String):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceRegister(Storage:PStorageDevice):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 style="font-size: 14px; padding-left: 12px;">'''Description:''' Register a new Storage in the Storage table</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 582: Line 554:
 
<br />
 
<br />
 
<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 USBStorageDeviceLock(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceDeregister(Storage:PStorageDevice):LongWord;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a Prevent Media Removal request to a storage device</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Deregister a Storage from the Storage table</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 594: Line 566:
 
<br />
 
<br />
 
<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 USBStorageDeviceUnlock(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceFind(StorageId:LongWord):PStorageDevice;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a Allow Media Removal request to a storage device</div>
+
<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;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 606: Line 578:
 
<br />
 
<br />
 
<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 USBStorageDeviceLoad(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceFindByDevice(Device:PDevice):PStorageDevice;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a Start Stop request to a storage device</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Find a Storage device by the matching DeviceData property</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Device
| To be documented
+
| The device entry to match with the DeviceData value
 +
|-
 +
! Return
 +
| The Storage device matched or nil if none found
 
|-
 
|-
 
|}
 
|}
Line 618: Line 593:
 
<br />
 
<br />
 
<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 USBStorageDeviceEject(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceFindByName(const Name:String):PStorageDevice; inline;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a Start Stop request to a storage device</div>
+
<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;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 630: Line 605:
 
<br />
 
<br />
 
<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 USBStorageDeviceReset(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceFindByDescription(const Description:String):PStorageDevice; inline;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a Storage Reset request to a storage device</div>
+
<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;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! 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.
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 642: Line 617:
 
<br />
 
<br />
 
<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 USBStorageDeviceGetInfo(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceEnumerate(Callback:TStorageEnumerate; Data:Pointer):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 style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 654: Line 629:
 
<br />
 
<br />
 
<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 USBStorageDeviceGetStatus(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceNotification(Storage:PStorageDevice; Callback:TStorageNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<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;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Supported by Subclass SCSI/UFI/SFF8070
+
| None documented
 
|-
 
|-
 
|}
 
|}
 
</div></div>
 
</div></div>
 
<br />
 
<br />
 +
 +
'''Storage helper functions'''
 +
 
<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 USBStorageDeviceGetMaxLUN(Device:PUSBDevice; Storage:PUSBStorageDevice; var MaxLUN:Byte):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageGetCount:LongWord;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a Get Max LUN request to a storage device</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 678: Line 656:
 
<br />
 
<br />
 
<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 USBStorageDeviceClearStall(Device:PUSBDevice; Storage:PUSBStorageDevice; Endpoint:PUSBEndpointDescriptor):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceCheck(Storage:PStorageDevice):PStorageDevice;</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 style="font-size: 14px; padding-left: 12px;">'''Description:''' Check if the supplied Storage is in the storage table</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| To be documented
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 690: Line 668:
 
<br />
 
<br />
 
<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 USBStorageDeviceInquiry(Device:PUSBDevice; Storage:PUSBStorageDevice; var DeviceType,DeviceFlags:LongWord;v ar Vendor,Product,Revision:PChar):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceTypeToString(StorageType:LongWord):String;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a SCSI Inquiry command to a LUN on a storage device</div>
+
<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;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Supported by Subclass SCSI/UFI/SFF8070
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 702: Line 680:
 
<br />
 
<br />
 
<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 USBStorageDeviceRequestSense(Device:PUSBDevice; Storage:PUSBStorageDevice; var SenseKey,ASC,ASCQ:Byte):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceStateToString(StorageState:LongWord):String;</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 style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Supported by Subclass SCSI/UFI/SFF8070
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 714: Line 692:
 
<br />
 
<br />
 
<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 USBStorageDeviceReadCapacity(Device:PUSBDevice; Storage:PUSBStorageDevice; var BlockSize,BlockShift:LongWord; var BlockCount:Int64):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function StorageDeviceStateToNotification(State:LongWord):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 style="font-size: 14px; padding-left: 12px;">'''Description:''' Convert a Storage state value into the notification code for device notifications</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Supported by Subclass SCSI/UFI/SFF8070
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 726: Line 704:
 
<br />
 
<br />
 
<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 USBStorageDeviceTestUnitReady(Device:PUSBDevice; Storage:PUSBStorageDevice; var DeviceFlags:LongWord):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure StorageLog(Level:LongWord; Storage:PStorageDevice; const AText:String);</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 style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Supported by Subclass SCSI/UFI/SFF8070
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 738: Line 716:
 
<br />
 
<br />
 
<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 USBStorageDeviceRead10(Device:PUSBDevice; Storage:PUSBStorageDevice; Start:LongWord;Count:Word; Buffer:Pointer):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure StorageLogInfo(Storage:PStorageDevice; const AText:String); inline;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a SCSI Read10 command to a LUN on a storage device</div>
+
<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;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Supported by Subclass SCSI/UFI/SFF8070. Caller must hold the storage lock.
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 750: Line 728:
 
<br />
 
<br />
 
<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 USBStorageDeviceWrite10(Device:PUSBDevice; Storage:PUSBStorageDevice; Start:LongWord; Count:Word; Buffer:Pointer):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure StorageLogWarn(Storage:PStorageDevice; const AText:String); inline;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a SCSI Write10 command to a LUN on a storage device</div>
+
<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;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Supported by Subclass SCSI/UFI/SFF8070. Caller must hold the storage lock.
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 762: Line 740:
 
<br />
 
<br />
 
<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 USBStorageDeviceRead16(Device:PUSBDevice; Storage:PUSBStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure StorageLogError(Storage:PStorageDevice; const AText:String); inline;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a SCSI Read16 command to a LUN on a storage device</div>
+
<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;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Supported by Subclass SCSI only (Only on devices > 2TB). Caller must hold the storage lock.
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 774: Line 752:
 
<br />
 
<br />
 
<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 USBStorageDeviceWrite16(Device:PUSBDevice; Storage:PUSBStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure StorageLogDebug(Storage:PStorageDevice; const AText:String); inline;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Issue a SCSI Write16 command to a LUN on a storage device</div>
+
<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;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Supported by Subclass SCSI only (Only on devices > 2TB). Caller must hold the storage lock.
+
| None documented
 
|-
 
|-
 
|}
 
|}
Line 786: Line 764:
 
<br />
 
<br />
 
<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 USBStorageDeviceTransport(Device:PUSBDevice; Storage:PUSBStorageDevice; Command:PUSBCommandBlock):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure StorageStatusTimer(Storage:PStorageDevice);</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 style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</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;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! 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.
+
| None documented
 
|-
 
|-
 
|}
 
|}

Latest revision as of 03:24, 29 March 2024

Return to Unit Reference


Description


Ultibo Storage Interface unit

This unit provides the generic Storage device interface used by all storage drivers.

Constants



Storage specific constants STORAGE_*
STORAGE_NAME_PREFIX = 'Storage'; Name prefix for Storage Devices
 
STORAGE_STATUS_TIMER_INTERVAL = 1000;  


Storage device type STORAGE_TYPE_*
STORAGE_TYPE_NONE = 0;  
STORAGE_TYPE_HDD = 1;  
STORAGE_TYPE_FDD = 2;  
STORAGE_TYPE_CDROM = 3;  
STORAGE_TYPE_OPTICAL = 4;  
STORAGE_TYPE_TAPE = 5;  
STORAGE_TYPE_REMOVABLE = 6;  
 
STORAGE_TYPE_MAX = 6;  


Storage device state STORAGE_STATE_*
STORAGE_STATE_EJECTED = 0;  
STORAGE_STATE_EJECTING = 1;  
STORAGE_STATE_INSERTING = 2;  
STORAGE_STATE_INSERTED = 3;  
 
STORAGE_STATE_MAX = 3;  


Storage device flag STORAGE_FLAG_*
STORAGE_FLAG_NONE = $00000000;  
STORAGE_FLAG_REMOVABLE = $00000001;  
STORAGE_FLAG_LBA48 = $00000002;  
STORAGE_FLAG_NOT_READY = $00000004;  
STORAGE_FLAG_NO_MEDIA = $00000008;  
STORAGE_FLAG_READ_ONLY = $00000010;  
STORAGE_FLAG_WRITE_ONLY = $00000020;  
STORAGE_FLAG_ERASEABLE = $00000040;  
STORAGE_FLAG_LOCKABLE = $00000080;  
STORAGE_FLAG_LOCKED = $00000100;  
STORAGE_FLAG_EJECTABLE = $00000200;  
STORAGE_FLAG_CHANGABLE = $00000400;  


Storage device control code STORAGE_CONTROL_*
STORAGE_CONTROL_TEST_READY = 1; Test Unit Ready
STORAGE_CONTROL_RESET = 2; Reset Device
STORAGE_CONTROL_TEST_MEDIA = 3; Test No Media
STORAGE_CONTROL_LOCK = 4; Lock Media
STORAGE_CONTROL_UNLOCK = 5; Unlock Media
STORAGE_CONTROL_EJECT = 6; Eject Media
STORAGE_CONTROL_TEST_LOCKED = 7; Test Media Locked
STORAGE_CONTROL_TEST_CHANGED = 8; Test Media Changed
STORAGE_CONTROL_GET_VENDORID = 9; Get Vendor Id
STORAGE_CONTROL_GET_PRODUCTID = 10; Get Product Id
STORAGE_CONTROL_GET_SERIAL = 11; Get Serial No
STORAGE_CONTROL_GET_REVISION = 12; Get Revision No
STORAGE_CONTROL_GET_PRODUCT = 13; Get Product Name
STORAGE_CONTROL_GET_MANUFACTURER = 14; Get Manufacturer Name


Storage logging STORAGE_LOG_*
STORAGE_LOG_LEVEL_DEBUG = LOG_LEVEL_DEBUG; Storage debugging messages
STORAGE_LOG_LEVEL_INFO = LOG_LEVEL_INFO; Storage informational messages, such as a device being attached or detached
STORAGE_LOG_LEVEL_WARN = LOG_LEVEL_WARN; Storage warning messages
STORAGE_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR; Storage error messages
STORAGE_LOG_LEVEL_NONE = LOG_LEVEL_NONE; No Storage messages


Type definitions



Storage enumeration callback

TStorageEnumerate = function(Storage:PStorageDevice; Data:Pointer):LongWord;

Storage notification callback

TStorageNotification = function(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;

Storage device read

TStorageDeviceRead = function(Storage:PStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;

Storage device write

TStorageDeviceWrite = function(Storage:PStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;

Storage device erase

TStorageDeviceErase = function(Storage:PStorageDevice; const Start,Count:Int64):LongWord;

Storage device control

TStorageDeviceControl = function(Storage:PStorageDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;

Storage device

PStorageDevice = ^TStorageDevice;

TStorageDevice = record

Device Properties
Device:TDevice; The Device entry for this Storage
Storage Properties
StorageId:LongWord; Unique Id of this Storage in the Storage table
StorageState:LongWord; Storage state (eg STORAGE_STATE_INSERTED)
DeviceRead:TStorageDeviceRead; A Device specific DeviceRead method implementing a standard Storage device interface
DeviceWrite:TStorageDeviceWrite; A Device specific DeviceWrite method implementing a standard Storage device interface
DeviceErase:TStorageDeviceErase; A Device specific DeviceErase method implementing a standard Storage device interface
DeviceControl:TStorageDeviceControl; A Device specific DeviceControl method implementing a standard Storage device interface
Driver Properties
Lock:TMutexHandle; Storage lock
TargetID:LongWord; SCSI Id
TargetLUN:LongWord; LUN
BlockSize:LongWord; Block Size
BlockCount:Int64; Number of Blocks
BlockShift:LongWord; Shift Count for Blocks to Bytes conversion (eg 9 for 512 byte blocks)
Vendor:PChar; ATA Model, SCSI Vendor
Product:PChar; ATA Serial No, SCSI Product
Revision:PChar; Firmware Revision
StatusTimer:TTimerHandle; Timer for status change detection
Statistics Properties
ReadCount:LongWord;  
ReadErrors:LongWord;  
WriteCount:LongWord;  
WriteErrors:LongWord;  
EraseCount:LongWord;  
EraseErrors:LongWord;  
Internal Properties
Prev:PStorageDevice; Previous entry in Storage table
Next:PStorageDevice; Next entry in Storage table


Public variables



Storage logging

STORAGE_DEFAULT_LOG_LEVEL:LongWord = STORAGE_LOG_LEVEL_DEBUG; Minimum level for Storage messages. Only messages with level greater than or equal to this will be printed.
STORAGE_LOG_ENABLED:Boolean;


Function declarations



Initialization functions

procedure StorageInit;
Description: To be documented
Note None documented


Storage functions

function StorageDeviceRead(Storage:PStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;
Description: To be documented
Note None documented


function StorageDeviceWrite(Storage:PStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;
Description: To be documented
Note None documented


function StorageDeviceErase(Storage:PStorageDevice; const Start,Count:Int64):LongWord;
Description: To be documented
Note None documented


function StorageDeviceControl(Storage:PStorageDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;
Description: To be documented
Note None documented


function StorageDeviceSetState(Storage:PStorageDevice; State:LongWord):LongWord;
Description: Set the state of the specified storage and send a notification
Storage The storage to set the state for
State The new state to set and notify
Return ERROR_SUCCESS if completed or another error code on failure


function StorageDeviceStartStatus(Storage:PStorageDevice; Interval:LongWord):LongWord;
Description: Start status monitoring on the specified storage for insert/eject notifications
Storage The storage to start status monitoring for
Interval The status monitoring interval in milliseconds
Return ERROR_SUCCESS if completed or another error code on failure


function StorageDeviceStopStatus(Storage:PStorageDevice):LongWord;
Description: Stop status monitoring on the specified storage for insert/eject notifications
Storage The storage to stop status monitoring for
Return ERROR_SUCCESS if completed or another error code on failure


function StorageDeviceCreate:PStorageDevice;
Description: Create a new Storage entry
Return Pointer to new Storage entry or nil if storage could not be created


function StorageDeviceCreateEx(Size:LongWord):PStorageDevice;
Description: Create a new Storage entry
Size Size in bytes to allocate for new storage (Including the storage entry)
Return Pointer to new Storage entry or nil if storage could not be created


function StorageDeviceDestroy(Storage:PStorageDevice):LongWord;
Description: Destroy an existing Storage entry
Note None documented


function StorageDeviceRegister(Storage:PStorageDevice):LongWord;
Description: Register a new Storage in the Storage table
Note None documented


function StorageDeviceDeregister(Storage:PStorageDevice):LongWord;
Description: Deregister a Storage from the Storage table
Note None documented


function StorageDeviceFind(StorageId:LongWord):PStorageDevice;
Description: To be documented
Note None documented


function StorageDeviceFindByDevice(Device:PDevice):PStorageDevice;
Description: Find a Storage device by the matching DeviceData property
Device The device entry to match with the DeviceData value
Return The Storage device matched or nil if none found


function StorageDeviceFindByName(const Name:String):PStorageDevice; inline;
Description: To be documented
Note None documented


function StorageDeviceFindByDescription(const Description:String):PStorageDevice; inline;
Description: To be documented
Note None documented


function StorageDeviceEnumerate(Callback:TStorageEnumerate; Data:Pointer):LongWord;
Description: To be documented
Note None documented


function StorageDeviceNotification(Storage:PStorageDevice; Callback:TStorageNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Description: To be documented
Note None documented


Storage helper functions

function StorageGetCount:LongWord;
Description: Get the current storage count
Note None documented


function StorageDeviceCheck(Storage:PStorageDevice):PStorageDevice;
Description: Check if the supplied Storage is in the storage table
Note None documented


function StorageDeviceTypeToString(StorageType:LongWord):String;
Description: To be documented
Note None documented


function StorageDeviceStateToString(StorageState:LongWord):String;
Description: To be documented
Note None documented


function StorageDeviceStateToNotification(State:LongWord):LongWord;
Description: Convert a Storage state value into the notification code for device notifications
Note None documented


procedure StorageLog(Level:LongWord; Storage:PStorageDevice; const AText:String);
Description: To be documented
Note None documented


procedure StorageLogInfo(Storage:PStorageDevice; const AText:String); inline;
Description: To be documented
Note None documented


procedure StorageLogWarn(Storage:PStorageDevice; const AText:String); inline;
Description: To be documented
Note None documented


procedure StorageLogError(Storage:PStorageDevice; const AText:String); inline;
Description: To be documented
Note None documented


procedure StorageLogDebug(Storage:PStorageDevice; const AText:String); inline;
Description: To be documented
Note None documented


procedure StorageStatusTimer(Storage:PStorageDevice);
Description: To be documented
Note None documented


Return to Unit Reference