* Added opcode definitions for read/write-16 and the extended "read capacity 16"

over service-action-in.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36415 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-04-22 13:44:24 +00:00
parent 46d3d6949b
commit 0a96e18689
+179 -132
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2004-2007, Haiku, Inc. All RightsReserved. * Copyright 2004-2010, Haiku, Inc. All RightsReserved.
* Copyright 2002/03, Thomas Kurschel. All rights reserved. * Copyright 2002/03, Thomas Kurschel. All rights reserved.
* *
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
@@ -7,158 +7,204 @@
#ifndef _SCSI_CMDS_H #ifndef _SCSI_CMDS_H
#define _SCSI_CMDS_H #define _SCSI_CMDS_H
// SCSI commands and their data structures and constants
//! SCSI commands and their data structures and constants
#include <lendian_bitfield.h> #include <lendian_bitfield.h>
// always keep in mind that SCSI is big-endian !!! // Always keep in mind that SCSI is big-endian!
#define SCSI_STD_TIMEOUT 10 #define SCSI_STD_TIMEOUT 10
// SCSI device status (as the result of a command) // SCSI device status (as the result of a command)
#define SCSI_STATUS_GOOD (0 << 1) #define SCSI_STATUS_GOOD (0 << 1)
#define SCSI_STATUS_CHECK_CONDITION (1 << 1) // error occured #define SCSI_STATUS_CHECK_CONDITION (1 << 1) // error occured
#define SCSI_STATUS_CONDITION_MET (2 << 1) // "found" for SEARCH DATA and PREFETCH #define SCSI_STATUS_CONDITION_MET (2 << 1)
#define SCSI_STATUS_BUSY (4 << 1) // try again later (??? == QUEUE_FULL ???) // "found" for SEARCH DATA and PREFETCH
#define SCSI_STATUS_INTERMEDIATE (8 << 1) // used by linked command only #define SCSI_STATUS_BUSY (4 << 1)
#define SCSI_STATUS_INTERMEDIATE_COND_MET (10 << 1) // ditto // try again later (??? == QUEUE_FULL ???)
#define SCSI_STATUS_RESERVATION_CONFLICT (12 << 1) // only if RESERVE/RELEASE is used #define SCSI_STATUS_INTERMEDIATE (8 << 1)
#define SCSI_STATUS_COMMAND_TERMINATED (17 << 1) // aborted by TERMINATE I/O PROCESS // used by linked command only
#define SCSI_STATUS_QUEUE_FULL (20 << 1) // queue full #define SCSI_STATUS_INTERMEDIATE_COND_MET (10 << 1) // ditto
#define SCSI_STATUS_RESERVATION_CONFLICT (12 << 1)
// only if RESERVE/RELEASE is used
#define SCSI_STATUS_COMMAND_TERMINATED (17 << 1)
// aborted by TERMINATE I/O PROCESS
#define SCSI_STATUS_QUEUE_FULL (20 << 1) // queue full
#define SCSI_STATUS_MASK 0xfe #define SCSI_STATUS_MASK 0xfe
// SCSI sense key // SCSI sense key
#define SCSIS_KEY_NO_SENSE 0 #define SCSIS_KEY_NO_SENSE 0
#define SCSIS_KEY_RECOVERED_ERROR 1 #define SCSIS_KEY_RECOVERED_ERROR 1
#define SCSIS_KEY_NOT_READY 2 // operator intervention may be required #define SCSIS_KEY_NOT_READY 2
#define SCSIS_KEY_MEDIUM_ERROR 3 // can be set if source could be hardware error // operator intervention may be required
#define SCSIS_KEY_HARDWARE_ERROR 4 #define SCSIS_KEY_MEDIUM_ERROR 3
#define SCSIS_KEY_ILLEGAL_REQUEST 5 // invalid command // can be set if source could be hardware error
#define SCSIS_KEY_UNIT_ATTENTION 6 // medium changed or target reset #define SCSIS_KEY_HARDWARE_ERROR 4
#define SCSIS_KEY_DATA_PROTECT 7 // data access forbidden #define SCSIS_KEY_ILLEGAL_REQUEST 5 // invalid command
#define SCSIS_KEY_BLANK_CHECK 8 // tried to read blank or to write non-blank medium #define SCSIS_KEY_UNIT_ATTENTION 6
#define SCSIS_KEY_VENDOR_SPECIFIC 9 // medium changed or target reset
#define SCSIS_KEY_COPY_ABORTED 10 // error in COPY or COMPARE command #define SCSIS_KEY_DATA_PROTECT 7 // data access forbidden
#define SCSIS_KEY_ABORTED_COMMAND 11 // aborted by target, retry *may* help #define SCSIS_KEY_BLANK_CHECK 8
#define SCSIS_KEY_EQUAL 12 // during SEARCH: data found // tried to read blank or to write non-blank medium
#define SCSIS_KEY_VOLUME_OVERFLOW 13 // tried to write buffered data beyond end of medium #define SCSIS_KEY_VENDOR_SPECIFIC 9
#define SCSIS_KEY_MISCOMPARE 14 #define SCSIS_KEY_COPY_ABORTED 10
#define SCSIS_KEY_RESERVED 15 // error in COPY or COMPARE command
#define SCSIS_KEY_ABORTED_COMMAND 11
// aborted by target, retry *may* help
#define SCSIS_KEY_EQUAL 12 // during SEARCH: data found
#define SCSIS_KEY_VOLUME_OVERFLOW 13
// tried to write buffered data beyond end of medium
#define SCSIS_KEY_MISCOMPARE 14
#define SCSIS_KEY_RESERVED 15
// SCSI ASC and ASCQ data - (ASC << 8) | ASCQ // SCSI ASC and ASCQ data - (ASC << 8) | ASCQ
// all codes with bit 7 of ASC or ASCQ set are vendor-specific // all codes with bit 7 of ASC or ASCQ set are vendor-specific
#define SCSIS_ASC_NO_SENSE 0x0000 #define SCSIS_ASC_NO_SENSE 0x0000
#define SCSIS_ASC_IO_PROC_TERMINATED 0x0006 #define SCSIS_ASC_IO_PROC_TERMINATED 0x0006
#define SCSIS_ASC_AUDIO_PLAYING 0x0011 #define SCSIS_ASC_AUDIO_PLAYING 0x0011
#define SCSIS_ASC_AUDIO_PAUSED 0x0012 #define SCSIS_ASC_AUDIO_PAUSED 0x0012
#define SCSIS_ASC_AUDIO_COMPLETED 0x0013 #define SCSIS_ASC_AUDIO_COMPLETED 0x0013
#define SCSIS_ASC_AUDIO_ERROR 0x0014 // playing has stopped due to error #define SCSIS_ASC_AUDIO_ERROR 0x0014
#define SCSIS_ASC_AUDIO_NO_STATUS 0x0015 // playing has stopped due to error
#define SCSIS_ASC_NO_INDEX 0x0100 // no index/sector signal #define SCSIS_ASC_AUDIO_NO_STATUS 0x0015
#define SCSIS_ASC_NO_SEEK_CMP 0x0200 // ??? #define SCSIS_ASC_NO_INDEX 0x0100 // no index/sector signal
#define SCSIS_ASC_WRITE_FAULT 0x0300 #define SCSIS_ASC_NO_SEEK_CMP 0x0200 // ???
#define SCSIS_ASC_LUN_NOT_READY 0x0400 // LUN not ready, cause not reportable #define SCSIS_ASC_WRITE_FAULT 0x0300
#define SCSIS_ASC_LUN_BECOMING_READY 0x0401 // LUN in progress of becoming ready #define SCSIS_ASC_LUN_NOT_READY 0x0400
#define SCSIS_ASC_LUN_NEED_INIT 0x0402 // LUN need initializing command // LUN not ready, cause not reportable
#define SCSIS_ASC_LUN_NEED_MANUAL_HELP 0x0403 // LUN needs manual intervention #define SCSIS_ASC_LUN_BECOMING_READY 0x0401
#define SCSIS_ASC_LUN_FORMATTING 0x0404 // LUN format in progress // LUN in progress of becoming ready
#define SCSIS_ASC_LUN_SEL_FAILED 0x0500 // LUN doesn't respond to selection #define SCSIS_ASC_LUN_NEED_INIT 0x0402
#define SCSIS_ASC_LUN_COM_FAILURE 0x0800 // LUN communication failure // LUN need initializing command
#define SCSIS_ASC_LUN_TIMEOUT 0x0801 // LUN communication time-out #define SCSIS_ASC_LUN_NEED_MANUAL_HELP 0x0403
#define SCSIS_ASC_LUN_COM_PARITY 0x0802 // LUN communication parity failure // LUN needs manual intervention
#define SCSIS_ASC_LUN_COM_CRC 0x0803 // LUN communication CRC failure (SCSI-3) #define SCSIS_ASC_LUN_FORMATTING 0x0404
#define SCSIS_ASC_WRITE_ERR_AUTOREALLOC 0x0c01 // recovered by auto-reallocation // LUN format in progress
#define SCSIS_ASC_LUN_SEL_FAILED 0x0500
// LUN doesn't respond to selection
#define SCSIS_ASC_LUN_COM_FAILURE 0x0800 // LUN communication failure
#define SCSIS_ASC_LUN_TIMEOUT 0x0801
// LUN communication time-out
#define SCSIS_ASC_LUN_COM_PARITY 0x0802
// LUN communication parity failure
#define SCSIS_ASC_LUN_COM_CRC 0x0803
// LUN communication CRC failure (SCSI-3)
#define SCSIS_ASC_WRITE_ERR_AUTOREALLOC 0x0c01
// recovered by auto-reallocation
#define SCSIS_ASC_WRITE_ERR_AUTOREALLOC_FAILED 0x0c02 #define SCSIS_ASC_WRITE_ERR_AUTOREALLOC_FAILED 0x0c02
#define SCSIS_ASC_ECC_ERROR 0x1000 #define SCSIS_ASC_ECC_ERROR 0x1000
#define SCSIS_ASC_UNREC_READ_ERR 0x1100 // unrecovered read error #define SCSIS_ASC_UNREC_READ_ERR 0x1100 // unrecovered read error
#define SCSIS_ASC_READ_RETRIES_EXH 0x1101 // read retries exhausted #define SCSIS_ASC_READ_RETRIES_EXH 0x1101 // read retries exhausted
#define SCSIS_ASC_UNREC_READ_ERR_AUTOREALLOC_FAILED 0x1104 // above + auto-reallocate failed #define SCSIS_ASC_UNREC_READ_ERR_AUTOREALLOC_FAILED 0x1104
#define SCSIS_ASC_RECORD_NOT_FOUND 0x1401 // above + auto-reallocate failed
#define SCSIS_ASC_RANDOM_POS_ERROR 0x1500 // random positioning error #define SCSIS_ASC_RECORD_NOT_FOUND 0x1401
#define SCSIS_ASC_POSITIONING_ERR 0x1501 // mechanical positioning error #define SCSIS_ASC_RANDOM_POS_ERROR 0x1500 // random positioning error
#define SCSIS_ASC_POS_ERR_ON_READ 0x1502 // positioning error detected by reading #define SCSIS_ASC_POSITIONING_ERR 0x1501
#define SCSIS_ASC_DATA_RECOV_NO_ERR_CORR 0x1700 // recovered with no error correction applied // mechanical positioning error
#define SCSIS_ASC_DATA_RECOV_WITH_RETRIES 0x1701 #define SCSIS_ASC_POS_ERR_ON_READ 0x1502
#define SCSIS_ASC_DATA_RECOV_POS_HEAD_OFS 0x1702 // ?recovered with positive head offset // positioning error detected by reading
#define SCSIS_ASC_DATA_RECOV_NEG_HEAD_OFS 0x1703 // ?recovered with negative head offset #define SCSIS_ASC_DATA_RECOV_NO_ERR_CORR 0x1700
#define SCSIS_ASC_DATA_RECOV_WITH_RETRIES_CIRC 0x1704 // recovered with retries/CIRC // recovered with no error correction applied
#define SCSIS_ASC_DATA_RECOV_PREV_SECT_ID 0x1705 // recovered using previous sector ID #define SCSIS_ASC_DATA_RECOV_WITH_RETRIES 0x1701
#define SCSIS_ASC_DATA_RECOV_POS_HEAD_OFS 0x1702
// ?recovered with positive head offset
#define SCSIS_ASC_DATA_RECOV_NEG_HEAD_OFS 0x1703
// ?recovered with negative head offset
#define SCSIS_ASC_DATA_RECOV_WITH_RETRIES_CIRC 0x1704
// recovered with retries/CIRC
#define SCSIS_ASC_DATA_RECOV_PREV_SECT_ID 0x1705
// recovered using previous sector ID
#define SCSIS_ASC_DATA_RECOV_NO_ECC_AUTOREALLOC 0x1706 #define SCSIS_ASC_DATA_RECOV_NO_ECC_AUTOREALLOC 0x1706
#define SCSIS_ASC_DATA_RECOV_NO_ECC_REASSIGN 0x1707 // reassign recommended #define SCSIS_ASC_DATA_RECOV_NO_ECC_REASSIGN 0x1707 // reassign recommended
#define SCSIS_ASC_DATA_RECOV_NO_ECC_REWRITE 0x1708 // rewrite recommended #define SCSIS_ASC_DATA_RECOV_NO_ECC_REWRITE 0x1708 // rewrite recommended
#define SCSIS_ASC_DATA_RECOV_WITH_CORR 0x1800 // recovered using error correction #define SCSIS_ASC_DATA_RECOV_WITH_CORR 0x1800
#define SCSIS_ASC_DATA_RECOV_WITH_CORR_RETRIES 0x1801 // used error correction and retries // recovered using error correction
#define SCSIS_ASC_DATA_RECOV_AUTOREALLOC 0x1802 #define SCSIS_ASC_DATA_RECOV_WITH_CORR_RETRIES 0x1801
#define SCSIS_ASC_DATA_RECOV_CIRC 0x1803 // recovered using CIRC // used error correction and retries
#define SCSIS_ASC_DATA_RECOV_LEC 0x1804 // recovered using LEC #define SCSIS_ASC_DATA_RECOV_AUTOREALLOC 0x1802
#define SCSIS_ASC_DATA_RECOV_REASSIGN 0x1805 // reassign recommended #define SCSIS_ASC_DATA_RECOV_CIRC 0x1803 // recovered using CIRC
#define SCSIS_ASC_DATA_RECOV_REWRITE 0x1806 // rewrite recommended #define SCSIS_ASC_DATA_RECOV_LEC 0x1804 // recovered using LEC
#define SCSIS_ASC_PARAM_LIST_LENGTH_ERR 0x1a00 // parameter list too short #define SCSIS_ASC_DATA_RECOV_REASSIGN 0x1805 // reassign recommended
#define SCSIS_ASC_ID_RECOV 0x1e00 // recoved ID with ECC #define SCSIS_ASC_DATA_RECOV_REWRITE 0x1806 // rewrite recommended
#define SCSIS_ASC_INV_OPCODE 0x2000 #define SCSIS_ASC_PARAM_LIST_LENGTH_ERR 0x1a00 // parameter list too short
#define SCSIS_ASC_LBA_OOR 0x2100 // LBA out of range #define SCSIS_ASC_ID_RECOV 0x1e00 // recoved ID with ECC
#define SCSIS_ASC_ILL_FUNCTION 0x2200 // better use 0x2000/0x2400/0x2600 instead #define SCSIS_ASC_INV_OPCODE 0x2000
#define SCSIS_ASC_INV_CDB_FIELD 0x2400 #define SCSIS_ASC_LBA_OOR 0x2100 // LBA out of range
#define SCSIS_ASC_LUN_NOT_SUPPORTED 0x2500 #define SCSIS_ASC_ILL_FUNCTION 0x2200
#define SCSIS_ASC_INV_PARAM_LIST_FIELD 0x2600 // better use 0x2000/0x2400/0x2600 instead
#define SCSIS_ASC_PARAM_NOT_SUPPORTED 0x2601 #define SCSIS_ASC_INV_CDB_FIELD 0x2400
#define SCSIS_ASC_PARAM_VALUE_INV 0x2602 #define SCSIS_ASC_LUN_NOT_SUPPORTED 0x2500
#define SCSIS_ASC_WRITE_PROTECTED 0x2700 #define SCSIS_ASC_INV_PARAM_LIST_FIELD 0x2600
#define SCSIS_ASC_MEDIUM_CHANGED 0x2800 #define SCSIS_ASC_PARAM_NOT_SUPPORTED 0x2601
#define SCSIS_ASC_WAS_RESET 0x2900 // reset by power-on/bus reset/device reset #define SCSIS_ASC_PARAM_VALUE_INV 0x2602
#define SCSIS_ASC_PARAMS_CHANGED 0x2a00 #define SCSIS_ASC_WRITE_PROTECTED 0x2700
#define SCSIS_ASC_MEDIUM_FORMAT_CORRUPTED 0x3100 #define SCSIS_ASC_MEDIUM_CHANGED 0x2800
#define SCSIS_ASC_ROUNDED_PARAM 0x3700 // parameter got rounded #define SCSIS_ASC_WAS_RESET 0x2900
#define SCSIS_ASC_NO_MEDIUM 0x3a00 // medium not present // reset by power-on/bus reset/device reset
#define SCSIS_ASC_INTERNAL_FAILURE 0x4400 #define SCSIS_ASC_PARAMS_CHANGED 0x2a00
#define SCSIS_ASC_SEL_FAILURE 0x4500 // select/reselect failure #define SCSIS_ASC_MEDIUM_FORMAT_CORRUPTED 0x3100
#define SCSIS_ASC_UNSUCC_SOFT_RESET 0x4600 // unsuccessful soft reset #define SCSIS_ASC_ROUNDED_PARAM 0x3700 // parameter got rounded
#define SCSIS_ASC_SCSI_PARITY_ERR 0x4700 // SCSI parity error #define SCSIS_ASC_NO_MEDIUM 0x3a00 // medium not present
#define SCSIS_ASC_LOAD_EJECT_FAILED 0x5300 // media load or eject failed #define SCSIS_ASC_INTERNAL_FAILURE 0x4400
#define SCSIS_ASC_REMOVAL_PREVENTED 0x5302 // medium removal prevented #define SCSIS_ASC_SEL_FAILURE 0x4500 // select/reselect failure
#define SCSIS_ASC_REMOVAL_REQUESTED 0x5a01 // operator requests medium removal #define SCSIS_ASC_UNSUCC_SOFT_RESET 0x4600 // unsuccessful soft reset
#define SCSIS_ASC_SCSI_PARITY_ERR 0x4700 // SCSI parity error
#define SCSIS_ASC_LOAD_EJECT_FAILED 0x5300
// media load or eject failed
#define SCSIS_ASC_REMOVAL_PREVENTED 0x5302 // medium removal prevented
#define SCSIS_ASC_REMOVAL_REQUESTED 0x5a01
// operator requests medium removal
// some scsi op-codes // some scsi op-codes
#define SCSI_OP_TEST_UNIT_READY 0x00 #define SCSI_OP_TEST_UNIT_READY 0x00
#define SCSI_OP_REQUEST_SENSE 0x03 #define SCSI_OP_REQUEST_SENSE 0x03
#define SCSI_OP_FORMAT 0x04 #define SCSI_OP_FORMAT 0x04
#define SCSI_OP_READ_6 0x08 #define SCSI_OP_READ_6 0x08
#define SCSI_OP_WRITE_6 0x0a #define SCSI_OP_WRITE_6 0x0a
#define SCSI_OP_INQUIRY 0x12 #define SCSI_OP_INQUIRY 0x12
#define SCSI_OP_MODE_SELECT_6 0x15 #define SCSI_OP_MODE_SELECT_6 0x15
#define SCSI_OP_RESERVE 0x16 #define SCSI_OP_RESERVE 0x16
#define SCSI_OP_RELEASE 0x17 #define SCSI_OP_RELEASE 0x17
#define SCSI_OP_MODE_SENSE_6 0x1a #define SCSI_OP_MODE_SENSE_6 0x1a
#define SCSI_OP_START_STOP 0x1b #define SCSI_OP_START_STOP 0x1b
#define SCSI_OP_RECEIVE_DIAGNOSTIC 0x1c #define SCSI_OP_RECEIVE_DIAGNOSTIC 0x1c
#define SCSI_OP_SEND_DIAGNOSTIC 0x1d #define SCSI_OP_SEND_DIAGNOSTIC 0x1d
#define SCSI_OP_PREVENT_ALLOW 0x1e #define SCSI_OP_PREVENT_ALLOW 0x1e
#define SCSI_OP_READ_CAPACITY 0x25 #define SCSI_OP_READ_CAPACITY 0x25
#define SCSI_OP_READ_10 0x28 #define SCSI_OP_READ_10 0x28
#define SCSI_OP_WRITE_10 0x2a #define SCSI_OP_WRITE_10 0x2a
#define SCSI_OP_POSITION_TO_ELEMENT 0x2b #define SCSI_OP_POSITION_TO_ELEMENT 0x2b
#define SCSI_OP_VERIFY 0x2f #define SCSI_OP_VERIFY 0x2f
#define SCSI_OP_SYNCHRONIZE_CACHE 0x35 #define SCSI_OP_SYNCHRONIZE_CACHE 0x35
#define SCSI_OP_WRITE_BUFFER 0x3b #define SCSI_OP_WRITE_BUFFER 0x3b
#define SCSI_OP_READ_BUFFER 0x3c #define SCSI_OP_READ_BUFFER 0x3c
#define SCSI_OP_CHANGE_DEFINITION 0x40 #define SCSI_OP_CHANGE_DEFINITION 0x40
#define SCSI_OP_READ_SUB_CHANNEL 0x42 #define SCSI_OP_READ_SUB_CHANNEL 0x42
#define SCSI_OP_READ_TOC 0x43 #define SCSI_OP_READ_TOC 0x43
#define SCSI_OP_PLAY_MSF 0x47 #define SCSI_OP_PLAY_MSF 0x47
#define SCSI_OP_PLAY_AUDIO_TRACK_INDEX 0x48 // obsolete, spec missing #define SCSI_OP_PLAY_AUDIO_TRACK_INDEX 0x48 // obsolete, spec missing
#define SCSI_OP_PAUSE_RESUME 0x4b #define SCSI_OP_PAUSE_RESUME 0x4b
#define SCSI_OP_STOP_PLAY 0x4e #define SCSI_OP_STOP_PLAY 0x4e
#define SCSI_OP_MODE_SELECT_10 0x55 #define SCSI_OP_MODE_SELECT_10 0x55
#define SCSI_OP_MODE_SENSE_10 0x5A #define SCSI_OP_MODE_SENSE_10 0x5A
#define SCSI_OP_MOVE_MEDIUM 0xa5 #define SCSI_OP_READ_16 0x88
#define SCSI_OP_READ_12 0xa8 #define SCSI_OP_WRITE_16 0x8a
#define SCSI_OP_WRITE_12 0xaa #define SCSI_OP_SERVICE_ACTION_IN 0x9e
#define SCSI_OP_READ_ELEMENT_STATUS 0xb8 #define SCSI_OP_SERVICE_ACTION_OUT 0x9f
#define SCSI_OP_SCAN 0xba #define SCSI_OP_MOVE_MEDIUM 0xa5
#define SCSI_OP_READ_CD 0xbe #define SCSI_OP_READ_12 0xa8
#define SCSI_OP_WRITE_12 0xaa
#define SCSI_OP_READ_ELEMENT_STATUS 0xb8
#define SCSI_OP_SCAN 0xba
#define SCSI_OP_READ_CD 0xbe
// Service-Action-In defines
#define SCSI_SAI_READ_CAPACITY_16 0x10
// INQUIRY // INQUIRY
@@ -999,4 +1045,5 @@ typedef struct scsi_cmd_sync_cache {
uint8 control; uint8 control;
} _PACKED scsi_cmd_sync_cache; } _PACKED scsi_cmd_sync_cache;
#endif /* _SCSI_CMDS_H */ #endif /* _SCSI_CMDS_H */