17#define SCSI_MAX_BLOCK_10 0xffffffffULL
24#define SCSI_OPCODE_READ_10 0x28
25#define SCSI_OPCODE_READ_16 0x88
26#define SCSI_OPCODE_WRITE_10 0x2a
27#define SCSI_OPCODE_WRITE_16 0x8a
28#define SCSI_OPCODE_READ_CAPACITY_10 0x25
29#define SCSI_OPCODE_SERVICE_ACTION_IN 0x9e
30#define SCSI_SERVICE_ACTION_READ_CAPACITY_16 0x10
31#define SCSI_OPCODE_TEST_UNIT_READY 0x00
40#define SCSI_FL_FUA_NV 0x02
41#define SCSI_FL_FUA 0x08
42#define SCSI_FL_DPO 0x10
219#define SCSI_CDB_FORMAT "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:" \
220 "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x"
223#define SCSI_CDB_DATA(cdb) \
224 (cdb).bytes[0], (cdb).bytes[1], (cdb).bytes[2], (cdb).bytes[3], \
225 (cdb).bytes[4], (cdb).bytes[5], (cdb).bytes[6], (cdb).bytes[7], \
226 (cdb).bytes[8], (cdb).bytes[9], (cdb).bytes[10], (cdb).bytes[11], \
227 (cdb).bytes[12], (cdb).bytes[13], (cdb).bytes[14], (cdb).bytes[15]
241#define SCSI_LUN_FORMAT "%04x-%04x-%04x-%04x"
244#define SCSI_LUN_DATA(lun) \
245 ntohs ( (lun).u16[0] ), ntohs ( (lun).u16[1] ), \
246 ntohs ( (lun).u16[2] ), ntohs ( (lun).u16[3] )
309#define SCSI_SENSE_CODE_MASK 0x7f
316#define SCSI_SENSE_FIXED( code ) ( ( (code) & 0x7e ) == 0x70 )
319#define SCSI_SENSE_KEY_MASK 0x0f
342#define scsi_command_TYPE( object_type ) \
343 typeof ( int ( object_type, struct interface *data, \
344 struct scsi_cmd *command ) )
347#define scsi_response_TYPE( object_type ) \
348 typeof ( void ( object_type, struct scsi_rsp *response ) )
unsigned long long uint64_t
uint8_t lun
Logical Unit Number.
uint8_t data[48]
Additional event data.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
union scsi_cdb __attribute__
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
uint8_t block[3][8]
DES-encrypted blocks.
int scsi_open(struct interface *block, struct interface *scsi, struct scsi_lun *lun)
Open SCSI device.
int scsi_command(struct interface *control, struct interface *data, struct scsi_cmd *command)
Issue SCSI command.
void scsi_response(struct interface *intf, struct scsi_rsp *response)
Report SCSI response.
void scsi_parse_sense(const void *data, size_t len, struct scsi_sns_descriptor *sense)
Parse SCSI sense data.
int scsi_parse_lun(const char *lun_string, struct scsi_lun *lun)
Parse SCSI LUN.
SCSI "READ CAPACITY (10)" parameter data.
uint32_t lba
Maximum logical block number.
uint32_t blksize
Block length in bytes.
SCSI "READ CAPACITY (16)" parameter data.
uint32_t blksize
Block length in bytes.
uint64_t lba
Maximum logical block number.
uint8_t reserved[20]
Reserved.
uint16_t len
Transfer length.
uint8_t group
Group number.
uint32_t lba
Start address.
uint8_t control
Control byte.
uint8_t opcode
Opcode (0x28)
uint8_t control
Control byte.
uint8_t group
Group number.
uint8_t opcode
Opcode (0x88)
uint64_t lba
Start address.
uint32_t len
Transfer length.
A SCSI "READ CAPACITY (10)" CDB.
uint8_t reserved_a
Reserved.
uint32_t lba
Logical block address.
uint8_t control
Control byte.
uint8_t opcode
Opcode (0x25)
uint8_t reserved_b[3]
Reserved.
A SCSI "READ CAPACITY (16)" CDB.
uint8_t service_action
Service action.
uint8_t control
Control byte.
uint8_t reserved
Reserved.
uint8_t opcode
Opcode (0x9e)
uint64_t lba
Logical block address.
uint32_t len
Transfer length.
A SCSI "TEST UNIT READY" CDB.
uint8_t control
Control byte.
uint8_t reserved[4]
Reserved.
uint8_t opcode
Opcode (0x00)
uint32_t lba
Start address.
uint8_t opcode
Opcode (0x2a)
uint8_t control
Control byte.
uint8_t group
Group number.
uint16_t len
Transfer length.
uint64_t lba
Start address.
uint8_t control
Control byte.
uint8_t group
Group number.
uint8_t opcode
Opcode (0x8a)
uint32_t len
Transfer length.
A SCSI command information unit.
size_t data_out_len
Data-out buffer length.
size_t data_in_len
Data-in buffer length.
void * data_out
Data-out buffer (may be NULL)
void * data_in
Data-in buffer (may be NULL)
union scsi_cdb cdb
CDB for this command.
A SCSI response information unit.
struct scsi_sns_descriptor sense
Autosense data (if any)
uint8_t status
SCSI status code.
ssize_t overrun
Data overrun (or negative underrun)
SCSI descriptor-format sense data.
uint8_t code
Response code.
uint16_t additional
Additional sense code and qualifier.
SCSI fixed-format sense data.
uint16_t additional
Additional sense code and qualifier.
uint32_t info
Information.
uint8_t code
Response code.
uint32_t cs_info
Command-specific information.
uint8_t reserved
Reserved.
uint8_t len
Additional sense length.
A SCSI Command Data Block.
struct scsi_cdb_test_unit_ready testready
struct scsi_cdb_read_10 read10
struct scsi_cdb_read_capacity_10 readcap10
struct scsi_cdb_write_16 write16
struct scsi_cdb_read_capacity_16 readcap16
struct scsi_cdb_read_16 read16
struct scsi_cdb_write_10 write10
struct scsi_sns_fixed fixed
Fixed-format sense data.
uint8_t code
Response code.
struct scsi_sns_descriptor desc
Descriptor-format sense data.