blob: aaafc9ca7902713f6fec72f9e7c8d1fe941d9f44 [file] [log] [blame]
wdenke85390d2002-04-01 14:29:03 +00001/*
2 * (C) Copyright 2001
3 * Denis Peter, MPL AG Switzerland
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 *
23 */
24 #ifndef _SCSI_H
25 #define _SCSI_H
26
27typedef struct SCSI_cmd_block{
28 unsigned char cmd[16]; /* command */
29 unsigned char sense_buf[64]; /* for request sense */
30 unsigned char status; /* SCSI Status */
31 unsigned char target; /* Target ID */
32 unsigned char lun; /* Target LUN */
33 unsigned char cmdlen; /* command len */
34 unsigned long datalen; /* Total data length */
Wolfgang Denk53677ef2008-05-20 16:00:29 +020035 unsigned char * pdata; /* pointer to data */
wdenke85390d2002-04-01 14:29:03 +000036 unsigned char msgout[12]; /* Messge out buffer (NOT USED) */
37 unsigned char msgin[12]; /* Message in buffer */
38 unsigned char sensecmdlen; /* Sense command len */
39 unsigned long sensedatalen; /* Sense data len */
40 unsigned char sensecmd[6]; /* Sense command */
41 unsigned long contr_stat; /* Controller Status */
42 unsigned long trans_bytes; /* tranfered bytes */
43
44 unsigned int priv;
45}ccb;
46
47/*-----------------------------------------------------------
48**
49** SCSI constants.
50**
51**-----------------------------------------------------------
52*/
53
54/*
55** Messages
56*/
57
58#define M_COMPLETE (0x00)
59#define M_EXTENDED (0x01)
60#define M_SAVE_DP (0x02)
61#define M_RESTORE_DP (0x03)
62#define M_DISCONNECT (0x04)
63#define M_ID_ERROR (0x05)
64#define M_ABORT (0x06)
65#define M_REJECT (0x07)
66#define M_NOOP (0x08)
67#define M_PARITY (0x09)
68#define M_LCOMPLETE (0x0a)
69#define M_FCOMPLETE (0x0b)
70#define M_RESET (0x0c)
71#define M_ABORT_TAG (0x0d)
72#define M_CLEAR_QUEUE (0x0e)
73#define M_INIT_REC (0x0f)
74#define M_REL_REC (0x10)
75#define M_TERMINATE (0x11)
76#define M_SIMPLE_TAG (0x20)
77#define M_HEAD_TAG (0x21)
78#define M_ORDERED_TAG (0x22)
79#define M_IGN_RESIDUE (0x23)
Wolfgang Denk53677ef2008-05-20 16:00:29 +020080#define M_IDENTIFY (0x80)
wdenke85390d2002-04-01 14:29:03 +000081
82#define M_X_MODIFY_DP (0x00)
83#define M_X_SYNC_REQ (0x01)
84#define M_X_WIDE_REQ (0x03)
85#define M_X_PPR_REQ (0x04)
86
87
88/*
89** Status
90*/
91
92#define S_GOOD (0x00)
93#define S_CHECK_COND (0x02)
94#define S_COND_MET (0x04)
95#define S_BUSY (0x08)
96#define S_INT (0x10)
97#define S_INT_COND_MET (0x14)
98#define S_CONFLICT (0x18)
99#define S_TERMINATED (0x20)
100#define S_QUEUE_FULL (0x28)
101#define S_ILLEGAL (0xff)
102#define S_SENSE (0x80)
103
104/*
105 * Sense_keys
106 */
107
108#define SENSE_NO_SENSE 0x0
109#define SENSE_RECOVERED_ERROR 0x1
110#define SENSE_NOT_READY 0x2
111#define SENSE_MEDIUM_ERROR 0x3
112#define SENSE_HARDWARE_ERROR 0x4
113#define SENSE_ILLEGAL_REQUEST 0x5
114#define SENSE_UNIT_ATTENTION 0x6
115#define SENSE_DATA_PROTECT 0x7
116#define SENSE_BLANK_CHECK 0x8
117#define SENSE_VENDOR_SPECIFIC 0x9
118#define SENSE_COPY_ABORTED 0xA
119#define SENSE_ABORTED_COMMAND 0xB
120#define SENSE_VOLUME_OVERFLOW 0xD
121#define SENSE_MISCOMPARE 0xE
122
123
124#define SCSI_CHANGE_DEF 0x40 /* Change Definition (Optional) */
125#define SCSI_COMPARE 0x39 /* Compare (O) */
126#define SCSI_COPY 0x18 /* Copy (O) */
127#define SCSI_COP_VERIFY 0x3A /* Copy and Verify (O) */
128#define SCSI_INQUIRY 0x12 /* Inquiry (MANDATORY) */
129#define SCSI_LOG_SELECT 0x4C /* Log Select (O) */
130#define SCSI_LOG_SENSE 0x4D /* Log Sense (O) */
131#define SCSI_MODE_SEL6 0x15 /* Mode Select 6-byte (Device Specific) */
132#define SCSI_MODE_SEL10 0x55 /* Mode Select 10-byte (Device Specific) */
133#define SCSI_MODE_SEN6 0x1A /* Mode Sense 6-byte (Device Specific) */
134#define SCSI_MODE_SEN10 0x5A /* Mode Sense 10-byte (Device Specific) */
135#define SCSI_READ_BUFF 0x3C /* Read Buffer (O) */
136#define SCSI_REQ_SENSE 0x03 /* Request Sense (MANDATORY) */
137#define SCSI_SEND_DIAG 0x1D /* Send Diagnostic (O) */
138#define SCSI_TST_U_RDY 0x00 /* Test Unit Ready (MANDATORY) */
139#define SCSI_WRITE_BUFF 0x3B /* Write Buffer (O) */
140/***************************************************************************
141 * %%% Commands Unique to Direct Access Devices %%%
142 ***************************************************************************/
143#define SCSI_COMPARE 0x39 /* Compare (O) */
144#define SCSI_FORMAT 0x04 /* Format Unit (MANDATORY) */
145#define SCSI_LCK_UN_CAC 0x36 /* Lock Unlock Cache (O) */
146#define SCSI_PREFETCH 0x34 /* Prefetch (O) */
147#define SCSI_MED_REMOVL 0x1E /* Prevent/Allow medium Removal (O) */
148#define SCSI_READ6 0x08 /* Read 6-byte (MANDATORY) */
149#define SCSI_READ10 0x28 /* Read 10-byte (MANDATORY) */
150#define SCSI_RD_CAPAC 0x25 /* Read Capacity (MANDATORY) */
151#define SCSI_RD_DEFECT 0x37 /* Read Defect Data (O) */
152#define SCSI_READ_LONG 0x3E /* Read Long (O) */
153#define SCSI_REASS_BLK 0x07 /* Reassign Blocks (O) */
154#define SCSI_RCV_DIAG 0x1C /* Receive Diagnostic Results (O) */
155#define SCSI_RELEASE 0x17 /* Release Unit (MANDATORY) */
156#define SCSI_REZERO 0x01 /* Rezero Unit (O) */
157#define SCSI_SRCH_DAT_E 0x31 /* Search Data Equal (O) */
158#define SCSI_SRCH_DAT_H 0x30 /* Search Data High (O) */
159#define SCSI_SRCH_DAT_L 0x32 /* Search Data Low (O) */
160#define SCSI_SEEK6 0x0B /* Seek 6-Byte (O) */
161#define SCSI_SEEK10 0x2B /* Seek 10-Byte (O) */
162#define SCSI_SEND_DIAG 0x1D /* Send Diagnostics (MANDATORY) */
163#define SCSI_SET_LIMIT 0x33 /* Set Limits (O) */
164#define SCSI_START_STP 0x1B /* Start/Stop Unit (O) */
165#define SCSI_SYNC_CACHE 0x35 /* Synchronize Cache (O) */
166#define SCSI_VERIFY 0x2F /* Verify (O) */
167#define SCSI_WRITE6 0x0A /* Write 6-Byte (MANDATORY) */
168#define SCSI_WRITE10 0x2A /* Write 10-Byte (MANDATORY) */
169#define SCSI_WRT_VERIFY 0x2E /* Write and Verify (O) */
170#define SCSI_WRITE_LONG 0x3F /* Write Long (O) */
171#define SCSI_WRITE_SAME 0x41 /* Write Same (O) */
172
173
174/****************************************************************************
175 * decleration of functions which have to reside in the LowLevel Part Driver
176 */
177
178void scsi_print_error(ccb *pccb);
179int scsi_exec(ccb *pccb);
180void scsi_bus_reset(void);
181void scsi_low_level_init(int busdevfunc);
182
183
184/***************************************************************************
185 * functions residing inside cmd_scsi.c
186 */
187void scsi_init(void);
188
189
wdenke85390d2002-04-01 14:29:03 +0000190#define SCSI_IDENTIFY 0xC0 /* not used */
191
192/* Hardware errors */
193#define SCSI_SEL_TIME_OUT 0x00000101 /* Selection time out */
194#define SCSI_HNS_TIME_OUT 0x00000102 /* Handshake */
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200195#define SCSI_MA_TIME_OUT 0x00000103 /* Phase error */
wdenke85390d2002-04-01 14:29:03 +0000196#define SCSI_UNEXP_DIS 0x00000104 /* unexpected disconnect */
197
198#define SCSI_INT_STATE 0x00010000 /* unknown Interrupt number is stored in 16 LSB */
199
200
wdenke85390d2002-04-01 14:29:03 +0000201#ifndef TRUE
202#define TRUE 1
203#endif
204#ifndef FALSE
205#define FALSE 0
206#endif
207
wdenke85390d2002-04-01 14:29:03 +0000208#endif /* _SCSI_H */