scsiconf.h revision 1.31 1 1.31 cgd /* $NetBSD: scsiconf.h,v 1.31 1996/08/28 18:47:55 cgd Exp $ */
2 1.11 cgd
3 1.1 cgd /*
4 1.20 mycroft * Copyright (c) 1993, 1994, 1995 Charles Hannum. All rights reserved.
5 1.6 mycroft *
6 1.6 mycroft * Redistribution and use in source and binary forms, with or without
7 1.6 mycroft * modification, are permitted provided that the following conditions
8 1.6 mycroft * are met:
9 1.6 mycroft * 1. Redistributions of source code must retain the above copyright
10 1.6 mycroft * notice, this list of conditions and the following disclaimer.
11 1.6 mycroft * 2. Redistributions in binary form must reproduce the above copyright
12 1.6 mycroft * notice, this list of conditions and the following disclaimer in the
13 1.6 mycroft * documentation and/or other materials provided with the distribution.
14 1.6 mycroft * 3. All advertising materials mentioning features or use of this software
15 1.6 mycroft * must display the following acknowledgement:
16 1.6 mycroft * This product includes software developed by Charles Hannum.
17 1.6 mycroft * 4. The name of the author may not be used to endorse or promote products
18 1.6 mycroft * derived from this software without specific prior written permission.
19 1.6 mycroft *
20 1.6 mycroft * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.6 mycroft * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.6 mycroft * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.6 mycroft * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.6 mycroft * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.6 mycroft * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.6 mycroft * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.6 mycroft * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.6 mycroft * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.6 mycroft * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.6 mycroft */
31 1.6 mycroft
32 1.6 mycroft /*
33 1.6 mycroft * Originally written by Julian Elischer (julian (at) tfs.com)
34 1.3 deraadt * for TRW Financial Systems for use under the MACH(2.5) operating system.
35 1.1 cgd *
36 1.1 cgd * TRW Financial Systems, in accordance with their agreement with Carnegie
37 1.1 cgd * Mellon University, makes this software available to CMU to distribute
38 1.1 cgd * or use in any manner that they see fit as long as this message is kept with
39 1.1 cgd * the software. For this reason TFS also grants any other persons or
40 1.1 cgd * organisations permission to use or modify this software.
41 1.1 cgd *
42 1.1 cgd * TFS supplies this software to be publicly redistributed
43 1.1 cgd * on the understanding that TFS is not responsible for the correct
44 1.1 cgd * functioning of this software in any circumstances.
45 1.4 cgd *
46 1.6 mycroft * Ported to run under 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992
47 1.1 cgd */
48 1.1 cgd
49 1.6 mycroft #ifndef SCSI_SCSICONF_H
50 1.6 mycroft #define SCSI_SCSICONF_H 1
51 1.17 mycroft
52 1.6 mycroft typedef int boolean;
53 1.6 mycroft
54 1.9 mycroft #include <sys/queue.h>
55 1.6 mycroft #include <machine/cpu.h>
56 1.6 mycroft #include <scsi/scsi_debug.h>
57 1.6 mycroft
58 1.1 cgd /*
59 1.6 mycroft * The following documentation tries to describe the relationship between the
60 1.6 mycroft * various structures defined in this file:
61 1.6 mycroft *
62 1.6 mycroft * each adapter type has a scsi_adapter struct. This describes the adapter and
63 1.6 mycroft * identifies routines that can be called to use the adapter.
64 1.6 mycroft * each device type has a scsi_device struct. This describes the device and
65 1.6 mycroft * identifies routines that can be called to use the device.
66 1.6 mycroft * each existing device position (scsibus + target + lun)
67 1.6 mycroft * can be described by a scsi_link struct.
68 1.6 mycroft * Only scsi positions that actually have devices, have a scsi_link
69 1.6 mycroft * structure assigned. so in effect each device has scsi_link struct.
70 1.6 mycroft * The scsi_link structure contains information identifying both the
71 1.6 mycroft * device driver and the adapter driver for that position on that scsi bus,
72 1.6 mycroft * and can be said to 'link' the two.
73 1.6 mycroft * each individual scsi bus has an array that points to all the scsi_link
74 1.6 mycroft * structs associated with that scsi bus. Slots with no device have
75 1.6 mycroft * a NULL pointer.
76 1.6 mycroft * each individual device also knows the address of it's own scsi_link
77 1.6 mycroft * structure.
78 1.6 mycroft *
79 1.6 mycroft * -------------
80 1.6 mycroft *
81 1.25 mycroft * The key to all this is the scsi_link structure which associates all the
82 1.6 mycroft * other structures with each other in the correct configuration. The
83 1.25 mycroft * scsi_link is the connecting information that allows each part of the
84 1.6 mycroft * scsi system to find the associated other parts.
85 1.6 mycroft */
86 1.6 mycroft
87 1.27 christos struct buf;
88 1.27 christos struct scsi_xfer;
89 1.6 mycroft
90 1.6 mycroft /*
91 1.6 mycroft * These entrypoints are called by the high-end drivers to get services from
92 1.6 mycroft * whatever low-end drivers they are attached to each adapter type has one of
93 1.6 mycroft * these statically allocated.
94 1.6 mycroft */
95 1.8 mycroft struct scsi_adapter {
96 1.27 christos int (*scsi_cmd) __P((struct scsi_xfer *));
97 1.25 mycroft void (*scsi_minphys) __P((struct buf *));
98 1.27 christos int (*open_target_lu) __P((void));
99 1.27 christos int (*close_target_lu) __P((void));
100 1.1 cgd };
101 1.6 mycroft
102 1.6 mycroft /*
103 1.6 mycroft * return values for scsi_cmd()
104 1.6 mycroft */
105 1.1 cgd #define SUCCESSFULLY_QUEUED 0
106 1.1 cgd #define TRY_AGAIN_LATER 1
107 1.1 cgd #define COMPLETE 2
108 1.17 mycroft #define ESCAPE_NOT_SUPPORTED 3
109 1.6 mycroft
110 1.6 mycroft /*
111 1.6 mycroft * These entry points are called by the low-end drivers to get services from
112 1.6 mycroft * whatever high-end drivers they are attached to. Each device type has one
113 1.6 mycroft * of these statically allocated.
114 1.6 mycroft */
115 1.8 mycroft struct scsi_device {
116 1.27 christos int (*err_handler) __P((struct scsi_xfer *));
117 1.27 christos /* returns -1 to say err processing done */
118 1.27 christos void (*start) __P((void *));
119 1.27 christos
120 1.27 christos int (*async) __P((void));
121 1.26 thorpej /*
122 1.26 thorpej * When called with `0' as the second argument, we expect status
123 1.26 thorpej * back from the upper-level driver. When called with a `1',
124 1.26 thorpej * we're simply notifying the upper-level driver that the command
125 1.26 thorpej * is complete and expect no status back.
126 1.26 thorpej */
127 1.27 christos int (*done) __P((struct scsi_xfer *, int));
128 1.6 mycroft };
129 1.6 mycroft
130 1.6 mycroft /*
131 1.6 mycroft * This structure describes the connection between an adapter driver and
132 1.6 mycroft * a device driver, and is used by each to call services provided by
133 1.6 mycroft * the other, and to allow generic scsi glue code to call these services
134 1.6 mycroft * as well.
135 1.31 cgd *
136 1.31 cgd * XXX Given the way NetBSD's autoconfiguration works, this is ...
137 1.31 cgd * XXX nasty.
138 1.6 mycroft */
139 1.8 mycroft struct scsi_link {
140 1.31 cgd int channel; /* channel, i.e. bus # on controller */
141 1.31 cgd
142 1.23 cgd u_int8_t scsibus; /* the Nth scsibus */
143 1.23 cgd u_int8_t target; /* targ of this dev */
144 1.23 cgd u_int8_t lun; /* lun of this dev */
145 1.23 cgd u_int8_t adapter_target; /* what are we on the scsi bus */
146 1.23 cgd u_int8_t openings; /* available operations */
147 1.23 cgd u_int8_t active; /* operations in progress */
148 1.23 cgd u_int8_t flags; /* flags that all devices have */
149 1.17 mycroft #define SDEV_REMOVABLE 0x01 /* media is removable */
150 1.17 mycroft #define SDEV_MEDIA_LOADED 0x02 /* device figures are still valid */
151 1.17 mycroft #define SDEV_WAITING 0x04 /* a process is waiting for this */
152 1.17 mycroft #define SDEV_OPEN 0x08 /* at least 1 open session */
153 1.25 mycroft #define SDEV_DBX 0xf0 /* debuging flags (scsi_debug.h) */
154 1.23 cgd u_int8_t quirks; /* per-device oddities */
155 1.17 mycroft #define SDEV_AUTOSAVE 0x01 /* do implicit SAVEDATAPOINTER on disconnect */
156 1.17 mycroft #define SDEV_NOSYNCWIDE 0x02 /* does not grok SDTR or WDTR */
157 1.17 mycroft #define SDEV_NOLUNS 0x04 /* does not grok LUNs */
158 1.21 cgd #define SDEV_FORCELUNS 0x08 /* prehistoric drive/ctlr groks LUNs */
159 1.30 christos #define SDEV_NOMODESENSE 0x10 /* removable media/optical drives */
160 1.23 cgd struct scsi_device *device; /* device entry points etc. */
161 1.23 cgd void *device_softc; /* needed for call to foo_start */
162 1.23 cgd struct scsi_adapter *adapter; /* adapter entry points etc. */
163 1.23 cgd void *adapter_softc; /* needed for call to foo_scsi_cmd */
164 1.24 cgd };
165 1.31 cgd
166 1.31 cgd /*
167 1.31 cgd * Other definitions used by autoconfiguration.
168 1.31 cgd */
169 1.31 cgd #define scsicf_channel cf_loc[0]
170 1.31 cgd #define SCSI_CHANNEL_UNKNOWN -1
171 1.31 cgd
172 1.31 cgd #define SCSI_CHANNEL_ONLY_ONE -1 /* only one channel on controller */
173 1.31 cgd
174 1.31 cgd int scsiprint __P((void *, const char *));
175 1.17 mycroft
176 1.17 mycroft /*
177 1.17 mycroft * This describes matching information for scsi_inqmatch(). The more things
178 1.17 mycroft * match, the higher the configuration priority.
179 1.17 mycroft */
180 1.17 mycroft struct scsi_inquiry_pattern {
181 1.17 mycroft u_int8_t type;
182 1.17 mycroft boolean removable;
183 1.17 mycroft char *vendor;
184 1.17 mycroft char *product;
185 1.17 mycroft char *revision;
186 1.6 mycroft };
187 1.6 mycroft
188 1.6 mycroft /*
189 1.6 mycroft * One of these is allocated and filled in for each scsi bus.
190 1.6 mycroft * it holds pointers to allow the scsi bus to get to the driver
191 1.6 mycroft * That is running each LUN on the bus
192 1.6 mycroft * it also has a template entry which is the prototype struct
193 1.6 mycroft * supplied by the adapter driver, this is used to initialise
194 1.6 mycroft * the others, before they have the rest of the fields filled in
195 1.6 mycroft */
196 1.17 mycroft struct scsibus_softc {
197 1.6 mycroft struct device sc_dev;
198 1.6 mycroft struct scsi_link *adapter_link; /* prototype supplied by adapter */
199 1.6 mycroft struct scsi_link *sc_link[8][8];
200 1.17 mycroft u_int8_t moreluns;
201 1.17 mycroft };
202 1.17 mycroft
203 1.17 mycroft /*
204 1.17 mycroft * This is used to pass information from the high-level configuration code
205 1.17 mycroft * to the device-specific drivers.
206 1.17 mycroft */
207 1.17 mycroft struct scsibus_attach_args {
208 1.17 mycroft struct scsi_link *sa_sc_link;
209 1.17 mycroft struct scsi_inquiry_data *sa_inqbuf;
210 1.6 mycroft };
211 1.1 cgd
212 1.6 mycroft /*
213 1.6 mycroft * Each scsi transaction is fully described by one of these structures
214 1.6 mycroft * It includes information about the source of the command and also the
215 1.6 mycroft * device and adapter for which the command is destined.
216 1.6 mycroft * (via the scsi_link structure)
217 1.6 mycroft */
218 1.8 mycroft struct scsi_xfer {
219 1.23 cgd LIST_ENTRY(scsi_xfer) free_list;
220 1.23 cgd int flags;
221 1.23 cgd struct scsi_link *sc_link; /* all about our device and adapter */
222 1.23 cgd int retries; /* the number of times to retry */
223 1.23 cgd int timeout; /* in milliseconds */
224 1.23 cgd struct scsi_generic *cmd; /* The scsi command to execute */
225 1.23 cgd int cmdlen; /* how long it is */
226 1.23 cgd u_char *data; /* dma address OR a uio address */
227 1.23 cgd int datalen; /* data len (blank if uio) */
228 1.23 cgd int resid; /* how much buffer was not touched */
229 1.23 cgd int error; /* an error value */
230 1.23 cgd struct buf *bp; /* If we need to associate with a buf */
231 1.23 cgd struct scsi_sense_data sense; /* 32 bytes*/
232 1.6 mycroft /*
233 1.6 mycroft * Believe it or not, Some targets fall on the ground with
234 1.6 mycroft * anything but a certain sense length.
235 1.6 mycroft */
236 1.23 cgd int req_sense_length; /* Explicit request sense length */
237 1.23 cgd u_int8_t status; /* SCSI status */
238 1.23 cgd struct scsi_generic cmdstore; /* stash the command in here */
239 1.1 cgd };
240 1.6 mycroft
241 1.6 mycroft /*
242 1.6 mycroft * Per-request Flag values
243 1.6 mycroft */
244 1.17 mycroft #define SCSI_NOSLEEP 0x0001 /* don't sleep */
245 1.17 mycroft #define SCSI_POLL 0x0002 /* poll for completion */
246 1.17 mycroft #define SCSI_AUTOCONF 0x0003 /* shorthand for SCSI_POLL | SCSI_NOSLEEP */
247 1.17 mycroft #define SCSI_USER 0x0004 /* Is a user cmd, call scsi_user_done */
248 1.17 mycroft #define ITSDONE 0x0008 /* the transfer is as done as it gets */
249 1.17 mycroft #define INUSE 0x0010 /* The scsi_xfer block is in use */
250 1.17 mycroft #define SCSI_SILENT 0x0020 /* don't announce NOT READY or MEDIA CHANGE */
251 1.17 mycroft #define SCSI_IGNORE_NOT_READY 0x0040 /* ignore NOT READY */
252 1.17 mycroft #define SCSI_IGNORE_MEDIA_CHANGE 0x0080 /* ignore MEDIA CHANGE */
253 1.17 mycroft #define SCSI_IGNORE_ILLEGAL_REQUEST 0x0100 /* ignore ILLEGAL REQUEST */
254 1.17 mycroft #define SCSI_RESET 0x0200 /* Reset the device in question */
255 1.17 mycroft #define SCSI_DATA_UIO 0x0400 /* The data address refers to a UIO */
256 1.17 mycroft #define SCSI_DATA_IN 0x0800 /* expect data to come INTO memory */
257 1.17 mycroft #define SCSI_DATA_OUT 0x1000 /* expect data to flow OUT of memory */
258 1.17 mycroft #define SCSI_TARGET 0x2000 /* This defines a TARGET mode op. */
259 1.17 mycroft #define SCSI_ESCAPE 0x4000 /* Escape operation */
260 1.6 mycroft
261 1.6 mycroft /*
262 1.6 mycroft * Escape op codes. This provides an extensible setup for operations
263 1.6 mycroft * that are not scsi commands. They are intended for modal operations.
264 1.6 mycroft */
265 1.6 mycroft
266 1.6 mycroft #define SCSI_OP_TARGET 0x0001
267 1.6 mycroft #define SCSI_OP_RESET 0x0002
268 1.6 mycroft #define SCSI_OP_BDINFO 0x0003
269 1.6 mycroft
270 1.6 mycroft /*
271 1.6 mycroft * Error values an adapter driver may return
272 1.6 mycroft */
273 1.17 mycroft #define XS_NOERROR 0 /* there is no error, (sense is invalid) */
274 1.17 mycroft #define XS_SENSE 1 /* Check the returned sense for the error */
275 1.17 mycroft #define XS_DRIVER_STUFFUP 2 /* Driver failed to perform operation */
276 1.17 mycroft #define XS_SELTIMEOUT 3 /* The device timed out.. turned off? */
277 1.17 mycroft #define XS_TIMEOUT 4 /* The Timeout reported was caught by SW */
278 1.17 mycroft #define XS_BUSY 5 /* The device busy, try again later? */
279 1.17 mycroft
280 1.17 mycroft caddr_t scsi_inqmatch __P((struct scsi_inquiry_data *, caddr_t, int, int, int *));
281 1.17 mycroft
282 1.17 mycroft struct scsi_xfer *scsi_get_xs __P((struct scsi_link *, int));
283 1.17 mycroft void scsi_free_xs __P((struct scsi_xfer *, int));
284 1.17 mycroft int scsi_execute_xs __P((struct scsi_xfer *));
285 1.17 mycroft u_long scsi_size __P((struct scsi_link *, int));
286 1.8 mycroft int scsi_test_unit_ready __P((struct scsi_link *, int));
287 1.8 mycroft int scsi_change_def __P((struct scsi_link *, int));
288 1.8 mycroft int scsi_inquire __P((struct scsi_link *, struct scsi_inquiry_data *, int));
289 1.8 mycroft int scsi_prevent __P((struct scsi_link *, int, int));
290 1.8 mycroft int scsi_start __P((struct scsi_link *, int, int));
291 1.6 mycroft void scsi_done __P((struct scsi_xfer *));
292 1.27 christos void scsi_user_done __P((struct scsi_xfer *));
293 1.6 mycroft int scsi_scsi_cmd __P((struct scsi_link *, struct scsi_generic *,
294 1.17 mycroft int cmdlen, u_char *data_addr,
295 1.17 mycroft int datalen, int retries,
296 1.8 mycroft int timeout, struct buf *bp,
297 1.8 mycroft int flags));
298 1.17 mycroft int scsi_do_ioctl __P((struct scsi_link *, dev_t, u_long, caddr_t, int, struct proc *));
299 1.17 mycroft void sc_print_addr __P((struct scsi_link *));
300 1.6 mycroft
301 1.6 mycroft void show_scsi_xs __P((struct scsi_xfer *));
302 1.6 mycroft void show_scsi_cmd __P((struct scsi_xfer *));
303 1.18 mycroft void show_mem __P((u_char *, int));
304 1.27 christos int scsi_probe_busses __P((int, int, int));
305 1.28 mycroft void scsi_strvis __P((u_char *, u_char *, int));
306 1.27 christos
307 1.29 mycroft static __inline void _lto2b __P((u_int32_t val, u_int8_t *bytes));
308 1.29 mycroft static __inline void _lto3b __P((u_int32_t val, u_int8_t *bytes));
309 1.29 mycroft static __inline void _lto4b __P((u_int32_t val, u_int8_t *bytes));
310 1.29 mycroft static __inline u_int32_t _2btol __P((u_int8_t *bytes));
311 1.29 mycroft static __inline u_int32_t _3btol __P((u_int8_t *bytes));
312 1.29 mycroft static __inline u_int32_t _4btol __P((u_int8_t *bytes));
313 1.29 mycroft
314 1.29 mycroft static __inline void _lto2l __P((u_int32_t val, u_int8_t *bytes));
315 1.29 mycroft static __inline void _lto3l __P((u_int32_t val, u_int8_t *bytes));
316 1.29 mycroft static __inline void _lto4l __P((u_int32_t val, u_int8_t *bytes));
317 1.29 mycroft static __inline u_int32_t _2ltol __P((u_int8_t *bytes));
318 1.29 mycroft static __inline u_int32_t _3ltol __P((u_int8_t *bytes));
319 1.29 mycroft static __inline u_int32_t _4ltol __P((u_int8_t *bytes));
320 1.29 mycroft
321 1.29 mycroft static __inline void
322 1.29 mycroft _lto2b(val, bytes)
323 1.29 mycroft u_int32_t val;
324 1.29 mycroft u_int8_t *bytes;
325 1.29 mycroft {
326 1.29 mycroft
327 1.29 mycroft bytes[0] = (val >> 8) & 0xff;
328 1.29 mycroft bytes[1] = val & 0xff;
329 1.29 mycroft }
330 1.29 mycroft
331 1.29 mycroft static __inline void
332 1.29 mycroft _lto3b(val, bytes)
333 1.29 mycroft u_int32_t val;
334 1.29 mycroft u_int8_t *bytes;
335 1.29 mycroft {
336 1.29 mycroft
337 1.29 mycroft bytes[0] = (val >> 16) & 0xff;
338 1.29 mycroft bytes[1] = (val >> 8) & 0xff;
339 1.29 mycroft bytes[2] = val & 0xff;
340 1.29 mycroft }
341 1.29 mycroft
342 1.29 mycroft static __inline void
343 1.29 mycroft _lto4b(val, bytes)
344 1.29 mycroft u_int32_t val;
345 1.29 mycroft u_int8_t *bytes;
346 1.29 mycroft {
347 1.29 mycroft
348 1.29 mycroft bytes[0] = (val >> 24) & 0xff;
349 1.29 mycroft bytes[1] = (val >> 16) & 0xff;
350 1.29 mycroft bytes[2] = (val >> 8) & 0xff;
351 1.29 mycroft bytes[3] = val & 0xff;
352 1.29 mycroft }
353 1.29 mycroft
354 1.29 mycroft static __inline u_int32_t
355 1.29 mycroft _2btol(bytes)
356 1.29 mycroft u_int8_t *bytes;
357 1.29 mycroft {
358 1.29 mycroft register u_int32_t rv;
359 1.29 mycroft
360 1.29 mycroft rv = (bytes[0] << 8) |
361 1.29 mycroft bytes[1];
362 1.29 mycroft return (rv);
363 1.29 mycroft }
364 1.29 mycroft
365 1.29 mycroft static __inline u_int32_t
366 1.29 mycroft _3btol(bytes)
367 1.29 mycroft u_int8_t *bytes;
368 1.29 mycroft {
369 1.29 mycroft register u_int32_t rv;
370 1.29 mycroft
371 1.29 mycroft rv = (bytes[0] << 16) |
372 1.29 mycroft (bytes[1] << 8) |
373 1.29 mycroft bytes[2];
374 1.29 mycroft return (rv);
375 1.29 mycroft }
376 1.29 mycroft
377 1.29 mycroft static __inline u_int32_t
378 1.29 mycroft _4btol(bytes)
379 1.29 mycroft u_int8_t *bytes;
380 1.29 mycroft {
381 1.29 mycroft register u_int32_t rv;
382 1.29 mycroft
383 1.29 mycroft rv = (bytes[0] << 24) |
384 1.29 mycroft (bytes[1] << 16) |
385 1.29 mycroft (bytes[2] << 8) |
386 1.29 mycroft bytes[3];
387 1.29 mycroft return (rv);
388 1.29 mycroft }
389 1.29 mycroft
390 1.29 mycroft static __inline void
391 1.29 mycroft _lto2l(val, bytes)
392 1.29 mycroft u_int32_t val;
393 1.29 mycroft u_int8_t *bytes;
394 1.29 mycroft {
395 1.29 mycroft
396 1.29 mycroft bytes[0] = val & 0xff;
397 1.29 mycroft bytes[1] = (val >> 8) & 0xff;
398 1.29 mycroft }
399 1.29 mycroft
400 1.29 mycroft static __inline void
401 1.29 mycroft _lto3l(val, bytes)
402 1.29 mycroft u_int32_t val;
403 1.29 mycroft u_int8_t *bytes;
404 1.29 mycroft {
405 1.29 mycroft
406 1.29 mycroft bytes[0] = val & 0xff;
407 1.29 mycroft bytes[1] = (val >> 8) & 0xff;
408 1.29 mycroft bytes[2] = (val >> 16) & 0xff;
409 1.29 mycroft }
410 1.29 mycroft
411 1.29 mycroft static __inline void
412 1.29 mycroft _lto4l(val, bytes)
413 1.29 mycroft u_int32_t val;
414 1.29 mycroft u_int8_t *bytes;
415 1.29 mycroft {
416 1.29 mycroft
417 1.29 mycroft bytes[0] = val & 0xff;
418 1.29 mycroft bytes[1] = (val >> 8) & 0xff;
419 1.29 mycroft bytes[2] = (val >> 16) & 0xff;
420 1.29 mycroft bytes[3] = (val >> 24) & 0xff;
421 1.29 mycroft }
422 1.29 mycroft
423 1.29 mycroft static __inline u_int32_t
424 1.29 mycroft _2ltol(bytes)
425 1.29 mycroft u_int8_t *bytes;
426 1.29 mycroft {
427 1.29 mycroft register u_int32_t rv;
428 1.29 mycroft
429 1.29 mycroft rv = bytes[0] |
430 1.29 mycroft (bytes[1] << 8);
431 1.29 mycroft return (rv);
432 1.29 mycroft }
433 1.29 mycroft
434 1.29 mycroft static __inline u_int32_t
435 1.29 mycroft _3ltol(bytes)
436 1.29 mycroft u_int8_t *bytes;
437 1.29 mycroft {
438 1.29 mycroft register u_int32_t rv;
439 1.29 mycroft
440 1.29 mycroft rv = bytes[0] |
441 1.29 mycroft (bytes[1] << 8) |
442 1.29 mycroft (bytes[2] << 16);
443 1.29 mycroft return (rv);
444 1.29 mycroft }
445 1.29 mycroft
446 1.29 mycroft static __inline u_int32_t
447 1.29 mycroft _4ltol(bytes)
448 1.29 mycroft u_int8_t *bytes;
449 1.29 mycroft {
450 1.29 mycroft register u_int32_t rv;
451 1.29 mycroft
452 1.29 mycroft rv = bytes[0] |
453 1.29 mycroft (bytes[1] << 8) |
454 1.29 mycroft (bytes[2] << 16) |
455 1.29 mycroft (bytes[3] << 24);
456 1.29 mycroft return (rv);
457 1.29 mycroft }
458 1.2 deraadt
459 1.17 mycroft #endif /* SCSI_SCSICONF_H */
460