1 /*! 2 \file msc_scsi.h 3 \brief definitions for the USB MSC SCSI commands 4 5 \version 2020-08-04, V1.1.0, firmware for GD32VF103 6 */ 7 8 /* 9 Copyright (c) 2020, GigaDevice Semiconductor Inc. 10 11 Redistribution and use in source and binary forms, with or without modification, 12 are permitted provided that the following conditions are met: 13 14 1. Redistributions of source code must retain the above copyright notice, this 15 list of conditions and the following disclaimer. 16 2. Redistributions in binary form must reproduce the above copyright notice, 17 this list of conditions and the following disclaimer in the documentation 18 and/or other materials provided with the distribution. 19 3. Neither the name of the copyright holder nor the names of its contributors 20 may be used to endorse or promote products derived from this software without 21 specific prior written permission. 22 23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 27 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 OF SUCH DAMAGE. 33 */ 34 35 #ifndef __MSC_SCSI_H 36 #define __MSC_SCSI_H 37 38 #include "usb_ch9_std.h" 39 40 /* SCSI commands */ 41 #define SCSI_FORMAT_UNIT 0x04U 42 #define SCSI_INQUIRY 0x12U 43 #define SCSI_MODE_SELECT6 0x15U 44 #define SCSI_MODE_SELECT10 0x55U 45 #define SCSI_MODE_SENSE6 0x1AU 46 #define SCSI_READ_TOC_DATA 0x43U 47 #define SCSI_MODE_SENSE10 0x5AU 48 #define SCSI_ALLOW_MEDIUM_REMOVAL 0x1EU 49 #define SCSI_READ6 0x08U 50 #define SCSI_READ10 0x28U 51 #define SCSI_READ12 0xA8U 52 #define SCSI_READ16 0x88U 53 54 #define SCSI_READ_CAPACITY10 0x25U 55 #define SCSI_READ_CAPACITY16 0x9EU 56 57 #define SCSI_REQUEST_SENSE 0x03U 58 #define SCSI_START_STOP_UNIT 0x1BU 59 #define SCSI_TEST_UNIT_READY 0x00U 60 #define SCSI_WRITE6 0x0AU 61 #define SCSI_WRITE10 0x2AU 62 #define SCSI_WRITE12 0xAAU 63 #define SCSI_WRITE16 0x8AU 64 65 #define SCSI_VERIFY10 0x2FU 66 #define SCSI_VERIFY12 0xAFU 67 #define SCSI_VERIFY16 0x8FU 68 69 #define SCSI_SEND_DIAGNOSTIC 0x1DU 70 #define SCSI_READ_FORMAT_CAPACITIES 0x23U 71 72 #define INVALID_CDB 0x20U 73 #define INVALID_FIELED_IN_COMMAND 0x24U 74 #define PARAMETER_LIST_LENGTH_ERROR 0x1AU 75 #define INVALID_FIELD_IN_PARAMETER_LIST 0x26U 76 #define ADDRESS_OUT_OF_RANGE 0x21U 77 #define MEDIUM_NOT_PRESENT 0x3AU 78 #define MEDIUM_HAVE_CHANGED 0x28U 79 #define WRITE_PROTECTED 0x27U 80 #define UNRECOVERED_READ_ERROR 0x11U 81 #define WRITE_FAULT 0x03U 82 83 #define READ_FORMAT_CAPACITY_DATA_LEN 0x0CU 84 #define READ_CAPACITY10_DATA_LEN 0x08U 85 #define MODE_SENSE10_DATA_LEN 0x08U 86 #define MODE_SENSE6_DATA_LEN 0x04U 87 #define READ_TOC_CMD_LEN 0x14U 88 #define REQUEST_SENSE_DATA_LEN 0x12U 89 #define STANDARD_INQUIRY_DATA_LEN 0x24U 90 #define BLKVFY 0x04U 91 92 enum sense_state { 93 NO_SENSE = 0U, 94 RECOVERED_ERROR, 95 NOT_READY, 96 MEDIUM_ERROR, 97 HARDWARE_ERROR, 98 ILLEGAL_REQUEST, 99 UNIT_ATTENTION, 100 DATA_PROTECT, 101 BLANK_CHECK, 102 VENDOR_SPECIFIC, 103 COPY_ABORTED, 104 ABORTED_COMMAND, 105 RESERVED, 106 VOLUME_OVERFLOW, 107 MISCOMPARE 108 }; 109 110 typedef struct { 111 uint8_t SenseKey; 112 uint32_t Information; 113 uint8_t ASC; 114 uint8_t ASCQ; 115 } msc_scsi_sense; 116 117 #endif /* __MSC_SCSI_H */ 118