scsiconf.h 19 KB

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