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 
35 #define CDB_CMD_TEST_UNIT_READY  0x00
36 #define CDB_CMD_INQUIRY          0x12
37 #define CDB_CMD_REQUEST_SENSE    0x03
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 
60 #define SCSI_TYPE_DISK  0x00
61 #define SCSI_TYPE_CDROM 0x05
62 
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 
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 
102 // blockcmd.c
103 struct disk_op_s;
104 int scsi_fill_cmd(struct disk_op_s *op, void *cdbcmd, int maxcdb);
105 int scsi_is_read(struct disk_op_s *op);
106 int scsi_is_ready(struct disk_op_s *op);
107 struct drive_s;
108 int scsi_drive_setup(struct drive_s *drive, const char *s, int prio, u8 target, u8 lun);
109 typedef int (*scsi_add_lun)(u32 lun, struct drive_s *tmpl_drv);
110 int scsi_rep_luns_scan(struct drive_s *tmp_drive, scsi_add_lun add_lun);
111 int scsi_sequential_scan(struct drive_s *tmp_drive, u32 maxluns,
112                          scsi_add_lun add_lun);
113 
114 #endif // blockcmd.h
115