| 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
|
|
|
44 |
|
|
|
45 |
#define SENSE_NOT_READY 0x02
|
|
|
46 |
#define SENSE_MEDIUM_ERROR 0x03
|
|
|
47 |
#define SENSE_ILLEGAL_REQUEST 0x05
|
|
|
48 |
#define SENSE_UNIT_ATTENTION 0x06
|
|
|
49 |
|
|
|
50 |
#define ASC_MEDIUM_NOT_PRESENT 0x3a
|
|
|
51 |
#define ASC_INVALID_FIELD_IN_CBD 0x24
|
|
|
52 |
#define ASC_LBA_OUT_OF_RANGE 0x21
|
|
|
53 |
#define ASC_WRITE_ERROR 0x0C
|
|
|
54 |
#define ASC_READ_ERROR 0x11
|
|
|
55 |
#define ASC_NOT_READY 0x04
|
|
|
56 |
#define ASC_INVALID_COMMAND 0x20
|
|
|
57 |
|
|
|
58 |
#define ASCQ_BECOMING_READY 0x01
|
|
|
59 |
|
|
|
60 |
#define DIRECT_ACCESS_DEVICE 0x00
|
|
|
61 |
#define DEVICE_REMOVABLE 0x80
|
|
|
62 |
|
|
|
63 |
#define SCSI_FORMAT_CAPACITY_FORMATTED_MEDIA 0x02000000
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
struct __attribute__((packed)) inquiry_data
|
|
|
67 |
{
|
|
|
68 |
unsigned char DeviceType;
|
|
|
69 |
unsigned char DeviceTypeModifier;
|
|
|
70 |
unsigned char Versions;
|
|
|
71 |
unsigned char Format;
|
|
|
72 |
unsigned char AdditionalLength;
|
|
|
73 |
unsigned char Reserved[2];
|
|
|
74 |
unsigned char Capability;
|
|
|
75 |
char VendorId[8];
|
|
|
76 |
char ProductId[16];
|
|
|
77 |
char ProductRevisionLevel[4];
|
|
|
78 |
};
|
|
|
79 |
|
|
|
80 |
struct __attribute__((packed)) report_lun_data
|
|
|
81 |
{
|
|
|
82 |
unsigned int lun_list_length;
|
|
|
83 |
unsigned int reserved1;
|
|
|
84 |
unsigned char luns[1][8];
|
|
|
85 |
};
|
|
|
86 |
|
|
|
87 |
struct __attribute__((packed)) sense_data
|
|
|
88 |
{
|
|
|
89 |
unsigned char ResponseCode;
|
|
|
90 |
unsigned char Obsolete;
|
|
|
91 |
unsigned char fei_sensekey;
|
|
|
92 |
unsigned int Information;
|
|
|
93 |
unsigned char AdditionalSenseLength;
|
|
|
94 |
unsigned int CommandSpecificInformation;
|
|
|
95 |
unsigned char AdditionalSenseCode;
|
|
|
96 |
unsigned char AdditionalSenseCodeQualifier;
|
|
|
97 |
unsigned char FieldReplaceableUnitCode;
|
|
|
98 |
unsigned char SKSV;
|
|
|
99 |
unsigned short SenseKeySpecific;
|
|
|
100 |
};
|
|
|
101 |
|
|
|
102 |
struct __attribute__((packed)) mode_sense_bdesc_longlba
|
|
|
103 |
{
|
|
|
104 |
unsigned char num_blocks[8];
|
|
|
105 |
unsigned char reserved[4];
|
|
|
106 |
unsigned char block_size[4];
|
|
|
107 |
};
|
|
|
108 |
|
|
|
109 |
struct __attribute__((packed)) mode_sense_bdesc_shortlba
|
|
|
110 |
{
|
|
|
111 |
unsigned char density_code;
|
|
|
112 |
unsigned char num_blocks[3];
|
|
|
113 |
unsigned char reserved;
|
|
|
114 |
unsigned char block_size[3];
|
|
|
115 |
};
|
|
|
116 |
|
|
|
117 |
struct __attribute__((packed)) mode_sense_data_10
|
|
|
118 |
{
|
|
|
119 |
unsigned short mode_data_length;
|
|
|
120 |
unsigned char medium_type;
|
|
|
121 |
unsigned char device_specific;
|
|
|
122 |
unsigned char longlba;
|
|
|
123 |
unsigned char reserved;
|
|
|
124 |
unsigned short block_descriptor_length;
|
|
|
125 |
struct mode_sense_bdesc_longlba block_descriptor;
|
|
|
126 |
};
|
|
|
127 |
|
|
|
128 |
struct __attribute__((packed)) mode_sense_data_6
|
|
|
129 |
{
|
|
|
130 |
unsigned char mode_data_length;
|
|
|
131 |
unsigned char medium_type;
|
|
|
132 |
unsigned char device_specific;
|
|
|
133 |
unsigned char block_descriptor_length;
|
|
|
134 |
struct mode_sense_bdesc_shortlba block_descriptor;
|
|
|
135 |
};
|
|
|
136 |
|
|
|
137 |
struct __attribute__((packed)) capacity
|
|
|
138 |
{
|
|
|
139 |
unsigned int block_count;
|
|
|
140 |
unsigned int block_size;
|
|
|
141 |
};
|
|
|
142 |
|
|
|
143 |
struct __attribute__((packed)) format_capacity
|
|
|
144 |
{
|
|
|
145 |
unsigned int following_length;
|
|
|
146 |
unsigned int block_count;
|
|
|
147 |
unsigned int block_size;
|
|
|
148 |
};
|
|
|
149 |
|
|
|
150 |
|
|
|
151 |
#endif
|
|
|
152 |
|