📄 sbc.h
字号:
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support - ROUSSET -
* ----------------------------------------------------------------------------
* Copyright (c) 2006, Atmel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaiimer below.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer below in the documentation and/or
* other materials provided with the distribution.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
/*
$Id: sbc.h 198 2006-10-30 10:01:09Z jjoannic $
*/
#ifndef _SBC_H
#define _SBC_H
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//! \brief Operation codes of commands described in the SBC-3 standard
//!
//! Note that most commands are actually defined in other standards,
//! like SPC-4. Optional commands are not included here.
//! \see sbc3r07.pdf - Section 5.1 - Table 12
//! \see spc4r06.pdf
//! \see S_sbc_command
#define SBC_INQUIRY 0x12
#define SBC_READ_10 0x28
#define SBC_READ_CAPACITY_10 0x25
#define SBC_REQUEST_SENSE 0x03
#define SBC_TEST_UNIT_READY 0x00
#define SBC_WRITE_10 0x2A
// Optional according to the standard, required by Windows
#define SBC_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1E
#define SBC_MODE_SENSE_6 0x1A
#define SBC_VERIFY_10 0x2F
//! \brief Peripheral qualifier values specified in the INQUIRY data
//! \see spc4r06.pdf - Section 6.4.2 - Table 83
//! \see S_sbc_inquiry_data
#define SBC_PERIPHERAL_DEVICE_CONNECTED 0x00
#define SBC_PERIPHERAL_DEVICE_NOT_CONNECTED 0x01
#define SBC_PERIPHERAL_DEVICE_NOT_SUPPORTED 0x03
//! \brief Peripheral device types specified in the INQUIRY data
//! \see spc4r06.pdf - Section 6.4.2 - Table 84
//! \see S_sbc_inquiry_data
#define SBC_DIRECT_ACCESS_BLOCK_DEVICE 0x00
#define SBC_SEQUENTIAL_ACCESS_DEVICE 0x01
#define SBC_PRINTER_DEVICE 0x02
#define SBC_PROCESSOR_DEVICE 0x03
#define SBC_WRITE_ONCE_DEVICE 0x04
#define SBC_CD_DVD_DEVICE 0x05
#define SBC_SCANNER_DEVICE 0x06
#define SBC_OPTICAL_MEMORY_DEVICE 0x07
#define SBC_MEDIA_CHANGER_DEVICE 0x08
#define SBC_COMMUNICATION_DEVICE 0x09
#define SBC_STORAGE_ARRAY_CONTROLLER_DEVICE 0x0C
#define SBC_ENCLOSURE_SERVICES_DEVICE 0x0D
#define SBC_SIMPLIFIED_DIRECT_ACCESS_DEVICE 0x0E
#define SBC_OPTICAL_CARD_READER_WRITER_DEVICE 0x0F
#define SBC_BRIDGE_CONTROLLER_COMMANDS 0x10
#define SBC_OBJECT_BASED_STORAGE_DEVICE 0x11
//! \brief Version value for the SBC-3 specification
//! \see spc4r06.pdf - Section 6.4.2 - Table 85
#define SBC_SPC_VERSION_4 0x06
//! \brief Values for the TPGS field returned in INQUIRY data
//! \see spc4r06.pdf - Section 6.4.2 - Table 86
#define SBC_TPGS_NONE 0x0
#define SBC_TPGS_ASYMMETRIC 0x1
#define SBC_TPGS_SYMMETRIC 0x2
#define SBC_TPGS_BOTH 0x3
//! \brief Version descriptor value for the SBC-3 specification
//! \see spc4r06.pdf - Section 6.4.2 - Table 87
#define SBC_VERSION_DESCRIPTOR_SBC_3 0x04C0
//! \brief Sense data response codes returned in REQUEST SENSE data
//! \see spc4r06.pdf - Section 4.5.1 - Table 12
#define SBC_SENSE_DATA_FIXED_CURRENT 0x70
#define SBC_SENSE_DATA_FIXED_DEFERRED 0x71
#define SBC_SENSE_DATA_DESCRIPTOR_CURRENT 0x72
#define SBC_SENSE_DATA_DESCRIPTOR_DEFERRED 0x73
//! \brief Sense key values returned in the REQUEST SENSE data
//! \see spc4r06.pdf - Section 4.5.6 - Table 27
#define SBC_SENSE_KEY_NO_SENSE 0x00
#define SBC_SENSE_KEY_RECOVERED_ERROR 0x01
#define SBC_SENSE_KEY_NOT_READY 0x02
#define SBC_SENSE_KEY_MEDIUM_ERROR 0x03
#define SBC_SENSE_KEY_HARDWARE_ERROR 0x04
#define SBC_SENSE_KEY_ILLEGAL_REQUEST 0x05
#define SBC_SENSE_KEY_UNIT_ATTENTION 0x06
#define SBC_SENSE_KEY_DATA_PROTECT 0x07
#define SBC_SENSE_KEY_BLANK_CHECK 0x08
#define SBC_SENSE_KEY_VENDOR_SPECIFIC 0x09
#define SBC_SENSE_KEY_COPY_ABORTED 0x0A
#define SBC_SENSE_KEY_ABORTED_COMMAND 0x0B
#define SBC_SENSE_KEY_VOLUME_OVERFLOW 0x0D
#define SBC_SENSE_KEY_MISCOMPARE 0x0E
//! \brief Additional sense code values returned in REQUEST SENSE data
//! \see spc4r06.pdf - Section 4.5.6 - Table 28
#define SBC_ASC_LOGICAL_UNIT_NOT_READY 0x04
#define SBC_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE 0x21
#define SBC_ASC_INVALID_FIELD_IN_CDB 0x24
#define SBC_ASC_WRITE_PROTECTED 0x27
#define SBC_ASC_FORMAT_CORRUPTED 0x31
#define SBC_ASC_INVALID_COMMAND_OPERATION_CODE 0x20
#define SBC_ASC_TOO_MUCH_WRITE_DATA 0x26
#define SBC_ASC_NOT_READY_TO_READY_CHANGE 0x28
#define SBC_ASC_MEDIUM_NOT_PRESENT 0x3A
//! \brief MEDIUM TYPE field value for direct-access block devices
//! \see sbc3r06.pdf - Section 6.3.1
#define SBC_MEDIUM_TYPE_DIRECT_ACCESS_BLOCK_DEVICE 0x00
//! \brief MRIE field values
//! \see sbc3r06.pdf - Section 7.4.11 - Table 286
#define SBC_MRIE_NO_REPORTING 0x00
#define SBC_MRIE_ASYNCHRONOUS 0x01
#define SBC_MRIE_GENERATE_UNIT_ATTENTION 0x02
#define SBC_MRIE_COND_GENERATE_RECOVERED_ERROR 0x03
#define SBC_MRIE_UNCOND_GENERATE_RECOVERED_ERROR 0x04
#define SBC_MRIE_GENERATE_NO_SENSE 0x05
#define SBC_MRIE_ON_REQUEST 0x06
//! \brief Supported mode pages
//! \see sbc3r06.pdf - Section 6.3.1 - Table 115
#define SBC_PAGE_READ_WRITE_ERROR_RECOVERY 0x01
#define SBC_PAGE_INFORMATIONAL_EXCEPTIONS_CONTROL 0x1C
#define SBC_PAGE_RETURN_ALL 0x3F
#define SBC_PAGE_VENDOR_SPECIFIC 0x00
//------------------------------------------------------------------------------
// Structures
//------------------------------------------------------------------------------
//! \brief Structure for the INQUIRY command
//! \see spc4r06.pdf - Section 6.4.1 - Table 81
__packed typedef struct {
unsigned char bOperationCode; //!< 0x12 : SBC_INQUIRY
unsigned char isEVPD:1, //!< Type of requested data
bReserved1:7; //!< Reserved bits
unsigned char bPageCode; //!< Specifies the VPD to return
unsigned char pAllocationLength[2]; //!< Size of host buffer
unsigned char bControl; //!< 0x00
} S_sbc_inquiry;
//! \brief Standard INQUIRY data format returned by the device
//! \see spc4r06.pdf - Section 6.4.2 - Table 82
__packed typedef struct {
unsigned char bPeripheralDeviceType:5, //!< Peripheral device type
bPeripheralQualifier :3; //!< Peripheral qualifier
unsigned char bReserved1:7, //!< Reserved bits
isRMB :1; //!< Is media removable ?
unsigned char bVersion; //!< SPC version used
unsigned char bResponseDataFormat:4, //!< Must be 0x2
isHIGHSUP :1, //!< Hierarchical addressing used ?
isNORMACA :1, //!< ACA attribute supported ?
bObsolete1 :2; //!< Obsolete bits
unsigned char bAdditionalLength; //!< Length of remaining INQUIRY data
unsigned char isSCCS :1, //!< Embedded SCC ?
isACC :1, //!< Access control coordinator ?
bTPGS :2, //!< Target port support group
is3PC :1, //!< Third-party copy supported ?
bReserved2:2, //!< Reserved bits
isProtect :1; //!< Protection info supported ?
unsigned char bObsolete2:1, //!< Obsolete bit
isEncServ :1, //!< Embedded enclosure service comp?
isVS :1, //!< ???
isMultiP :1, //!< Multi-port device ?
bObsolete3:3, //!< Obsolete bits
bUnused1 :1; //!< Unused feature
unsigned char bUnused2:6, //!< Unused features
isCmdQue:1, //!< Task management model supported ?
isVS2 :1; //!< ???
unsigned char pVendorID[8]; //!< T10 vendor identification
unsigned char pProductID[16]; //!< Vendor-defined product ID
unsigned char pProductRevisionLevel[4];//!< Vendor-defined product revision
unsigned char pVendorSpecific[20]; //!< Vendor-specific data
unsigned char bUnused3; //!< Unused features
unsigned char bReserved3; //!< Reserved bits
unsigned short pVersionDescriptors[8]; //!< Standards the device complies to
unsigned char pReserved4[22]; //!< Reserved bytes
} S_sbc_inquiry_data;
//! \brief Data structure for the READ (10) command
//! \see sbc3r07.pdf - Section 5.7 - Table 34
__packed typedef struct {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -