SyterKit
0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
include
drivers
ufs
scsi.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: GPL-2.0+ */
2
3
#ifndef __SCSI_H__
4
#define __SCSI_H__
5
6
#include <stdarg.h>
7
#include <stdbool.h>
8
#include <stddef.h>
9
#include <stdint.h>
10
#include <types.h>
11
12
#define SCSI_MAX_DEVICE (128)
13
14
typedef
struct
scsi_cmd
{
15
uint8_t
cmd
[16];
/* command */
16
uint8_t
sense_buf
[64];
/* sense_buf */
17
uint8_t
status
;
/* SCSI Status */
18
uint8_t
target
;
/* Target ID */
19
uint8_t
lun
;
/* Target LUN */
20
uint8_t
cmdlen
;
/* command len */
21
uint64_t
datalen
;
/* Total data length */
22
uint8_t
*
pdata
;
/* pointer to data */
23
uint8_t
msgout
[12];
/* Messge out buffer (NOT USED) */
24
uint8_t
msgin
[12];
/* Message in buffer */
25
uint8_t
sensecmdlen
;
/* Sense command len */
26
uint64_t
sensedatalen
;
/* Sense data len */
27
uint8_t
sensecmd
[6];
/* Sense command */
28
uint64_t
contr_stat
;
/* Controller Status */
29
uint64_t
trans_bytes
;
/* tranfered bytes */
30
31
uint32_t
priv
;
32
uint32_t
dma_dir
;
33
}
scsi_cmd_t
;
34
35
/* SCSI constants. */
36
/* Messages */
37
#define M_COMPLETE (0x00)
38
#define M_EXTENDED (0x01)
39
#define M_SAVE_DP (0x02)
40
#define M_RESTORE_DP (0x03)
41
#define M_DISCONNECT (0x04)
42
#define M_ID_ERROR (0x05)
43
#define M_ABORT (0x06)
44
#define M_REJECT (0x07)
45
#define M_NOOP (0x08)
46
#define M_PARITY (0x09)
47
#define M_LCOMPLETE (0x0a)
48
#define M_FCOMPLETE (0x0b)
49
#define M_RESET (0x0c)
50
#define M_ABORT_TAG (0x0d)
51
#define M_CLEAR_QUEUE (0x0e)
52
#define M_INIT_REC (0x0f)
53
#define M_REL_REC (0x10)
54
#define M_TERMINATE (0x11)
55
#define M_SIMPLE_TAG (0x20)
56
#define M_HEAD_TAG (0x21)
57
#define M_ORDERED_TAG (0x22)
58
#define M_IGN_RESIDUE (0x23)
59
#define M_IDENTIFY (0x80)
60
61
#define M_X_MODIFY_DP (0x00)
62
#define M_X_SYNC_REQ (0x01)
63
#define M_X_WIDE_REQ (0x03)
64
#define M_X_PPR_REQ (0x04)
65
66
/* Status */
67
#define S_GOOD (0x00)
68
#define S_CHECK_COND (0x02)
69
#define S_COND_MET (0x04)
70
#define S_BUSY (0x08)
71
#define S_INT (0x10)
72
#define S_INT_COND_MET (0x14)
73
#define S_CONFLICT (0x18)
74
#define S_TERMINATED (0x20)
75
#define S_QUEUE_FULL (0x28)
76
#define S_ILLEGAL (0xff)
77
#define S_SENSE (0x80)
78
79
/* Sense_keys */
80
#define SENSE_NO_SENSE 0x0
81
#define SENSE_RECOVERED_ERROR 0x1
82
#define SENSE_NOT_READY 0x2
83
#define SENSE_MEDIUM_ERROR 0x3
84
#define SENSE_HARDWARE_ERROR 0x4
85
#define SENSE_ILLEGAL_REQUEST 0x5
86
#define SENSE_UNIT_ATTENTION 0x6
87
#define SENSE_DATA_PROTECT 0x7
88
#define SENSE_BLANK_CHECK 0x8
89
#define SENSE_VENDOR_SPECIFIC 0x9
90
#define SENSE_COPY_ABORTED 0xA
91
#define SENSE_ABORTED_COMMAND 0xB
92
#define SENSE_VOLUME_OVERFLOW 0xD
93
#define SENSE_MISCOMPARE 0xE
94
95
/* SCSI CMD */
96
#define SCSI_CHANGE_DEF 0x40
/* Change Definition (Optional) */
97
#define SCSI_COMPARE 0x39
/* Compare (O) */
98
#define SCSI_COPY 0x18
/* Copy (O) */
99
#define SCSI_COP_VERIFY 0x3A
/* Copy and Verify (O) */
100
#define SCSI_INQUIRY 0x12
/* Inquiry (MANDATORY) */
101
#define SCSI_LOG_SELECT 0x4C
/* Log Select (O) */
102
#define SCSI_LOG_SENSE 0x4D
/* Log Sense (O) */
103
#define SCSI_MODE_SEL6 0x15
/* Mode Select 6-byte (Device Specific) */
104
#define SCSI_MODE_SEL10 0x55
/* Mode Select 10-byte (Device Specific) */
105
#define SCSI_MODE_SEN6 0x1A
/* Mode Sense 6-byte (Device Specific) */
106
#define SCSI_MODE_SEN10 0x5A
/* Mode Sense 10-byte (Device Specific) */
107
#define SCSI_READ_BUFF 0x3C
/* Read Buffer (O) */
108
#define SCSI_REQ_SENSE 0x03
/* Request Sense (MANDATORY) */
109
#define SCSI_START_STOP 0x1b
/*start stop unit command */
110
#define SCSI_SEND_DIAG 0x1D
/* Send Diagnostic (O) */
111
#define SCSI_TST_U_RDY 0x00
/* Test Unit Ready (MANDATORY) */
112
#define SCSI_WRITE_BUFF 0x3B
/* Write Buffer (O) */
113
#define SCSI_COMPARE 0x39
/* Compare (O) */
114
#define SCSI_FORMAT 0x04
/* Format Unit (MANDATORY) */
115
#define SCSI_LCK_UN_CAC 0x36
/* Lock Unlock Cache (O) */
116
#define SCSI_PREFETCH 0x34
/* Prefetch (O) */
117
#define SCSI_MED_REMOVL 0x1E
/* Prevent/Allow medium Removal (O) */
118
#define SCSI_READ6 0x08
/* Read 6-byte (MANDATORY) */
119
#define SCSI_READ10 0x28
/* Read 10-byte (MANDATORY) */
120
#define SCSI_READ16 0x48
121
#define SCSI_RD_CAPAC 0x25
/* Read Capacity (MANDATORY) */
122
#define SCSI_RD_CAPAC10 SCSI_RD_CAPAC
/* Read Capacity (10) */
123
#define SCSI_RD_CAPAC16 0x9e
/* Read Capacity (16) */
124
#define SCSI_RD_DEFECT 0x37
/* Read Defect Data (O) */
125
#define SCSI_READ_LONG 0x3E
/* Read Long (O) */
126
#define SCSI_REASS_BLK 0x07
/* Reassign Blocks (O) */
127
#define SCSI_RCV_DIAG 0x1C
/* Receive Diagnostic Results (O) */
128
#define SCSI_RELEASE 0x17
/* Release Unit (MANDATORY) */
129
#define SCSI_REZERO 0x01
/* Rezero Unit (O) */
130
#define SCSI_SRCH_DAT_E 0x31
/* Search Data Equal (O) */
131
#define SCSI_SRCH_DAT_H 0x30
/* Search Data High (O) */
132
#define SCSI_SRCH_DAT_L 0x32
/* Search Data Low (O) */
133
#define SCSI_SEEK6 0x0B
/* Seek 6-Byte (O) */
134
#define SCSI_SEEK10 0x2B
/* Seek 10-Byte (O) */
135
#define SCSI_SEND_DIAG 0x1D
/* Send Diagnostics (MANDATORY) */
136
#define SCSI_SET_LIMIT 0x33
/* Set Limits (O) */
137
#define SCSI_START_STP 0x1B
/* Start/Stop Unit (O) */
138
#define SCSI_SYNC_CACHE 0x35
/* Synchronize Cache (O) */
139
#define SCSI_VERIFY 0x2F
/* Verify (O) */
140
#define SCSI_WRITE6 0x0A
/* Write 6-Byte (MANDATORY) */
141
#define SCSI_WRITE10 0x2A
/* Write 10-Byte (MANDATORY) */
142
#define SCSI_WRT_VERIFY 0x2E
/* Write and Verify (O) */
143
#define SCSI_WRITE_LONG 0x3F
/* Write Long (O) */
144
#define SCSI_WRITE_SAME 0x41
/* Write Same (O) */
145
154
typedef
struct
scsi_plat
{
155
uint64_t
base
;
156
uint64_t
max_lun
;
157
uint64_t
max_id
;
158
uint64_t
max_bytes_per_req
;
159
}
scsi_plat_t
;
160
161
#define SCSI_IDENTIFY 0xC0
/* not used */
162
163
/* Hardware errors */
164
#define SCSI_SEL_TIME_OUT 0x00000101
/* Selection time out */
165
#define SCSI_HNS_TIME_OUT 0x00000102
/* Handshake */
166
#define SCSI_MA_TIME_OUT 0x00000103
/* Phase error */
167
#define SCSI_UNEXP_DIS 0x00000104
/* unexpected disconnect */
168
#define SCSI_INT_STATE 0x00010000
/* unknown Interrupt number is stored in 16 LSB */
169
170
enum
dma_data_direction
{
171
DMA_BIDIRECTIONAL
= 0,
172
DMA_TO_DEVICE
= 1,
173
DMA_FROM_DEVICE
= 2,
174
DMA_NONE
= 3,
175
};
176
177
#endif
// __SCSI_H__
uint64_t
u64_t uint64_t
Definition
stdint.h:16
uint32_t
u32_t uint32_t
Definition
stdint.h:13
uint8_t
u8_t uint8_t
Definition
stdint.h:7
scsi_cmd_t
struct scsi_cmd scsi_cmd_t
dma_data_direction
dma_data_direction
Definition
scsi.h:170
DMA_NONE
@ DMA_NONE
Definition
scsi.h:174
DMA_TO_DEVICE
@ DMA_TO_DEVICE
Definition
scsi.h:172
DMA_FROM_DEVICE
@ DMA_FROM_DEVICE
Definition
scsi.h:173
DMA_BIDIRECTIONAL
@ DMA_BIDIRECTIONAL
Definition
scsi.h:171
scsi_plat_t
struct scsi_plat scsi_plat_t
struct scsi_plat - stores information about SCSI controller
scsi_cmd
Definition
scsi.h:14
scsi_cmd::msgin
uint8_t msgin[12]
Definition
scsi.h:24
scsi_cmd::priv
uint32_t priv
Definition
scsi.h:31
scsi_cmd::pdata
uint8_t * pdata
Definition
scsi.h:22
scsi_cmd::datalen
uint64_t datalen
Definition
scsi.h:21
scsi_cmd::contr_stat
uint64_t contr_stat
Definition
scsi.h:28
scsi_cmd::lun
uint8_t lun
Definition
scsi.h:19
scsi_cmd::msgout
uint8_t msgout[12]
Definition
scsi.h:23
scsi_cmd::sense_buf
uint8_t sense_buf[64]
Definition
scsi.h:16
scsi_cmd::status
uint8_t status
Definition
scsi.h:17
scsi_cmd::cmdlen
uint8_t cmdlen
Definition
scsi.h:20
scsi_cmd::target
uint8_t target
Definition
scsi.h:18
scsi_cmd::sensedatalen
uint64_t sensedatalen
Definition
scsi.h:26
scsi_cmd::sensecmd
uint8_t sensecmd[6]
Definition
scsi.h:27
scsi_cmd::dma_dir
uint32_t dma_dir
Definition
scsi.h:32
scsi_cmd::trans_bytes
uint64_t trans_bytes
Definition
scsi.h:29
scsi_cmd::cmd
uint8_t cmd[16]
Definition
scsi.h:15
scsi_cmd::sensecmdlen
uint8_t sensecmdlen
Definition
scsi.h:25
scsi_plat
struct scsi_plat - stores information about SCSI controller
Definition
scsi.h:154
scsi_plat::max_id
uint64_t max_id
Definition
scsi.h:157
scsi_plat::max_bytes_per_req
uint64_t max_bytes_per_req
Definition
scsi.h:158
scsi_plat::max_lun
uint64_t max_lun
Definition
scsi.h:156
scsi_plat::base
uint64_t base
Definition
scsi.h:155
Generated by
1.9.8