Kevin O'Connor | 7d70025 | 2010-02-15 11:56:07 -0500 | [diff] [blame] | 1 | // Definitions for SCSI style command data blocks. |
| 2 | #ifndef __BLOCKCMD_H |
| 3 | #define __BLOCKCMD_H |
| 4 | |
| 5 | #include "types.h" // u8 |
| 6 | |
| 7 | #define CDB_CMD_READ_10 0x28 |
| 8 | #define CDB_CMD_VERIFY_10 0x2f |
| 9 | #define CDB_CMD_WRITE_10 0x2a |
| 10 | |
| 11 | struct cdb_rwdata_10 { |
| 12 | u8 command; |
| 13 | u8 flags; |
| 14 | u32 lba; |
| 15 | u8 resreved_06; |
| 16 | u16 count; |
| 17 | u8 reserved_09; |
| 18 | u8 pad[6]; |
| 19 | } PACKED; |
| 20 | |
| 21 | #define CDB_CMD_READ_CAPACITY 0x25 |
| 22 | |
| 23 | struct cdb_read_capacity { |
| 24 | u8 command; |
| 25 | u8 flags; |
| 26 | u8 resreved_02[8]; |
| 27 | u8 pad[6]; |
| 28 | } PACKED; |
| 29 | |
| 30 | struct cdbres_read_capacity { |
| 31 | u32 sectors; |
| 32 | u32 blksize; |
| 33 | } PACKED; |
| 34 | |
Paolo Bonzini | 0082374 | 2011-11-16 13:02:42 +0100 | [diff] [blame] | 35 | #define CDB_CMD_TEST_UNIT_READY 0x00 |
| 36 | #define CDB_CMD_INQUIRY 0x12 |
| 37 | #define CDB_CMD_REQUEST_SENSE 0x03 |
Kevin O'Connor | 7d70025 | 2010-02-15 11:56:07 -0500 | [diff] [blame] | 38 | |
| 39 | struct cdb_request_sense { |
| 40 | u8 command; |
| 41 | u8 flags; |
| 42 | u16 reserved_02; |
| 43 | u8 length; |
| 44 | u8 reserved_05; |
| 45 | u8 pad[10]; |
| 46 | } PACKED; |
| 47 | |
| 48 | struct cdbres_request_sense { |
| 49 | u8 errcode; |
| 50 | u8 segment; |
| 51 | u8 flags; |
| 52 | u32 info; |
| 53 | u8 additional; |
| 54 | u32 specific; |
| 55 | u8 asc; |
| 56 | u8 ascq; |
| 57 | u32 reserved_0e; |
| 58 | } PACKED; |
| 59 | |
Paolo Bonzini | 2730045 | 2011-11-16 13:02:50 +0100 | [diff] [blame] | 60 | #define SCSI_TYPE_DISK 0x00 |
| 61 | #define SCSI_TYPE_CDROM 0x05 |
| 62 | |
Kevin O'Connor | 7149fc8 | 2010-02-17 23:24:42 -0500 | [diff] [blame] | 63 | struct cdbres_inquiry { |
| 64 | u8 pdt; |
| 65 | u8 removable; |
| 66 | u8 reserved_02[2]; |
| 67 | u8 additional; |
| 68 | u8 reserved_05[3]; |
| 69 | char vendor[8]; |
| 70 | char product[16]; |
| 71 | char rev[4]; |
| 72 | } PACKED; |
| 73 | |
Paolo Bonzini | 000e084 | 2011-11-16 13:02:54 +0100 | [diff] [blame] | 74 | #define CDB_CMD_MODE_SENSE 0x5A |
| 75 | #define MODE_PAGE_HD_GEOMETRY 0x04 |
| 76 | |
| 77 | struct cdb_mode_sense { |
| 78 | u8 command; |
| 79 | u8 flags; |
| 80 | u8 page; |
| 81 | u32 reserved_03; |
| 82 | u16 count; |
| 83 | u8 reserved_09; |
| 84 | u8 pad[6]; |
| 85 | } PACKED; |
| 86 | |
| 87 | struct cdbres_mode_sense_geom { |
| 88 | u8 unused_00[3]; |
| 89 | u8 read_only; |
| 90 | u32 unused_04; |
| 91 | u8 page; |
| 92 | u8 length; |
| 93 | u8 cyl[3]; |
| 94 | u8 heads; |
| 95 | u8 precomp[3]; |
| 96 | u8 reduced[3]; |
| 97 | u16 step_rate; |
| 98 | u8 landing[3]; |
| 99 | u16 rpm; |
| 100 | } PACKED; |
| 101 | |
Kevin O'Connor | 76977b2 | 2010-02-17 01:01:32 -0500 | [diff] [blame] | 102 | // blockcmd.c |
Kevin O'Connor | 7149fc8 | 2010-02-17 23:24:42 -0500 | [diff] [blame] | 103 | int cdb_get_inquiry(struct disk_op_s *op, struct cdbres_inquiry *data); |
Kevin O'Connor | 76977b2 | 2010-02-17 01:01:32 -0500 | [diff] [blame] | 104 | int cdb_get_sense(struct disk_op_s *op, struct cdbres_request_sense *data); |
Paolo Bonzini | 0082374 | 2011-11-16 13:02:42 +0100 | [diff] [blame] | 105 | int cdb_test_unit_ready(struct disk_op_s *op); |
Kevin O'Connor | 76977b2 | 2010-02-17 01:01:32 -0500 | [diff] [blame] | 106 | int cdb_read_capacity(struct disk_op_s *op, struct cdbres_read_capacity *data); |
Paolo Bonzini | 000e084 | 2011-11-16 13:02:54 +0100 | [diff] [blame] | 107 | int cdb_mode_sense_geom(struct disk_op_s *op, struct cdbres_mode_sense_geom *data); |
Kevin O'Connor | 7149fc8 | 2010-02-17 23:24:42 -0500 | [diff] [blame] | 108 | int cdb_inquiry(struct disk_op_s *op, struct cdbres_inquiry *data); |
Kevin O'Connor | 76977b2 | 2010-02-17 01:01:32 -0500 | [diff] [blame] | 109 | int cdb_read(struct disk_op_s *op); |
Paolo Bonzini | ddb8ceb | 2011-11-16 13:02:47 +0100 | [diff] [blame] | 110 | int cdb_write(struct disk_op_s *op); |
Kevin O'Connor | 76977b2 | 2010-02-17 01:01:32 -0500 | [diff] [blame] | 111 | |
Paolo Bonzini | 8c976e3 | 2011-11-16 13:02:51 +0100 | [diff] [blame] | 112 | int scsi_is_ready(struct disk_op_s *op); |
Kevin O'Connor | 279dcb1 | 2012-02-18 11:02:27 -0500 | [diff] [blame^] | 113 | int scsi_init_drive(struct drive_s *drive, const char *s, int prio); |
Paolo Bonzini | 8c976e3 | 2011-11-16 13:02:51 +0100 | [diff] [blame] | 114 | |
Kevin O'Connor | 7d70025 | 2010-02-15 11:56:07 -0500 | [diff] [blame] | 115 | #endif // blockcmd.h |