blob: b45bbb7dcae09e9137eff944aa673440e39850cb [file] [log] [blame]
Kevin O'Connor7d700252010-02-15 11:56:07 -05001// 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
11struct 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
23struct cdb_read_capacity {
24 u8 command;
25 u8 flags;
26 u8 resreved_02[8];
27 u8 pad[6];
28} PACKED;
29
30struct cdbres_read_capacity {
31 u32 sectors;
32 u32 blksize;
33} PACKED;
34
Paolo Bonzini00823742011-11-16 13:02:42 +010035#define CDB_CMD_TEST_UNIT_READY 0x00
36#define CDB_CMD_INQUIRY 0x12
37#define CDB_CMD_REQUEST_SENSE 0x03
Kevin O'Connor7d700252010-02-15 11:56:07 -050038
39struct 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
48struct 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 Bonzini27300452011-11-16 13:02:50 +010060#define SCSI_TYPE_DISK 0x00
61#define SCSI_TYPE_CDROM 0x05
62
Kevin O'Connor7149fc82010-02-17 23:24:42 -050063struct 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 Bonzini000e0842011-11-16 13:02:54 +010074#define CDB_CMD_MODE_SENSE 0x5A
75#define MODE_PAGE_HD_GEOMETRY 0x04
76
77struct 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
87struct 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'Connor76977b22010-02-17 01:01:32 -0500102// blockcmd.c
Kevin O'Connor1fd9a892012-03-14 21:27:45 -0400103int cdb_is_read(u8 *cdbcmd, u16 blocksize);
Kevin O'Connord3140832012-05-13 22:46:12 -0400104struct disk_op_s;
Kevin O'Connor7149fc82010-02-17 23:24:42 -0500105int cdb_get_inquiry(struct disk_op_s *op, struct cdbres_inquiry *data);
Kevin O'Connor76977b22010-02-17 01:01:32 -0500106int cdb_get_sense(struct disk_op_s *op, struct cdbres_request_sense *data);
Paolo Bonzini00823742011-11-16 13:02:42 +0100107int cdb_test_unit_ready(struct disk_op_s *op);
Kevin O'Connor76977b22010-02-17 01:01:32 -0500108int cdb_read_capacity(struct disk_op_s *op, struct cdbres_read_capacity *data);
Paolo Bonzini000e0842011-11-16 13:02:54 +0100109int cdb_mode_sense_geom(struct disk_op_s *op, struct cdbres_mode_sense_geom *data);
Kevin O'Connor7149fc82010-02-17 23:24:42 -0500110int cdb_inquiry(struct disk_op_s *op, struct cdbres_inquiry *data);
Kevin O'Connor76977b22010-02-17 01:01:32 -0500111int cdb_read(struct disk_op_s *op);
Paolo Bonziniddb8ceb2011-11-16 13:02:47 +0100112int cdb_write(struct disk_op_s *op);
Kevin O'Connor76977b22010-02-17 01:01:32 -0500113
Paolo Bonzini8c976e32011-11-16 13:02:51 +0100114int scsi_is_ready(struct disk_op_s *op);
Kevin O'Connord3140832012-05-13 22:46:12 -0400115struct drive_s;
Kevin O'Connor279dcb12012-02-18 11:02:27 -0500116int scsi_init_drive(struct drive_s *drive, const char *s, int prio);
Paolo Bonzini8c976e32011-11-16 13:02:51 +0100117
Kevin O'Connor7d700252010-02-15 11:56:07 -0500118#endif // blockcmd.h