1
/* @(#)scsitransp.h 1.54 03/05/03 Copyright 1995 J. Schilling */
3
* Definitions for commands that use functions from scsitransp.c
5
* Copyright (c) 1995 J. Schilling
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2, or (at your option)
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.
18
* You should have received a copy of the GNU General Public License along with
19
* this program; see the file COPYING. If not, write to the Free Software
20
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
#ifndef _SCG_SCSITRANSP_H
24
#define _SCG_SCSITRANSP_H
30
typedef struct scg_scsi SCSI;
33
int scsibus; /* SCSI bus # for next I/O */
34
int target; /* SCSI target # for next I/O */
35
int lun; /* SCSI lun # for next I/O */
39
#include <scg/scgops.h>
42
typedef int (*scg_cb_t) __PR((void *));
45
scg_ops_t *ops; /* Ptr to low level SCSI transport ops */
46
int fd; /* File descriptor for next I/O */
47
scg_addr_t addr; /* SCSI address for next I/O */
48
int flags; /* Libscg flags (see below) */
49
int dflags; /* Drive specific flags (see below) */
50
int kdebug; /* Kernel debug value for next I/O */
51
int debug; /* Debug value for SCSI library */
52
int silent; /* Be silent if value > 0 */
53
int verbose; /* Be verbose if value > 0 */
54
int overbose; /* Be verbose in open() if value > 0 */
57
int noparity; /* Do not use SCSI parity fo next I/O */
58
int dev; /* from scsi_cdr.c */
63
int error; /* libscg error number */
65
long maxdma; /* Max DMA limit for this open instance */
66
long maxbuf; /* Cur DMA buffer limit for this inst. */
67
/* This is the size behind bufptr */
68
struct timeval *cmdstart;
69
struct timeval *cmdstop;
70
const char **nonstderrs;
71
void *local; /* Local data from the low level code */
72
void *bufbase; /* needed for scsi_freebuf() */
73
void *bufptr; /* DMA buffer pointer for appl. use */
74
char *errstr; /* Error string for scsi_open/sendmcd */
75
char *errbeg; /* Pointer to begin of not flushed data */
76
char *errptr; /* Actual write pointer into errstr */
77
void *errfile; /* FILE to write errors to. NULL for not*/
78
/* writing and leaving errs in errstr */
82
struct scsi_inquiry *inq;
83
struct scsi_capacity *cap;
87
* Macros for accessing members of the scg address structure.
88
* scg_settarget() is the only function that is allowed to modify
89
* the values of the SCSI address.
91
#define scg_scsibus(scgp) (scgp)->addr.scsibus
92
#define scg_target(scgp) (scgp)->addr.target
93
#define scg_lun(scgp) (scgp)->addr.lun
96
* Flags for struct SCSI:
101
* Drive specific flags for struct SCSI:
103
#define DRF_MODE_DMA_OVR 0x0001 /* Drive gives DMA overrun */
106
#define SCSI_ERRSTR_SIZE 4096
109
* Libscg error codes:
111
#define SCG_ERRBASE 1000000
112
#define SCG_NOMEM 1000001
115
* Function codes for scg_version():
117
#define SCG_VERSION 0 /* libscg or transport version */
118
#define SCG_AUTHOR 1 /* Author of above */
119
#define SCG_SCCS_ID 2 /* SCCS id of above */
120
#define SCG_RVERSION 10 /* Remote transport version */
121
#define SCG_RAUTHOR 11 /* Remote transport author */
122
#define SCG_RSCCS_ID 12 /* Remote transport SCCS ID */
123
#define SCG_KVERSION 20 /* Kernel transport version */
126
* Function codes for scg_reset():
128
#define SCG_RESET_NOP 0 /* Test if reset is supported */
129
#define SCG_RESET_TGT 1 /* Reset Target only */
130
#define SCG_RESET_BUS 2 /* Reset complete SCSI Bus */
133
* Helpers for the error buffer in SCSI*
135
#define scg_errsize(scgp) ((scgp)->errptr - (scgp)->errstr)
136
#define scg_errrsize(scgp) (SCSI_ERRSTR_SIZE - scg_errsize(scgp))
141
extern char *scg_version __PR((SCSI *scgp, int what));
142
extern int scg__open __PR((SCSI *scgp, char *device));
143
extern int scg__close __PR((SCSI *scgp));
144
extern BOOL scg_havebus __PR((SCSI *scgp, int));
145
extern int scg_initiator_id __PR((SCSI *scgp));
146
extern int scg_isatapi __PR((SCSI *scgp));
147
extern int scg_reset __PR((SCSI *scgp, int what));
148
extern void *scg_getbuf __PR((SCSI *scgp, long));
149
extern void scg_freebuf __PR((SCSI *scgp));
150
extern long scg_bufsize __PR((SCSI *scgp, long));
151
extern void scg_setnonstderrs __PR((SCSI *scgp, const char **));
152
extern BOOL scg_yes __PR((char *));
153
extern int scg_cmd __PR((SCSI *scgp));
154
extern void scg_vhead __PR((SCSI *scgp));
155
extern int scg_svhead __PR((SCSI *scgp, char *buf, int maxcnt));
156
extern int scg_vtail __PR((SCSI *scgp));
157
extern int scg_svtail __PR((SCSI *scgp, int *retp, char *buf, int maxcnt));
158
extern void scg_vsetup __PR((SCSI *scgp));
159
extern int scg_getresid __PR((SCSI *scgp));
160
extern int scg_getdmacnt __PR((SCSI *scgp));
161
extern BOOL scg_cmd_err __PR((SCSI *scgp));
162
extern void scg_printerr __PR((SCSI *scgp));
163
#ifdef EOF /* stdio.h has been included */
164
extern void scg_fprinterr __PR((SCSI *scgp, FILE *f));
166
extern int scg_sprinterr __PR((SCSI *scgp, char *buf, int maxcnt));
167
extern int scg__sprinterr __PR((SCSI *scgp, char *buf, int maxcnt));
168
extern void scg_printcdb __PR((SCSI *scgp));
169
extern int scg_sprintcdb __PR((SCSI *scgp, char *buf, int maxcnt));
170
extern void scg_printwdata __PR((SCSI *scgp));
171
extern int scg_sprintwdata __PR((SCSI *scgp, char *buf, int maxcnt));
172
extern void scg_printrdata __PR((SCSI *scgp));
173
extern int scg_sprintrdata __PR((SCSI *scgp, char *buf, int maxcnt));
174
extern void scg_printresult __PR((SCSI *scgp));
175
extern int scg_sprintresult __PR((SCSI *scgp, char *buf, int maxcnt));
176
extern void scg_printstatus __PR((SCSI *scgp));
177
extern int scg_sprintstatus __PR((SCSI *scgp, char *buf, int maxcnt));
178
#ifdef EOF /* stdio.h has been included */
179
extern void scg_fprbytes __PR((FILE *, char *, unsigned char *, int));
180
extern void scg_fprascii __PR((FILE *, char *, unsigned char *, int));
182
extern void scg_prbytes __PR((char *, unsigned char *, int));
183
extern void scg_prascii __PR((char *, unsigned char *, int));
184
extern int scg_sprbytes __PR((char *buf, int maxcnt, char *, unsigned char *, int));
185
extern int scg_sprascii __PR((char *buf, int maxcnt, char *, unsigned char *, int));
186
#ifdef EOF /* stdio.h has been included */
187
extern void scg_fprsense __PR((FILE *f, unsigned char *, int));
189
extern void scg_prsense __PR((unsigned char *, int));
190
extern int scg_sprsense __PR((char *buf, int maxcnt, unsigned char *, int));
191
extern int scg_cmd_status __PR((SCSI *scgp));
192
extern int scg_sense_key __PR((SCSI *scgp));
193
extern int scg_sense_code __PR((SCSI *scgp));
194
extern int scg_sense_qual __PR((SCSI *scgp));
195
#ifdef _SCG_SCSIREG_H
196
#ifdef EOF /* stdio.h has been included */
197
extern void scg_fprintdev __PR((FILE *, struct scsi_inquiry *));
199
extern void scg_printdev __PR((struct scsi_inquiry *));
201
extern int scg_printf __PR((SCSI *scgp, const char *form, ...));
202
extern int scg_errflush __PR((SCSI *scgp));
203
#ifdef EOF /* stdio.h has been included */
204
extern int scg_errfflush __PR((SCSI *scgp, FILE *f));
210
extern const char *scg_sensemsg __PR((int, int, int,
211
const char **, char *, int maxcnt));
212
#ifdef _SCG_SCSISENSE_H
213
extern int scg__errmsg __PR((SCSI *scgp, char *obuf, int maxcnt,
215
struct scsi_status *,
222
#ifdef EOF /* stdio.h has been included */
223
extern int scg_help __PR((FILE *f));
225
extern SCSI *scg_open __PR((char *scsidev, char *errs, int slen, int odebug, int be_verbose));
226
extern int scg_close __PR((SCSI * scgp));
227
extern void scg_settimeout __PR((SCSI * scgp, int timeout));
228
extern SCSI *scg_smalloc __PR((void));
229
extern void scg_sfree __PR((SCSI *scgp));
232
* From scgsettarget.c:
234
extern int scg_settarget __PR((SCSI *scgp, int scsibus, int target, int lun));
237
* From scsi-remote.c:
239
extern scg_ops_t *scg_remote __PR((void));
244
#ifdef EOF /* stdio.h has been included */
245
extern void __scg_help __PR((FILE *f, char *name, char *tcomment,
257
#endif /* _SCG_SCSITRANSP_H */