summaryrefslogtreecommitdiffstats
path: root/include/grub/scsicmd.h
blob: 3f1e6d28ccfa2d5da7af1c5b73ef876b87bbc81f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*
 *  GRUB  --  GRand Unified Bootloader
 *  Copyright (C) 2008  Free Software Foundation, Inc.
 *
 *  GRUB is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  GRUB is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef	GRUB_SCSICMD_H
#define	GRUB_SCSICMD_H	1

#include <grub/types.h>

#define GRUB_SCSI_DEVTYPE_MASK	31
#define GRUB_SCSI_REMOVABLE_BIT	7
#define GRUB_SCSI_LUN_SHIFT	5

struct grub_scsi_test_unit_ready
{
  grub_uint8_t opcode;
  grub_uint8_t lun; /* 7-5 LUN, 4-0 reserved */
  grub_uint8_t reserved1;
  grub_uint8_t reserved2;
  grub_uint8_t reserved3;
  grub_uint8_t control;
  grub_uint8_t pad[6]; /* To be ATAPI compatible */
} GRUB_PACKED;

struct grub_scsi_inquiry
{
  grub_uint8_t opcode;
  grub_uint8_t lun; /* 7-5 LUN, 4-1 reserved, 0 EVPD */
  grub_uint8_t page; /* page code if EVPD=1 */
  grub_uint8_t reserved;
  grub_uint8_t alloc_length;
  grub_uint8_t control;
  grub_uint8_t pad[6]; /* To be ATAPI compatible */
} GRUB_PACKED;

struct grub_scsi_inquiry_data
{
  grub_uint8_t devtype;
  grub_uint8_t rmb;
  grub_uint16_t reserved;
  grub_uint8_t length;
  grub_uint8_t reserved2[3];
  char vendor[8];
  char prodid[16];
  char prodrev[4];
} GRUB_PACKED;

struct grub_scsi_request_sense
{
  grub_uint8_t opcode;
  grub_uint8_t lun; /* 7-5 LUN, 4-0 reserved */
  grub_uint8_t reserved1;
  grub_uint8_t reserved2;
  grub_uint8_t alloc_length;
  grub_uint8_t control;
  grub_uint8_t pad[6]; /* To be ATAPI compatible */
} GRUB_PACKED;

struct grub_scsi_request_sense_data
{
  grub_uint8_t error_code; /* 7 Valid, 6-0 Err. code */
  grub_uint8_t segment_number;
  grub_uint8_t sense_key; /*7 FileMark, 6 EndOfMedia, 5 ILI, 4-0 sense key */
  grub_uint32_t information;
  grub_uint8_t additional_sense_length;
  grub_uint32_t cmd_specific_info;
  grub_uint8_t additional_sense_code;
  grub_uint8_t additional_sense_code_qualifier;
  grub_uint8_t field_replaceable_unit_code;
  grub_uint8_t sense_key_specific[3];
  /* there can be additional sense field */
} GRUB_PACKED;

struct grub_scsi_read_capacity10
{
  grub_uint8_t opcode;
  grub_uint8_t lun; /* 7-5 LUN, 4-1 reserved, 0 reserved */
  grub_uint32_t logical_block_addr; /* only if PMI=1 */
  grub_uint8_t reserved1;
  grub_uint8_t reserved2;
  grub_uint8_t PMI;
  grub_uint8_t control;
  grub_uint16_t pad; /* To be ATAPI compatible */
} GRUB_PACKED;

struct grub_scsi_read_capacity10_data
{
  grub_uint32_t last_block;
  grub_uint32_t blocksize;
} GRUB_PACKED;

struct grub_scsi_read_capacity16
{
  grub_uint8_t opcode;
  grub_uint8_t lun; /* 7-5 LUN, 4-0 0x10 */
  grub_uint64_t logical_block_addr; /* only if PMI=1 */
  grub_uint32_t alloc_len;
  grub_uint8_t PMI;
  grub_uint8_t control;
} GRUB_PACKED;

struct grub_scsi_read_capacity16_data
{
  grub_uint64_t last_block;
  grub_uint32_t blocksize;
  grub_uint8_t pad[20];
} GRUB_PACKED;

struct grub_scsi_read10
{
  grub_uint8_t opcode;
  grub_uint8_t lun;
  grub_uint32_t lba;
  grub_uint8_t reserved;
  grub_uint16_t size;
  grub_uint8_t reserved2;
  grub_uint16_t pad;
} GRUB_PACKED;

struct grub_scsi_read12
{
  grub_uint8_t opcode;
  grub_uint8_t lun;
  grub_uint32_t lba;
  grub_uint32_t size;
  grub_uint8_t reserved;
  grub_uint8_t control;
} GRUB_PACKED;

struct grub_scsi_read16
{
  grub_uint8_t opcode;
  grub_uint8_t lun;
  grub_uint64_t lba;
  grub_uint32_t size;
  grub_uint8_t reserved;
  grub_uint8_t control;
} GRUB_PACKED;

struct grub_scsi_write10
{
  grub_uint8_t opcode;
  grub_uint8_t lun;
  grub_uint32_t lba;
  grub_uint8_t reserved;
  grub_uint16_t size;
  grub_uint8_t reserved2;
  grub_uint16_t pad;
} GRUB_PACKED;

struct grub_scsi_write12
{
  grub_uint8_t opcode;
  grub_uint8_t lun;
  grub_uint32_t lba;
  grub_uint32_t size;
  grub_uint8_t reserved;
  grub_uint8_t control;
} GRUB_PACKED;

struct grub_scsi_write16
{
  grub_uint8_t opcode;
  grub_uint8_t lun;
  grub_uint64_t lba;
  grub_uint32_t size;
  grub_uint8_t reserved;
  grub_uint8_t control;
} GRUB_PACKED;

typedef enum
  {
    grub_scsi_cmd_test_unit_ready = 0x00,
    grub_scsi_cmd_request_sense = 0x03,
    grub_scsi_cmd_inquiry = 0x12,
    grub_scsi_cmd_read_capacity10 = 0x25,
    grub_scsi_cmd_read10 = 0x28,
    grub_scsi_cmd_write10 = 0x2a,
    grub_scsi_cmd_read16 = 0x88,
    grub_scsi_cmd_write16 = 0x8a,
    grub_scsi_cmd_read_capacity16 = 0x9e,
    grub_scsi_cmd_read12 = 0xa8,
    grub_scsi_cmd_write12 = 0xaa,
  } grub_scsi_cmd_t;

typedef enum
  {
    grub_scsi_devtype_direct = 0x00,
    grub_scsi_devtype_cdrom = 0x05
  } grub_scsi_devtype_t;

#endif /* GRUB_SCSICMD_H */