VirtualBox

source: vbox/trunk/include/VBox/scsi.h

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.5 KB
Line 
1/** @file
2 * VirtualBox - SCSI declarations. (DEV,+)
3 */
4
5/*
6 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
34 */
35
36#ifndef VBOX_INCLUDED_scsi_h
37#define VBOX_INCLUDED_scsi_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#include <iprt/assert.h>
43
44/**
45 * @todo: Remove when the splitting code was removed from DevATA.
46 * The limit doesn't belong here but is specific for each host platform.
47 */
48#ifdef RT_OS_FREEBSD
49/* The cam subsystem doesn't allow more */
50# define SCSI_MAX_BUFFER_SIZE (64 * _1K)
51#else
52# define SCSI_MAX_BUFFER_SIZE (100 * _1K)
53#endif
54
55/**
56 * SCSI command opcode identifiers.
57 *
58 * SCSI-3, so far for CD/DVD Logical Units, from Table 49 of the MMC-3 draft standard.
59 */
60typedef enum SCSICMD
61{
62 SCSI_BLANK = 0xa1,
63 SCSI_CLOSE_TRACK_SESSION = 0x5b,
64 SCSI_ERASE_10 = 0x2c,
65 SCSI_FORMAT_UNIT = 0x04,
66 SCSI_GET_CONFIGURATION = 0x46,
67 SCSI_GET_EVENT_STATUS_NOTIFICATION = 0x4a,
68 SCSI_GET_PERFORMANCE = 0xac,
69 /** Inquiry command. */
70 SCSI_INQUIRY = 0x12,
71 SCSI_LOAD_UNLOAD_MEDIUM = 0xa6,
72 SCSI_MECHANISM_STATUS = 0xbd,
73 SCSI_MODE_SELECT_10 = 0x55,
74 SCSI_MODE_SENSE_10 = 0x5a,
75 SCSI_PAUSE_RESUME = 0x4b,
76 SCSI_PLAY_AUDIO_10 = 0x45,
77 SCSI_PLAY_AUDIO_12 = 0xa5,
78 SCSI_PLAY_AUDIO_MSF = 0x47,
79 SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL = 0x1e,
80 /** Read(10) command. */
81 SCSI_READ_10 = 0x28,
82 SCSI_READ_12 = 0xa8,
83 SCSI_READ_BUFFER = 0x3c,
84 SCSI_READ_BUFFER_CAPACITY = 0x5c,
85 /** Read Capacity(6) command. */
86 SCSI_READ_CAPACITY = 0x25,
87 SCSI_READ_CD = 0xbe,
88 SCSI_READ_CD_MSF = 0xb9,
89 SCSI_READ_DISC_INFORMATION = 0x51,
90 SCSI_READ_DVD_STRUCTURE = 0xad,
91 SCSI_READ_FORMAT_CAPACITIES = 0x23,
92 SCSI_READ_SUBCHANNEL = 0x42,
93 SCSI_READ_TOC_PMA_ATIP = 0x43,
94 SCSI_READ_TRACK_INFORMATION = 0x52,
95 SCSI_REPAIR_TRACK = 0x58,
96 SCSI_REPORT_KEY = 0xa4,
97 SCSI_REQUEST_SENSE = 0x03,
98 SCSI_RESERVE_TRACK = 0x53,
99 SCSI_SCAN = 0xba,
100 SCSI_SEEK_10 = 0x2b,
101 SCSI_SEND_CUE_SHEET = 0x5d,
102 SCSI_SEND_DVD_STRUCTURE = 0xbf,
103 SCSI_SEND_EVENT = 0xa2,
104 SCSI_SEND_KEY = 0xa3,
105 SCSI_SEND_OPC_INFORMATION = 0x54,
106 SCSI_SET_CD_SPEED = 0xbb,
107 SCSI_SET_READ_AHEAD = 0xa7,
108 SCSI_SET_STREAMING = 0xb6,
109 SCSI_START_STOP_UNIT = 0x1b,
110 SCSI_LOAD_UNLOAD = 0x1b,
111 SCSI_STOP_PLAY_SCAN = 0x4e,
112 /** Synchronize Cache command. */
113 SCSI_SYNCHRONIZE_CACHE = 0x35,
114 SCSI_TEST_UNIT_READY = 0x00,
115 SCSI_VERIFY_10 = 0x2f,
116 /** Write(10) command. */
117 SCSI_WRITE_10 = 0x2a,
118 SCSI_WRITE_12 = 0xaa,
119 SCSI_WRITE_AND_VERIFY_10 = 0x2e,
120 SCSI_WRITE_BUFFER = 0x3b,
121
122 /** Mode Select(6) command */
123 SCSI_MODE_SELECT_6 = 0x15,
124 /** Mode Sense(6) command */
125 SCSI_MODE_SENSE_6 = 0x1a,
126 /** Report LUNs command. */
127 SCSI_REPORT_LUNS = 0xa0,
128 SCSI_REPORT_DENSITY = 0x44,
129 /** Rezero Unit command. Obsolete for ages now, but used by cdrecord. */
130 SCSI_REZERO_UNIT = 0x01,
131 SCSI_REWIND = 0x01,
132 SCSI_SERVICE_ACTION_IN_16 = 0x9e,
133 SCSI_READ_16 = 0x88,
134 SCSI_WRITE_16 = 0x8a,
135 SCSI_READ_6 = 0x08,
136 SCSI_WRITE_6 = 0x0a,
137 SCSI_LOG_SENSE = 0x4d,
138 SCSI_UNMAP = 0x42,
139 SCSI_RESERVE_6 = 0x16,
140 SCSI_RELEASE_6 = 0x17,
141 SCSI_RESERVE_10 = 0x56,
142 SCSI_RELEASE_10 = 0x57,
143 SCSI_READ_BLOCK_LIMITS = 0x05,
144 SCSI_MAINTENANCE_IN = 0xa3
145} SCSICMD;
146
147/**
148 * Service action in opcode identifiers
149 */
150typedef enum SCSISVCACTIONIN
151{
152 SCSI_SVC_ACTION_IN_READ_CAPACITY_16 = 0x10
153} SCSISVCACTIONIN;
154
155/**
156 * Maintenance in opcode identifiers
157 */
158typedef enum SCSIMAINTENANCEIN
159{
160 SCSI_MAINTENANCE_IN_REPORT_SUPP_OPC = 0x0c
161} SCSIMAINTENANCEIN;
162
163/* Mode page codes for mode sense/select commands. */
164#define SCSI_MODEPAGE_ERROR_RECOVERY 0x01
165#define SCSI_MODEPAGE_WRITE_PARAMETER 0x05
166#define SCSI_MODEPAGE_CD_STATUS 0x2a
167
168
169/* Page control codes. */
170#define SCSI_PAGECONTROL_CURRENT 0x00
171#define SCSI_PAGECONTROL_CHANGEABLE 0x01
172#define SCSI_PAGECONTROL_DEFAULT 0x02
173#define SCSI_PAGECONTROL_SAVED 0x03
174
175
176/* Status codes */
177#define SCSI_STATUS_OK 0x00
178#define SCSI_STATUS_CHECK_CONDITION 0x02
179#define SCSI_STATUS_CONDITION_MET 0x04
180#define SCSI_STATUS_BUSY 0x08
181#define SCSI_STATUS_INTERMEDIATE 0x10
182#define SCSI_STATUS_DATA_UNDEROVER_RUN 0x12
183#define SCSI_STATUS_INTERMEDIATE_CONDITION_MET 0x14
184#define SCSI_STATUS_RESERVATION_CONFLICT 0x18
185#define SCSI_STATUS_COMMAND_TERMINATED 0x22
186#define SCSI_STATUS_QUEUE_FULL 0x28
187#define SCSI_STATUS_ACA_ACTIVE 0x30
188#define SCSI_STATUS_TASK_ABORTED 0x40
189
190/* Sense data response codes - This is the first byte in the sense data */
191#define SCSI_SENSE_RESPONSE_CODE_CURR_FIXED 0x70
192#define SCSI_SENSE_RESPONSE_CODE_DEFERRED_FIXED 0x71
193#define SCSI_SENSE_RESPONSE_CODE_CURR_DESC 0x72
194#define SCSI_SENSE_RESPONSE_CODE_DEFERRED_DESC 0x73
195
196/* Sense keys */
197#define SCSI_SENSE_NONE 0
198#define SCSI_SENSE_RECOVERED_ERROR 1
199#define SCSI_SENSE_NOT_READY 2
200#define SCSI_SENSE_MEDIUM_ERROR 3
201#define SCSI_SENSE_HARDWARE_ERROR 4
202#define SCSI_SENSE_ILLEGAL_REQUEST 5
203#define SCSI_SENSE_UNIT_ATTENTION 6
204#define SCSI_SENSE_DATA_PROTECT 7
205#define SCSI_SENSE_BLANK_CHECK 8
206#define SCSI_SENSE_VENDOR_SPECIFIC 9
207#define SCSI_SENSE_COPY_ABORTED 10
208#define SCSI_SENSE_ABORTED_COMMAND 11
209#define SCSI_SENSE_VOLUME_OVERFLOW 13
210#define SCSI_SENSE_MISCOMPARE 14
211
212/* Additional sense bit flags (to be ORed with sense key). */
213#define SCSI_SENSE_FLAG_FILEMARK 0x80
214#define SCSI_SENSE_FLAG_EOM 0x40
215#define SCSI_SENSE_FLAG_ILI 0x20
216
217/* Additional sense keys */
218#define SCSI_ASC_NONE 0x00
219#define SCSI_ASC_WRITE_ERROR 0x0c
220#define SCSI_ASC_READ_ERROR 0x11
221#define SCSI_ASC_ILLEGAL_OPCODE 0x20
222#define SCSI_ASC_LOGICAL_BLOCK_OOR 0x21
223#define SCSI_ASC_INV_FIELD_IN_CMD_PACKET 0x24
224#define SCSI_ASC_LOGICAL_UNIT_NOT_SUPPORTED 0x25
225#define SCSI_ASC_WRITE_PROTECTED 0x27
226#define SCSI_ASC_MEDIUM_MAY_HAVE_CHANGED 0x28
227#define SCSI_ASC_POWER_ON_RESET_BUS_DEVICE_RESET_OCCURRED 0x29
228#define SCSI_ASC_CANNOT_READ_MEDIUM 0x30
229#define SCSI_ASC_MEDIUM_NOT_PRESENT 0x3a
230#define SCSI_ASC_SAVING_PARAMETERS_NOT_SUPPORTED 0x39
231#define SCSI_ASC_INTERNAL_TARGET_FAILURE 0x44
232#define SCSI_ASC_INVALID_MESSAGE 0x49
233#define SCSI_ASC_MEDIA_LOAD_OR_EJECT_FAILED 0x53
234#define SCSI_ASC_LOGICAL_UNIT_DOES_NOT_RESPOND_TO_SELECTION 0x00
235#define SCSI_ASC_SYSTEM_RESOURCE_FAILURE 0x55
236#define SCSI_ASC_ILLEGAL_MODE_FOR_THIS_TRACK 0x64
237#define SCSI_ASC_COMMAND_TO_LOGICAL_UNIT_FAILED 0x6E
238
239/** Additional sense code qualifiers (ASCQ). */
240/* NB: The ASC/ASCQ combination determines the full meaning. */
241#define SCSI_ASCQ_SYSTEM_BUFFER_FULL 0x01
242#define SCSI_ASCQ_POWER_ON_RESET_BUS_DEVICE_RESET_OCCURRED 0x00
243#define SCSI_ASCQ_END_OF_DATA_DETECTED 0x05
244#define SCSI_ASCQ_FILEMARK_DETECTED 0x01
245#define SCSI_ASCQ_EOP_EOM_DETECTED 0x02
246#define SCSI_ASCQ_SETMARK_DETECTED 0x03
247#define SCSI_ASCQ_BOP_BOM_DETECTED 0x04
248#define SCSI_ASCQ_UNKNOWN_FORMAT 0x01
249#define SCSI_ASCQ_INCOMPATIBLE_FORMAT 0x02
250#define SCSI_ASCQ_COPY_TARGET_DEVICE_DATA_OVERRUN 0x0d
251
252/** @name SCSI_INQUIRY
253 * @{
254 */
255
256/** Length of the SCSI INQUIRY vendor identifier (without termination). */
257#define SCSI_INQUIRY_VENDOR_ID_LENGTH 8
258/** Length of the SCSI INQUIRY product identifier (without termination). */
259#define SCSI_INQUIRY_PRODUCT_ID_LENGTH 16
260/** Length of the SCSI INQUIRY revision identifier (without termination). */
261#define SCSI_INQUIRY_REVISION_LENGTH 4
262
263#pragma pack(1)
264typedef struct SCSIINQUIRYCDB
265{
266 unsigned u8Cmd : 8;
267 unsigned fEVPD : 1;
268 unsigned u4Reserved : 4;
269 unsigned u3LUN : 3;
270 unsigned u8PageCode : 8;
271 unsigned u8Reserved : 8;
272 uint8_t cbAlloc;
273 uint8_t u8Control;
274} SCSIINQUIRYCDB;
275#pragma pack()
276AssertCompileSize(SCSIINQUIRYCDB, 6);
277typedef SCSIINQUIRYCDB *PSCSIINQUIRYCDB;
278typedef const SCSIINQUIRYCDB *PCSCSIINQUIRYCDB;
279
280#pragma pack(1)
281typedef struct SCSIINQUIRYDATA
282{
283 unsigned u5PeripheralDeviceType : 5; /**< 0x00 / 00 */
284 unsigned u3PeripheralQualifier : 3;
285 unsigned u6DeviceTypeModifier : 7; /**< 0x01 */
286 unsigned fRMB : 1;
287 unsigned u3AnsiVersion : 3; /**< 0x02 */
288 unsigned u3EcmaVersion : 3;
289 unsigned u2IsoVersion : 2;
290 unsigned u4ResponseDataFormat : 4; /**< 0x03 */
291 unsigned u2Reserved0 : 2;
292 unsigned fTrmlOP : 1;
293 unsigned fAEC : 1;
294 unsigned cbAdditional : 8; /**< 0x04 */
295 unsigned u8Reserved1 : 8; /**< 0x05 */
296 unsigned u8Reserved2 : 8; /**< 0x06 */
297 unsigned fSftRe : 1; /**< 0x07 */
298 unsigned fCmdQue : 1;
299 unsigned fReserved3 : 1;
300 unsigned fLinked : 1;
301 unsigned fSync : 1;
302 unsigned fWBus16 : 1;
303 unsigned fWBus32 : 1;
304 unsigned fRelAdr : 1;
305 int8_t achVendorId[SCSI_INQUIRY_VENDOR_ID_LENGTH]; /**< 0x08 */
306 int8_t achProductId[SCSI_INQUIRY_PRODUCT_ID_LENGTH]; /**< 0x10 */
307 int8_t achProductLevel[SCSI_INQUIRY_REVISION_LENGTH]; /**< 0x20 */
308 uint8_t abVendorSpecific[20]; /**< 0x24/36 - Optional it seems. */
309 uint8_t abReserved4[40];
310 uint8_t abVendorSpecificParameters[1]; /**< 0x60/96 - Variable size. */
311} SCSIINQUIRYDATA;
312#pragma pack()
313AssertCompileSize(SCSIINQUIRYDATA, 97);
314typedef SCSIINQUIRYDATA *PSCSIINQUIRYDATA;
315typedef const SCSIINQUIRYDATA *PCSCSIINQUIRYDATA;
316
317#define SCSI_INQUIRY_DATA_PERIPHERAL_QUALIFIER_CONNECTED 0x00
318#define SCSI_INQUIRY_DATA_PERIPHERAL_QUALIFIER_NOT_CONNECTED_BUT_SUPPORTED 0x01
319#define SCSI_INQUIRY_DATA_PERIPHERAL_QUALIFIER_NOT_CONNECTED_NOT_SUPPORTED 0x03
320
321#define SCSI_INQUIRY_DATA_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS 0x00
322#define SCSI_INQUIRY_DATA_PERIPHERAL_DEVICE_TYPE_SEQUENTIAL_ACCESS 0x01
323#define SCSI_INQUIRY_DATA_PERIPHERAL_DEVICE_TYPE_CD_DVD 0x05
324#define SCSI_INQUIRY_DATA_PERIPHERAL_DEVICE_TYPE_UNKNOWN 0x1f
325
326/** @} */
327
328#if defined(IN_RING3) && (defined(LOG_ENABLED) || defined(RT_STRICT))
329const char * SCSICmdText(uint8_t uCmd);
330const char * SCSIStatusText(uint8_t uStatus);
331const char * SCSISenseText(uint8_t uSense);
332const char * SCSISenseExtText(uint8_t uASC, uint8_t uASCQ);
333int SCSILogModePage(char *pszBuf, size_t cchBuffer, uint8_t *pbModePage,
334 size_t cbModePage);
335int SCSILogCueSheet(char *pszBuf, size_t cchBuffer, uint8_t *pbCueSheet,
336 size_t cbCueSheet);
337#endif
338
339#endif /* !VBOX_INCLUDED_scsi_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use