2 * This file has been modified for the cdrkit suite.
4 * The behaviour and appearence of the program code below can differ to a major
5 * extent from the version distributed by the original author(s).
7 * For details, see Changelog file distributed with the cdrkit package. If you
8 * received this file from another source then ask the distributing person for
9 * a log of modifications.
13 /* @(#)scsitransp.h 1.54 03/05/03 Copyright 1995 J. Schilling */
15 * Definitions for commands that use functions from scsitransp.c
17 * Copyright (c) 1995 J. Schilling
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License version 2
22 * as published by the Free Software Foundation.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License along with
30 * this program; see the file COPYING. If not, write to the Free Software
31 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #ifndef _SCG_SCSITRANSP_H
35 #define _SCG_SCSITRANSP_H
41 typedef struct usal_scsi SCSI;
44 int scsibus; /* SCSI bus # for next I/O */
45 int target; /* SCSI target # for next I/O */
46 int lun; /* SCSI lun # for next I/O */
50 #include <usal/usalops.h>
53 typedef int (*usal_cb_t)(void *);
56 usal_ops_t *ops; /* Ptr to low level SCSI transport ops */
57 int fd; /* File descriptor for next I/O */
58 usal_addr_t addr; /* SCSI address for next I/O */
59 int flags; /* Libusal flags (see below) */
60 int dflags; /* Drive specific flags (see below) */
61 int kdebug; /* Kernel debug value for next I/O */
62 int debug; /* Debug value for SCSI library */
63 int silent; /* Be silent if value > 0 */
64 int verbose; /* Be verbose if value > 0 */
65 int overbose; /* Be verbose in open() if value > 0 */
68 int noparity; /* Do not use SCSI parity fo next I/O */
69 int dev; /* from scsi_cdr.c */
70 struct usal_cmd *scmd;
74 int error; /* libusal error number */
76 long maxdma; /* Max DMA limit for this open instance */
77 long maxbuf; /* Cur DMA buffer limit for this inst. */
78 /* This is the size behind bufptr */
79 struct timeval *cmdstart;
80 struct timeval *cmdstop;
81 const char **nonstderrs;
82 void *local; /* Local data from the low level code */
83 void *bufbase; /* needed for scsi_freebuf() */
84 void *bufptr; /* DMA buffer pointer for appl. use */
85 char *errstr; /* Error string for scsi_open/sendmcd */
86 char *errbeg; /* Pointer to begin of not flushed data */
87 char *errptr; /* Actual write pointer into errstr */
88 void *errfile; /* FILE to write errors to. NULL for not*/
89 /* writing and leaving errs in errstr */
93 struct scsi_inquiry *inq;
94 struct scsi_capacity *cap;
98 * Macros for accessing members of the usal address structure.
99 * usal_settarget() is the only function that is allowed to modify
100 * the values of the SCSI address.
102 #define usal_scsibus(usalp) (usalp)->addr.scsibus
103 #define usal_target(usalp) (usalp)->addr.target
104 #define usal_lun(usalp) (usalp)->addr.lun
107 * Flags for struct SCSI:
112 * Drive specific flags for struct SCSI:
114 #define DRF_MODE_DMA_OVR 0x0001 /* Drive gives DMA overrun */
117 #define SCSI_ERRSTR_SIZE 4096
120 * Libusal error codes:
122 #define SCG_ERRBASE 1000000
123 #define SCG_NOMEM 1000001
126 * Function codes for usal_version():
128 #define SCG_VERSION 0 /* libusal or transport version */
129 #define SCG_AUTHOR 1 /* Author of above */
130 #define SCG_SCCS_ID 2 /* SCCS id of above */
131 #define SCG_RVERSION 10 /* Remote transport version */
132 #define SCG_RAUTHOR 11 /* Remote transport author */
133 #define SCG_RSCCS_ID 12 /* Remote transport SCCS ID */
134 #define SCG_KVERSION 20 /* Kernel transport version */
137 * Function codes for usal_reset():
139 #define SCG_RESET_NOP 0 /* Test if reset is supported */
140 #define SCG_RESET_TGT 1 /* Reset Target only */
141 #define SCG_RESET_BUS 2 /* Reset complete SCSI Bus */
144 * Helpers for the error buffer in SCSI*
146 #define usal_errsize(usalp) ((usalp)->errptr - (usalp)->errstr)
147 #define usal_errrsize(usalp) (SCSI_ERRSTR_SIZE - usal_errsize(usalp))
152 extern char *usal_version(SCSI *usalp, int what);
153 extern int usal__open(SCSI *usalp, char *device);
154 extern int usal__close(SCSI *usalp);
155 extern BOOL usal_havebus(SCSI *usalp, int);
156 extern int usal_initiator_id(SCSI *usalp);
157 extern int usal_isatapi(SCSI *usalp);
158 extern int usal_reset(SCSI *usalp, int what);
159 extern void *usal_getbuf(SCSI *usalp, long);
160 extern void usal_freebuf(SCSI *usalp);
161 extern long usal_bufsize(SCSI *usalp, long);
162 extern void usal_setnonstderrs(SCSI *usalp, const char **);
163 extern BOOL usal_yes(char *);
164 extern int usal_cmd(SCSI *usalp);
165 extern void usal_vhead(SCSI *usalp);
166 extern int usal_svhead(SCSI *usalp, char *buf, int maxcnt);
167 extern int usal_vtail(SCSI *usalp);
168 extern int usal_svtail(SCSI *usalp, int *retp, char *buf, int maxcnt);
169 extern void usal_vsetup(SCSI *usalp);
170 extern int usal_getresid(SCSI *usalp);
171 extern int usal_getdmacnt(SCSI *usalp);
172 extern BOOL usal_cmd_err(SCSI *usalp);
173 extern void usal_printerr(SCSI *usalp);
174 #ifdef EOF /* stdio.h has been included */
175 extern void usal_fprinterr(SCSI *usalp, FILE *f);
177 extern int usal_sprinterr(SCSI *usalp, char *buf, int maxcnt);
178 extern int usal__sprinterr(SCSI *usalp, char *buf, int maxcnt);
179 extern void usal_printcdb(SCSI *usalp);
180 extern int usal_sprintcdb(SCSI *usalp, char *buf, int maxcnt);
181 extern void usal_printwdata(SCSI *usalp);
182 extern int usal_sprintwdata(SCSI *usalp, char *buf, int maxcnt);
183 extern void usal_printrdata(SCSI *usalp);
184 extern int usal_sprintrdata(SCSI *usalp, char *buf, int maxcnt);
185 extern void usal_printresult(SCSI *usalp);
186 extern int usal_sprintresult(SCSI *usalp, char *buf, int maxcnt);
187 extern void usal_printstatus(SCSI *usalp);
188 extern int usal_sprintstatus(SCSI *usalp, char *buf, int maxcnt);
189 #ifdef EOF /* stdio.h has been included */
190 extern void usal_fprbytes(FILE *, char *, unsigned char *, int);
191 extern void usal_fprascii(FILE *, char *, unsigned char *, int);
193 extern void usal_prbytes(char *, unsigned char *, int);
194 extern void usal_prascii(char *, unsigned char *, int);
195 extern int usal_sprbytes(char *buf, int maxcnt, char *, unsigned char *, int);
196 extern int usal_sprascii(char *buf, int maxcnt, char *, unsigned char *, int);
197 #ifdef EOF /* stdio.h has been included */
198 extern void usal_fprsense(FILE *f, unsigned char *, int);
200 extern void usal_prsense(unsigned char *, int);
201 extern int usal_sprsense(char *buf, int maxcnt, unsigned char *, int);
202 extern int usal_cmd_status(SCSI *usalp);
203 extern int usal_sense_key(SCSI *usalp);
204 extern int usal_sense_code(SCSI *usalp);
205 extern int usal_sense_qual(SCSI *usalp);
206 #ifdef _SCG_SCSIREG_H
207 #ifdef EOF /* stdio.h has been included */
208 extern void usal_fprintdev(FILE *, struct scsi_inquiry *);
210 extern void usal_printdev(struct scsi_inquiry *);
212 extern int usal_printf(SCSI *usalp, const char *form, ...);
213 extern int usal_errflush(SCSI *usalp);
214 #ifdef EOF /* stdio.h has been included */
215 extern int usal_errfflush(SCSI *usalp, FILE *f);
221 extern const char *usal_sensemsg(int, int, int, const char **, char *,
223 #ifdef _SCG_SCSISENSE_H
224 extern int usal__errmsg(SCSI *usalp, char *obuf, int maxcnt,
225 struct scsi_sense *, struct scsi_status *, int);
231 #ifdef EOF /* stdio.h has been included */
232 extern int usal_help(FILE *f);
234 extern SCSI *usal_open(char *scsidev, char *errs, int slen, int odebug,
236 extern int usal_close(SCSI * usalp);
237 extern void usal_settimeout(SCSI * usalp, int timeout);
238 extern SCSI *usal_smalloc(void);
239 extern void usal_sfree(SCSI *usalp);
242 * From usalsettarget.c:
244 extern int usal_settarget(SCSI *usalp, int scsibus, int target, int lun);
247 * From scsi-remote.c:
249 extern usal_ops_t *usal_remote(void);
254 #ifdef EOF /* stdio.h has been included */
255 extern void __usal_help(FILE *f, char *name, char *tcomment, char *tind,
256 char *tspec, char *texample, BOOL mayscan,
264 #endif /* _SCG_SCSITRANSP_H */