Difference between revisions of "Unit Storage"
Line 20: | Line 20: | ||
---- | ---- | ||
− | '' | + | |
+ | <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> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>STORAGE_NAME_PREFIX = 'Storage';</code> | ||
+ | | Name prefix for Storage Devices | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>STORAGE_STATUS_TIMER_INTERVAL = 1000;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <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;">'''Storage device type constants''' <code> STORAGE_TYPE_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>STORAGE_TYPE_NONE = 0;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>STORAGE_TYPE_HDD = 1;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>STORAGE_TYPE_FDD = 2;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>STORAGE_TYPE_CDROM = 3;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>STORAGE_TYPE_OPTICAL = 4;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>STORAGE_TYPE_TAPE = 5;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>STORAGE_TYPE_REMOVABLE = 6;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>STORAGE_TYPE_MAX = 6;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <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;">'''Storage device state constants''' <code> STORAGE_STATE_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>STORAGE_STATE_EJECTED = 0;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>STORAGE_STATE_EJECTING = 1;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>STORAGE_STATE_INSERTING = 2;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>STORAGE_STATE_INSERTED = 3;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>STORAGE_STATE_MAX = 3;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <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;">'''Storage device flag constants''' <code> STORAGE_FLAG_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>STORAGE_FLAG_NONE = $00000000;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>STORAGE_FLAG_REMOVABLE = $00000001;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>STORAGE_FLAG_LBA48 = $00000002;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>STORAGE_FLAG_NOT_READY = $00000004;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>STORAGE_FLAG_NO_MEDIA = $00000008;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>STORAGE_FLAG_READ_ONLY = $00000010;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>STORAGE_FLAG_WRITE_ONLY = $00000020;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>STORAGE_FLAG_ERASEABLE = $00000040;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>STORAGE_FLAG_LOCKABLE = $00000080;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>STORAGE_FLAG_LOCKED = $00000100;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>STORAGE_FLAG_EJECTABLE = $00000200;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>STORAGE_FLAG_CHANGABLE = $00000400;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <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;">'''Storage device control code constants''' <code> STORAGE_CONTROL_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>STORAGE_CONTROL_TEST_READY = 1;</code> | ||
+ | | 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> | ||
+ | <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;">'''Storage logging constants''' <code> STORAGE_LOG_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>STORAGE_LOG_LEVEL_DEBUG = LOG_LEVEL_DEBUG;</code> | ||
+ | | 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_ERROR = LOG_LEVEL_ERROR;</code> | ||
+ | | Storage error messages | ||
+ | |- | ||
+ | | <code>STORAGE_LOG_LEVEL_NONE = LOG_LEVEL_NONE;</code> | ||
+ | | No Storage messages | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
=== Type definitions === | === Type definitions === |
Revision as of 03:20, 29 November 2016
Return to Unit Reference
Contents
[hide]Description
Storage Devices
This unit provides both the Storage device interface and the generic USB mass storage driver.
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
STORAGE_*
STORAGE_TYPE_*
STORAGE_STATE_*
STORAGE_FLAG_*
STORAGE_CONTROL_*
STORAGE_LOG_*
Type definitions
To be documented
Public variables
To be documented
Function declarations
Initialization functions
Storage functions
function StorageDeviceRead(Storage:PStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;
function StorageDeviceWrite(Storage:PStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;
function StorageDeviceErase(Storage:PStorageDevice; const Start,Count:Int64):LongWord;
function StorageDeviceControl(Storage:PStorageDevice; Request:Integer; Argument1:LongWord; var Argument2:LongWord):LongWord;
function StorageDeviceSetState(Storage:PStorageDevice; State:LongWord):LongWord;
function StorageDeviceStartStatus(Storage:PStorageDevice; Interval:LongWord):LongWord;
function StorageDeviceStopStatus(Storage:PStorageDevice):LongWord;
function StorageDeviceCreateEx(Size:LongWord):PStorageDevice;
function StorageDeviceDestroy(Storage:PStorageDevice):LongWord;
function StorageDeviceRegister(Storage:PStorageDevice):LongWord;
function StorageDeviceDeregister(Storage:PStorageDevice):LongWord;
function StorageDeviceFind(StorageId:LongWord):PStorageDevice;
function StorageDeviceFindByName(const Name:String):PStorageDevice; inline;
function StorageDeviceFindByDescription(const Description:String):PStorageDevice; inline;
function StorageDeviceEnumerate(Callback:TStorageEnumerate; Data:Pointer):LongWord;
function StorageDeviceNotification(Storage:PStorageDevice; Callback:TStorageNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
USB storage functions
function USBStorageDeviceRead(Storage:PStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;
function USBStorageDeviceWrite(Storage:PStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;
function USBStorageDeviceControl(Storage:PStorageDevice; Request:Integer; Argument1:LongWord; var Argument2:LongWord):LongWord;
function USBStorageDriverBind(Device:PUSBDevice; Interrface:PUSBInterface):LongWord;
function USBStorageDriverUnbind(Device:PUSBDevice; Interrface:PUSBInterface):LongWord;
procedure USBStorageReadComplete(Request:PUSBRequest);
procedure USBStorageWriteComplete(Request:PUSBRequest);
procedure USBStorageInterruptComplete(Request:PUSBRequest);
Storage helper functions
function StorageDeviceCheck(Storage:PStorageDevice):PStorageDevice;
function StorageDeviceTypeToString(StorageType:LongWord):String;
function StorageDeviceStateToString(StorageState:LongWord):String;
function StorageDeviceStateToNotification(State:LongWord):LongWord;
procedure StorageLog(Level:LongWord; Storage:PStorageDevice; const AText:String);
procedure StorageLogInfo(Storage:PStorageDevice; const AText:String);
procedure StorageLogError(Storage:PStorageDevice; const AText:String);
procedure StorageLogDebug(Storage:PStorageDevice; const AText:String);
USB storage helper functions
function USBStorageBlockSizeToBlockShift(BlockSize:LongWord):LongWord;
function USBStoragePatchDevice(Device:PUSBDevice; var Subclass,Protocol:Byte):LongWord;
function USBStorageFixupDevice(Device:PUSBDevice; var Vendor,Product:String):LongWord;
function USBStorageDeviceLock(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;
function USBStorageDeviceUnlock(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;
function USBStorageDeviceLoad(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;
function USBStorageDeviceEject(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;
function USBStorageDeviceReset(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;
function USBStorageDeviceGetInfo(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;
function USBStorageDeviceGetStatus(Device:PUSBDevice; Storage:PUSBStorageDevice):LongWord;
function USBStorageDeviceGetMaxLUN(Device:PUSBDevice; Storage:PUSBStorageDevice; var MaxLUN:Byte):LongWord;
function USBStorageDeviceClearStall(Device:PUSBDevice; Storage:PUSBStorageDevice; Endpoint:PUSBEndpointDescriptor):LongWord;
function USBStorageDeviceInquiry(Device:PUSBDevice; Storage:PUSBStorageDevice; var DeviceType,DeviceFlags:LongWord;v ar Vendor,Product,Revision:PChar):LongWord;
function USBStorageDeviceRequestSense(Device:PUSBDevice; Storage:PUSBStorageDevice; var SenseKey,ASC,ASCQ:Byte):LongWord;
function USBStorageDeviceReadCapacity(Device:PUSBDevice; Storage:PUSBStorageDevice; var BlockSize,BlockShift:LongWord; var BlockCount:Int64):LongWord;
function USBStorageDeviceTestUnitReady(Device:PUSBDevice; Storage:PUSBStorageDevice; var DeviceFlags:LongWord):LongWord;
function USBStorageDeviceRead10(Device:PUSBDevice; Storage:PUSBStorageDevice; Start:LongWord;Count:Word; Buffer:Pointer):LongWord;
function USBStorageDeviceWrite10(Device:PUSBDevice; Storage:PUSBStorageDevice; Start:LongWord; Count:Word; Buffer:Pointer):LongWord;
function USBStorageDeviceRead16(Device:PUSBDevice; Storage:PUSBStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;
function USBStorageDeviceWrite16(Device:PUSBDevice; Storage:PUSBStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;
function USBStorageDeviceTransport(Device:PUSBDevice; Storage:PUSBStorageDevice; Command:PUSBCommandBlock):LongWord;
Return to Unit Reference