Subversion Repositories freemyipod

Rev

Rev 924 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
924 theseven 1
//
2
//
3
//    Copyright 2013 TheSeven
4
//    Copyright 2014 user890104
5
//
6
//
7
//    This file is part of emCORE.
8
//
9
//    emCORE is free software: you can redistribute it and/or
10
//    modify it under the terms of the GNU General Public License as
11
//    published by the Free Software Foundation, either version 2 of the
12
//    License, or (at your option) any later version.
13
//
14
//    emCORE is distributed in the hope that it will be useful,
15
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
16
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
//    See the GNU General Public License for more details.
18
//
19
//    You should have received a copy of the GNU General Public License along
20
//    with emCORE.  If not, see <http://www.gnu.org/licenses/>.
21
//
22
//
23
 
24
 
25
#ifndef __SCSI_H__
26
#define __SCSI_H__
27
 
28
#include "emcoreapp.h"
29
 
30
 
31
#define SCSI_TEST_UNIT_READY        0x00
32
#define SCSI_INQUIRY                0x12
33
#define SCSI_MODE_SENSE_6           0x1a
34
#define SCSI_MODE_SENSE_10          0x5a
35
#define SCSI_REQUEST_SENSE          0x03
36
#define SCSI_ALLOW_MEDIUM_REMOVAL   0x1e
37
#define SCSI_READ_CAPACITY          0x25
38
#define SCSI_READ_FORMAT_CAPACITY   0x23
39
#define SCSI_READ_10                0x28
40
#define SCSI_WRITE_10               0x2a
41
#define SCSI_START_STOP_UNIT        0x1b
42
#define SCSI_REPORT_LUNS            0xa0
43
#define SCSI_WRITE_BUFFER           0x3b
967 theseven 44
#define SCSI_ATA_PASSTHROUGH_12     0xa1
45
#define SCSI_ATA_PASSTHROUGH_16     0x85
924 theseven 46
 
967 theseven 47
#define SENSE_SOFT_ERROR            0x01
924 theseven 48
#define SENSE_NOT_READY             0x02
49
#define SENSE_MEDIUM_ERROR          0x03
967 theseven 50
#define SENSE_HARDWARE_ERROR        0x04
924 theseven 51
#define SENSE_ILLEGAL_REQUEST       0x05
52
#define SENSE_UNIT_ATTENTION        0x06
967 theseven 53
#define SENSE_DATA_PROTECT          0x07
54
#define SENSE_ABORTED_COMMAND       0x0b
924 theseven 55
 
56
#define ASC_MEDIUM_NOT_PRESENT      0x3a
57
#define ASC_INVALID_FIELD_IN_CBD    0x24
58
#define ASC_LBA_OUT_OF_RANGE        0x21
59
#define ASC_WRITE_ERROR             0x0C
60
#define ASC_READ_ERROR              0x11
61
#define ASC_NOT_READY               0x04
62
#define ASC_INVALID_COMMAND         0x20
967 theseven 63
#define ASC_INTERNAL_TARGET_FAILURE 0x44
64
#define ASC_ADDRESS_MARK_NOT_FOUND  0x13
65
#define ASC_OPERATOR_REQUEST        0x5a
66
#define ASC_MEDIUM_MAY_HAVE_CHANGED 0x28
67
#define ASC_SCSI_PARITY_ERROR       0x47
68
#define ASC_WRITE_PROTECTED         0x27
69
#define ASC_RECOVERED_ERROR         0x00
70
#define ASC_UNSUCCESSFUL_SOFT_RESET 0x46
924 theseven 71
 
72
#define ASCQ_BECOMING_READY         0x01
967 theseven 73
#define ASCQ_MEDIUM_REMOVAL_REQUEST 0x01
74
#define ASCQ_UICRC_ERROR_DETECTED   0x03
75
#define ASCQ_SAT_INFO_AVAILABLE     0x1d
924 theseven 76
 
967 theseven 77
#define SAT_HARD_RESET              0x0
78
#define SAT_SOFT_RESET              0x1
79
#define SAT_NON_DATA                0x3
80
#define SAT_PIO_DATA_IN             0x4
81
#define SAT_PIO_DATA_OUT            0x5
82
#define SAT_DMA                     0x6
83
#define SAT_DMA_QUEUED              0x7
84
#define SAT_DIAGNOSTIC              0x8
85
#define SAT_NON_DATA_RESET          0x9
86
#define SAT_UDMA_DATA_IN            0xa
87
#define SAT_UDMA_DATA_OUT           0xb
88
#define SAT_FPDMA                   0xc
89
#define SAT_RETURN_RESPONSE         0xf
90
 
924 theseven 91
#define DIRECT_ACCESS_DEVICE        0x00
92
#define DEVICE_REMOVABLE            0x80
93
 
94
#define SCSI_FORMAT_CAPACITY_FORMATTED_MEDIA 0x02000000
95
 
96
 
97
struct __attribute__((packed)) inquiry_data
98
{
99
    unsigned char DeviceType;
100
    unsigned char DeviceTypeModifier;
101
    unsigned char Versions;
102
    unsigned char Format;
103
    unsigned char AdditionalLength;
104
    unsigned char Reserved[2];
105
    unsigned char Capability;
106
    char VendorId[8];
107
    char ProductId[16];
108
    char ProductRevisionLevel[4];
109
};
110
 
111
struct __attribute__((packed)) report_lun_data
112
{
113
    unsigned int lun_list_length;
114
    unsigned int reserved1;
115
    unsigned char luns[1][8];
116
};
117
 
967 theseven 118
struct __attribute__((packed)) sense_data_fixed
924 theseven 119
{
120
    unsigned char ResponseCode;
121
    unsigned char Obsolete;
122
    unsigned char fei_sensekey;
123
    unsigned int Information;
124
    unsigned char AdditionalSenseLength;
125
    unsigned int  CommandSpecificInformation;
126
    unsigned char AdditionalSenseCode;
127
    unsigned char AdditionalSenseCodeQualifier;
128
    unsigned char FieldReplaceableUnitCode;
129
    unsigned char SKSV;
130
    unsigned short SenseKeySpecific;
131
};
132
 
967 theseven 133
struct __attribute__((packed)) sense_data_descr
134
{
135
    unsigned char ResponseCode;
136
    unsigned char fei_sensekey;
137
    unsigned char AdditionalSenseCode;
138
    unsigned char AdditionalSenseCodeQualifier;
139
    unsigned char Reserved[3];
140
    unsigned char AdditionalSenseLength;
141
};
142
 
924 theseven 143
struct __attribute__((packed)) mode_sense_bdesc_longlba
144
{
145
    unsigned char num_blocks[8];
146
    unsigned char reserved[4];
147
    unsigned char block_size[4];
148
};
149
 
150
struct __attribute__((packed)) mode_sense_bdesc_shortlba
151
{
152
    unsigned char density_code;
153
    unsigned char num_blocks[3];
154
    unsigned char reserved;
155
    unsigned char block_size[3];
156
};
157
 
158
struct __attribute__((packed)) mode_sense_data_10
159
{
160
    unsigned short mode_data_length;
161
    unsigned char medium_type;
162
    unsigned char device_specific;
163
    unsigned char longlba;
164
    unsigned char reserved;
165
    unsigned short block_descriptor_length;
166
    struct mode_sense_bdesc_longlba block_descriptor;
167
};
168
 
169
struct __attribute__((packed)) mode_sense_data_6
170
{
171
    unsigned char mode_data_length;
172
    unsigned char medium_type;
173
    unsigned char device_specific;
174
    unsigned char block_descriptor_length;
175
    struct mode_sense_bdesc_shortlba block_descriptor;
176
};
177
 
178
struct __attribute__((packed)) capacity
179
{
180
    unsigned int block_count;
181
    unsigned int block_size;
182
};
183
 
184
struct __attribute__((packed)) format_capacity
185
{
186
    unsigned int following_length;
187
    unsigned int block_count;
188
    unsigned int block_size;
189
};
190
 
191
 
192
#endif
193