xref: /openbsd/sys/scsi/scsiconf.h (revision 905646f0)
1 /*	$OpenBSD: scsiconf.h,v 1.200 2020/10/14 23:40:33 krw Exp $	*/
2 /*	$NetBSD: scsiconf.h,v 1.35 1997/04/02 02:29:38 mycroft Exp $	*/
3 
4 /*
5  * Copyright (c) 1993, 1994, 1995 Charles Hannum.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *	This product includes software developed by Charles Hannum.
18  * 4. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 /*
34  * Originally written by Julian Elischer (julian@tfs.com)
35  * for TRW Financial Systems for use under the MACH(2.5) operating system.
36  *
37  * TRW Financial Systems, in accordance with their agreement with Carnegie
38  * Mellon University, makes this software available to CMU to distribute
39  * or use in any manner that they see fit as long as this message is kept with
40  * the software. For this reason TFS also grants any other persons or
41  * organisations permission to use or modify this software.
42  *
43  * TFS supplies this software to be publicly redistributed
44  * on the understanding that TFS is not responsible for the correct
45  * functioning of this software in any circumstances.
46  *
47  * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
48  */
49 
50 #ifndef	_SCSI_SCSICONF_H
51 #define _SCSI_SCSICONF_H
52 
53 #include <sys/queue.h>
54 #include <sys/timeout.h>
55 #include <sys/mutex.h>
56 
57 static __inline void _lto2b(u_int32_t val, u_int8_t *bytes);
58 static __inline void _lto3b(u_int32_t val, u_int8_t *bytes);
59 static __inline void _lto4b(u_int32_t val, u_int8_t *bytes);
60 static __inline void _lto8b(u_int64_t val, u_int8_t *bytes);
61 static __inline u_int32_t _2btol(u_int8_t *bytes);
62 static __inline u_int32_t _3btol(u_int8_t *bytes);
63 static __inline u_int32_t _4btol(u_int8_t *bytes);
64 static __inline u_int64_t _5btol(u_int8_t *bytes);
65 static __inline u_int64_t _8btol(u_int8_t *bytes);
66 
67 static __inline void
68 _lto2b(u_int32_t val, u_int8_t *bytes)
69 {
70 
71 	bytes[0] = (val >> 8) & 0xff;
72 	bytes[1] = val & 0xff;
73 }
74 
75 static __inline void
76 _lto3b(u_int32_t val, u_int8_t *bytes)
77 {
78 
79 	bytes[0] = (val >> 16) & 0xff;
80 	bytes[1] = (val >> 8) & 0xff;
81 	bytes[2] = val & 0xff;
82 }
83 
84 static __inline void
85 _lto4b(u_int32_t val, u_int8_t *bytes)
86 {
87 
88 	bytes[0] = (val >> 24) & 0xff;
89 	bytes[1] = (val >> 16) & 0xff;
90 	bytes[2] = (val >> 8) & 0xff;
91 	bytes[3] = val & 0xff;
92 }
93 
94 static __inline void
95 _lto8b(u_int64_t val, u_int8_t *bytes)
96 {
97 
98 	bytes[0] = (val >> 56) & 0xff;
99 	bytes[1] = (val >> 48) & 0xff;
100 	bytes[2] = (val >> 40) & 0xff;
101 	bytes[3] = (val >> 32) & 0xff;
102 	bytes[4] = (val >> 24) & 0xff;
103 	bytes[5] = (val >> 16) & 0xff;
104 	bytes[6] = (val >> 8) & 0xff;
105 	bytes[7] = val & 0xff;
106 }
107 
108 static __inline u_int32_t
109 _2btol(u_int8_t *bytes)
110 {
111 	u_int32_t rv;
112 
113 	rv = (bytes[0] << 8) | bytes[1];
114 	return rv;
115 }
116 
117 static __inline u_int32_t
118 _3btol(u_int8_t *bytes)
119 {
120 	u_int32_t rv;
121 
122 	rv = (bytes[0] << 16) | (bytes[1] << 8) | bytes[2];
123 	return rv;
124 }
125 
126 static __inline u_int32_t
127 _4btol(u_int8_t *bytes)
128 {
129 	u_int32_t rv;
130 
131 	rv = (bytes[0] << 24) | (bytes[1] << 16) |
132 	    (bytes[2] << 8) | bytes[3];
133 	return rv;
134 }
135 
136 static __inline u_int64_t
137 _5btol(u_int8_t *bytes)
138 {
139 	u_int64_t rv;
140 
141 	rv = ((u_int64_t)bytes[0] << 32) |
142 	     ((u_int64_t)bytes[1] << 24) |
143 	     ((u_int64_t)bytes[2] << 16) |
144 	     ((u_int64_t)bytes[3] << 8) |
145 	     (u_int64_t)bytes[4];
146 	return rv;
147 }
148 
149 static __inline u_int64_t
150 _8btol(u_int8_t *bytes)
151 {
152 	u_int64_t rv;
153 
154 	rv = (((u_int64_t)bytes[0]) << 56) |
155 	    (((u_int64_t)bytes[1]) << 48) |
156 	    (((u_int64_t)bytes[2]) << 40) |
157 	    (((u_int64_t)bytes[3]) << 32) |
158 	    (((u_int64_t)bytes[4]) << 24) |
159 	    (((u_int64_t)bytes[5]) << 16) |
160 	    (((u_int64_t)bytes[6]) << 8) |
161 	    ((u_int64_t)bytes[7]);
162 	return rv;
163 }
164 
165 #ifdef _KERNEL
166 
167 #define DEVID_NONE	0
168 #define DEVID_NAA	1
169 #define DEVID_EUI	2
170 #define DEVID_T10	3
171 #define DEVID_SERIAL	4
172 #define DEVID_WWN	5
173 
174 struct devid {
175 	u_int8_t	d_type;
176 	u_int8_t	d_flags;
177 #define DEVID_F_PRINT		(1<<0)
178 	u_int8_t	d_refcount;
179 	u_int8_t	d_len;
180 
181 	/*
182 	 * the devid struct is basically a header, the actual id is allocated
183 	 * immediately after it.
184 	 */
185 };
186 
187 #define DEVID_CMP(_a, _b) (					\
188 	(_a) != NULL && (_b) != NULL &&				\
189 	((_a) == (_b) ||					\
190 	((_a)->d_type != DEVID_NONE &&				\
191 	 (_a)->d_type == (_b)->d_type &&			\
192 	 (_a)->d_len == (_b)->d_len &&				\
193 	 bcmp((_a) + 1, (_b) + 1, (_a)->d_len) == 0))		\
194 )
195 
196 struct devid *	devid_alloc(u_int8_t, u_int8_t, u_int8_t, u_int8_t *);
197 struct devid *	devid_copy(struct devid *);
198 void		devid_free(struct devid *);
199 
200 /*
201  * Each existing device (scsibus + target + lun)
202  *    - is described by a scsi_link struct.
203  * Each scsi_link struct
204  *    - identifies the device's softc and scsi_adapter.
205  * Each scsi_adapter struct
206  *    - contains pointers to the device's scsi functions.
207  * Each scsibus_softc has an SLIST
208  *    - holding pointers to the scsi_link structs of devices on that scsi bus.
209  * Each individual device
210  *    - knows the address of its scsi_link structure.
211  */
212 
213 struct scsi_xfer;
214 struct scsi_link;
215 struct scsibus_softc;
216 
217 /*
218  * Temporary hack
219  */
220 extern int scsi_autoconf;
221 
222 /*
223  * These entrypoints are called by the high-end drivers to get services from
224  * whatever low-end drivers they are attached to.  Each adapter type has one
225  * of these statically allocated.
226  */
227 struct scsi_adapter {
228 	void		(*scsi_cmd)(struct scsi_xfer *);
229 	void		(*dev_minphys)(struct buf *, struct scsi_link *);
230 	int		(*dev_probe)(struct scsi_link *);
231 	void		(*dev_free)(struct scsi_link *);
232 	int		(*ioctl)(struct scsi_link *, u_long, caddr_t, int);
233 };
234 
235 struct scsi_iopool;
236 
237 struct scsi_iohandler {
238 	TAILQ_ENTRY(scsi_iohandler) q_entry;
239 	u_int q_state;
240 
241 	struct scsi_iopool *pool;
242 	void (*handler)(void *, void *);
243 	void *cookie;
244 };
245 TAILQ_HEAD(scsi_runq, scsi_iohandler);
246 
247 struct scsi_iopool {
248 	/* access to the IOs */
249 	void	*iocookie;
250 	/*
251 	 * Get an IO. This must reserve all resources that are necessary
252 	 * to send the transfer to the device. The resources must stay
253 	 * reserved during the lifetime of the IO, as the IO may be re-used
254 	 * without being io_put(), first.
255 	 */
256 	void	*(*io_get)(void *);
257 	void	 (*io_put)(void *, void *);
258 
259 	/* the runqueue */
260 	struct scsi_runq queue;
261 	/* runqueue semaphore */
262 	u_int running;
263 	/* protection for the runqueue and its semaphore */
264 	struct mutex mtx;
265 };
266 
267 struct scsi_xshandler {
268 	struct scsi_iohandler ioh; /* must be first */
269 
270 	struct scsi_link *link;
271 	void (*handler)(struct scsi_xfer *);
272 };
273 
274 /*
275  * This structure describes the connection between an adapter driver and
276  * a device driver, and is used by each to call services provided by
277  * the other, and to allow generic scsi glue code to call these services
278  * as well.
279  */
280 struct scsi_link {
281 	SLIST_ENTRY(scsi_link)	bus_list;
282 
283 	u_int		state;
284 #define SDEV_S_DYING		(1<<1)
285 
286 	u_int16_t target;		/* targ of this dev */
287 	u_int16_t lun;			/* lun of this dev */
288 	u_int16_t openings;		/* available operations per lun */
289 	u_int64_t port_wwn;		/* world wide name of port */
290 	u_int64_t node_wwn;		/* world wide name of node */
291 	u_int16_t flags;		/* flags that all devices have */
292 #define	SDEV_REMOVABLE		0x0001	/* media is removable */
293 #define	SDEV_MEDIA_LOADED	0x0002	/* device figures are still valid */
294 #define	SDEV_READONLY		0x0004	/* device is read-only */
295 #define	SDEV_OPEN		0x0008	/* at least 1 open session */
296 #define	SDEV_DBX		0x00f0	/* debugging flags (scsi_debug.h) */
297 #define	SDEV_EJECTING		0x0100	/* eject on device close */
298 #define	SDEV_ATAPI		0x0200	/* device is ATAPI */
299 #define SDEV_UMASS		0x0400	/* device is UMASS SCSI */
300 #define SDEV_VIRTUAL		0x0800	/* device is virtualised on the hba */
301 #define SDEV_OWN_IOPL		0x1000	/* scsibus */
302 	u_int16_t quirks;		/* per-device oddities */
303 #define	SDEV_AUTOSAVE		0x0001	/* do implicit SAVEDATAPOINTER on disconnect */
304 #define	SDEV_NOSYNC		0x0002	/* does not grok SDTR */
305 #define	SDEV_NOWIDE		0x0004	/* does not grok WDTR */
306 #define	SDEV_NOTAGS		0x0008	/* lies about having tagged queueing */
307 #define	SDEV_NOSYNCCACHE	0x0010	/* no SYNCHRONIZE_CACHE */
308 #define	ADEV_NOSENSE		0x0020	/* No request sense - ATAPI */
309 #define	ADEV_LITTLETOC		0x0040	/* little-endian TOC - ATAPI */
310 #define	ADEV_NOCAPACITY		0x0080	/* no READ CD CAPACITY */
311 #define	ADEV_NODOORLOCK		0x0100	/* can't lock door */
312 	int	(*interpret_sense)(struct scsi_xfer *);
313 	void	*device_softc;		/* needed for call to foo_start */
314 	struct	scsibus_softc *bus;	/* link to the scsibus we're on */
315 	struct	scsi_inquiry_data inqdata; /* copy of INQUIRY data from probe */
316 	struct  devid *id;
317 
318 	struct	scsi_runq queue;
319 	u_int	running;
320 	u_short	pending;
321 
322 	struct	scsi_iopool *pool;
323 };
324 
325 int	scsiprint(void *, const char *);
326 
327 /*
328  * This describes matching information for scsi_inqmatch().  The more things
329  * match, the higher the configuration priority.
330  */
331 struct scsi_inquiry_pattern {
332 	u_int8_t type;
333 	int removable;
334 	char *vendor;
335 	char *product;
336 	char *revision;
337 };
338 
339 struct scsibus_attach_args {
340 	struct	scsi_adapter	*saa_adapter;
341 	void			*saa_adapter_softc;
342 	struct	scsi_iopool	*saa_pool;
343 	u_int64_t		 saa_wwpn;
344 	u_int64_t		 saa_wwnn;
345 	u_int16_t		 saa_quirks;
346 	u_int16_t		 saa_flags;
347 	u_int16_t		 saa_openings;
348 	u_int16_t		 saa_adapter_target;
349 #define	SDEV_NO_ADAPTER_TARGET	0xffff
350 	u_int16_t		 saa_adapter_buswidth;
351 	u_int8_t		 saa_luns;
352 };
353 
354 /*
355  * One of these is allocated and filled in for each scsi bus.
356  * It holds pointers to allow the scsi bus to get to the driver
357  * that is running each LUN on the bus.
358  * It also has a template entry which is the prototype struct
359  * supplied by the adapter driver.  This is used to initialise
360  * the others, before they have the rest of the fields filled in.
361  */
362 struct scsibus_softc {
363 	struct device		 sc_dev;
364 	SLIST_HEAD(, scsi_link)  sc_link_list;
365 	void			*sb_adapter_softc;
366 	struct	scsi_adapter	*sb_adapter;
367 	struct	scsi_iopool	*sb_pool;
368 	u_int16_t		 sb_quirks;
369 	u_int16_t		 sb_flags;
370 	u_int16_t		 sb_openings;
371 	u_int16_t		 sb_adapter_buswidth;
372 	u_int16_t		 sb_adapter_target;
373 	u_int8_t		 sb_luns;
374 };
375 
376 /*
377  * This is used to pass information from the high-level configuration code
378  * to the device-specific drivers.
379  */
380 struct scsi_attach_args {
381 	struct scsi_link *sa_sc_link;
382 };
383 
384 /*
385  * Each scsi transaction is fully described by one of these structures.
386  * It includes information about the source of the command and also the
387  * device and adapter for which the command is destined.
388  * (via the scsi_link structure)
389  */
390 struct scsi_xfer {
391 	SIMPLEQ_ENTRY(scsi_xfer) xfer_list;
392 	int	flags;
393 	struct	scsi_link *sc_link;	/* all about our device and adapter */
394 	int	retries;		/* the number of times to retry */
395 	int	timeout;		/* in milliseconds */
396 	struct	scsi_generic cmd;	/* The scsi command to execute */
397 	int	cmdlen;			/* how long it is */
398 	u_char	*data;			/* dma address OR a uio address */
399 	int	datalen;		/* data len (blank if uio)    */
400 	size_t	resid;			/* how much buffer was not touched */
401 	int	error;			/* an error value	*/
402 	struct	buf *bp;		/* If we need to associate with a buf */
403 	struct	scsi_sense_data	sense;	/* 18 bytes*/
404 	u_int8_t status;		/* SCSI status */
405 	/*
406 	 * timeout structure for hba's to use for a command
407 	 */
408 	struct timeout stimeout;
409 	void *cookie;
410 	void (*done)(struct scsi_xfer *);
411 
412 	void *io;			/* adapter io resource */
413 };
414 SIMPLEQ_HEAD(scsi_xfer_list, scsi_xfer);
415 
416 /*
417  * Per-request Flag values
418  */
419 #define	SCSI_NOSLEEP	0x00001	/* don't sleep */
420 #define	SCSI_POLL	0x00002	/* poll for completion */
421 #define	SCSI_AUTOCONF	0x00003	/* shorthand for SCSI_POLL | SCSI_NOSLEEP */
422 #define	ITSDONE		0x00008	/* the transfer is as done as it gets	*/
423 #define	SCSI_SILENT	0x00020	/* don't announce NOT READY or MEDIA CHANGE */
424 #define	SCSI_IGNORE_NOT_READY		0x00040	/* ignore NOT READY */
425 #define	SCSI_IGNORE_MEDIA_CHANGE	0x00080	/* ignore MEDIA CHANGE */
426 #define	SCSI_IGNORE_ILLEGAL_REQUEST	0x00100	/* ignore ILLEGAL REQUEST */
427 #define	SCSI_RESET	0x00200	/* Reset the device in question		*/
428 #define	SCSI_DATA_IN	0x00800	/* expect data to come INTO memory	*/
429 #define	SCSI_DATA_OUT	0x01000	/* expect data to flow OUT of memory	*/
430 #define	SCSI_TARGET	0x02000	/* This defines a TARGET mode op.	*/
431 #define	SCSI_ESCAPE	0x04000	/* Escape operation			*/
432 #define	SCSI_PRIVATE	0xf0000	/* private to each HBA flags */
433 
434 /*
435  * Escape op-codes.  This provides an extensible setup for operations
436  * that are not scsi commands.  They are intended for modal operations.
437  */
438 
439 #define SCSI_OP_TARGET	0x0001
440 #define	SCSI_OP_RESET	0x0002
441 #define	SCSI_OP_BDINFO	0x0003
442 
443 /*
444  * Error values an adapter driver may return
445  */
446 #define XS_NOERROR	0	/* there is no error, (sense is invalid)  */
447 #define XS_SENSE	1	/* Check the returned sense for the error */
448 #define	XS_DRIVER_STUFFUP 2	/* Driver failed to perform operation	  */
449 #define XS_SELTIMEOUT	3	/* The device timed out.. turned off?	  */
450 #define XS_TIMEOUT	4	/* The Timeout reported was caught by SW  */
451 #define XS_BUSY		5	/* The device busy, try again later?	  */
452 #define XS_SHORTSENSE   6	/* Check the ATAPI sense for the error */
453 #define XS_RESET	8	/* bus was reset; possible retry command  */
454 
455 /*
456  * Possible retries for scsi_test_unit_ready()
457  */
458 #define TEST_READY_RETRIES	5
459 
460 /*
461  * Possible retries for most SCSI commands.
462  */
463 #define SCSI_RETRIES		4
464 
465 const void *scsi_inqmatch(struct scsi_inquiry_data *, const void *, int,
466 	    int, int *);
467 
468 void	scsi_init(void);
469 int	scsi_test_unit_ready(struct scsi_link *, int, int);
470 int	scsi_inquire(struct scsi_link *, struct scsi_inquiry_data *, int);
471 int	scsi_read_cap_10(struct scsi_link *, struct scsi_read_cap_data *, int);
472 int	scsi_read_cap_16(struct scsi_link *, struct scsi_read_cap_data_16 *,
473 	    int);
474 int	scsi_inquire_vpd(struct scsi_link *, void *, u_int, u_int8_t, int);
475 void	scsi_init_inquiry(struct scsi_xfer *, u_int8_t, u_int8_t,
476 	    void *, size_t);
477 int	scsi_prevent(struct scsi_link *, int, int);
478 int	scsi_start(struct scsi_link *, int, int);
479 void	scsi_parse_blkdesc(struct scsi_link *, union scsi_mode_sense_buf *, int,
480 	    u_int32_t *, u_int64_t *, u_int32_t *);
481 int	scsi_do_mode_sense(struct scsi_link *, int,
482 	    union scsi_mode_sense_buf *, void **, int, int, int *);
483 void	scsi_parse_blkdesc(struct scsi_link *, union scsi_mode_sense_buf *, int,
484 	    u_int32_t *, u_int64_t *, u_int32_t *);
485 int	scsi_mode_select(struct scsi_link *, int, struct scsi_mode_header *,
486 	    int, int);
487 int	scsi_mode_select_big(struct scsi_link *, int,
488 	    struct scsi_mode_header_big *, int, int);
489 void	scsi_copy_internal_data(struct scsi_xfer *, void *, size_t);
490 void	scsi_done(struct scsi_xfer *);
491 int	scsi_do_ioctl(struct scsi_link *, u_long, caddr_t, int);
492 void	sc_print_addr(struct scsi_link *);
493 int	scsi_report_luns(struct scsi_link *, int,
494 	    struct scsi_report_luns_data *, u_int32_t, int, int);
495 int	scsi_interpret_sense(struct scsi_xfer *);
496 
497 void	scsi_print_sense(struct scsi_xfer *);
498 void	scsi_strvis(u_char *, u_char *, int);
499 int	scsi_delay(struct scsi_xfer *, int);
500 
501 int	scsi_probe(struct scsibus_softc *, int, int);
502 int	scsi_probe_bus(struct scsibus_softc *);
503 int	scsi_probe_target(struct scsibus_softc *, int);
504 int	scsi_probe_lun(struct scsibus_softc *, int, int);
505 
506 int	scsi_detach(struct scsibus_softc *, int, int, int);
507 int	scsi_detach_target(struct scsibus_softc *, int, int);
508 int	scsi_detach_lun(struct scsibus_softc *, int, int, int);
509 
510 int	scsi_req_probe(struct scsibus_softc *, int, int);
511 int	scsi_req_detach(struct scsibus_softc *, int, int, int);
512 
513 int	scsi_activate(struct scsibus_softc *, int, int, int);
514 
515 struct scsi_link *	scsi_get_link(struct scsibus_softc *, int, int);
516 
517 #define SID_ANSII_REV(x)	((x)->version & SID_ANSII)
518 #define SID_RESPONSE_FORMAT(x)	((x)->response_format & SID_RESPONSE_DATA_FMT)
519 
520 #define SCSI_REV_0	0x00	/* No conformance to any standard. */
521 #define SCSI_REV_1	0x01	/* (Obsolete) SCSI-1 in olden times. */
522 #define SCSI_REV_2	0x02	/* (Obsolete) SCSI-2 in olden times. */
523 #define SCSI_REV_SPC	0x03	/* ANSI INCITS 301-1997 (SPC).	*/
524 #define SCSI_REV_SPC2	0x04	/* ANSI INCITS 351-2001 (SPC-2)	*/
525 #define SCSI_REV_SPC3	0x05	/* ANSI INCITS 408-2005 (SPC-3)	*/
526 #define SCSI_REV_SPC4	0x06	/* ANSI INCITS 513-2015 (SPC-4)	*/
527 #define SCSI_REV_SPC5	0x07	/* T10/BSR INCITS 503   (SPC-5)	*/
528 
529 struct scsi_xfer *	scsi_xs_get(struct scsi_link *, int);
530 void			scsi_xs_exec(struct scsi_xfer *);
531 int			scsi_xs_sync(struct scsi_xfer *);
532 void			scsi_xs_put(struct scsi_xfer *);
533 
534 /*
535  * iopool stuff
536  */
537 void	scsi_iopool_init(struct scsi_iopool *, void *,
538 	    void *(*)(void *), void (*)(void *, void *));
539 void	scsi_iopool_run(struct scsi_iopool *);
540 void	scsi_iopool_destroy(struct scsi_iopool *);
541 void	scsi_link_shutdown(struct scsi_link *);
542 
543 void *	scsi_io_get(struct scsi_iopool *, int);
544 void	scsi_io_put(struct scsi_iopool *, void *);
545 
546 /*
547  * default io allocator.
548  */
549 #define SCSI_IOPOOL_POISON ((void *)0x5c5)
550 void *	scsi_default_get(void *);
551 void	scsi_default_put(void *, void *);
552 
553 /*
554  * io handler interface
555  */
556 void	scsi_ioh_set(struct scsi_iohandler *, struct scsi_iopool *,
557 	    void (*)(void *, void *), void *);
558 int	scsi_ioh_add(struct scsi_iohandler *);
559 int	scsi_ioh_del(struct scsi_iohandler *);
560 
561 void	scsi_xsh_set(struct scsi_xshandler *, struct scsi_link *,
562 	    void (*)(struct scsi_xfer *));
563 int	scsi_xsh_add(struct scsi_xshandler *);
564 int	scsi_xsh_del(struct scsi_xshandler *);
565 
566 /*
567  * utility functions
568  */
569 int	scsi_pending_start(struct mutex *, u_int *);
570 int	scsi_pending_finish(struct mutex *, u_int *);
571 
572 /*
573  * Utility functions for SCSI HBA emulation.
574  */
575 void	scsi_cmd_rw_decode(struct scsi_generic *, u_int64_t *, u_int32_t *);
576 
577 #endif /* _KERNEL */
578 #endif /* _SCSI_SCSICONF_H */
579