scsipi_base.h revision 1.8 1 1.8 mycroft /* $NetBSD: scsipi_base.h,v 1.8 1998/08/15 10:10:58 mycroft Exp $ */
2 1.2 bouyer
3 1.8 mycroft /*-
4 1.8 mycroft * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 1.8 mycroft * All rights reserved.
6 1.8 mycroft *
7 1.8 mycroft * This code is derived from software contributed to The NetBSD Foundation
8 1.8 mycroft * by Charles M. Hannum.
9 1.2 bouyer *
10 1.2 bouyer * Redistribution and use in source and binary forms, with or without
11 1.2 bouyer * modification, are permitted provided that the following conditions
12 1.2 bouyer * are met:
13 1.2 bouyer * 1. Redistributions of source code must retain the above copyright
14 1.2 bouyer * notice, this list of conditions and the following disclaimer.
15 1.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
16 1.2 bouyer * notice, this list of conditions and the following disclaimer in the
17 1.2 bouyer * documentation and/or other materials provided with the distribution.
18 1.2 bouyer * 3. All advertising materials mentioning features or use of this software
19 1.2 bouyer * must display the following acknowledgement:
20 1.8 mycroft * This product includes software developed by the NetBSD
21 1.8 mycroft * Foundation, Inc. and its contributors.
22 1.8 mycroft * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.8 mycroft * contributors may be used to endorse or promote products derived
24 1.8 mycroft * from this software without specific prior written permission.
25 1.2 bouyer *
26 1.8 mycroft * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.8 mycroft * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.8 mycroft * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.8 mycroft * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.8 mycroft * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.8 mycroft * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.8 mycroft * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.8 mycroft * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.8 mycroft * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.8 mycroft * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.8 mycroft * POSSIBILITY OF SUCH DAMAGE.
37 1.2 bouyer */
38 1.2 bouyer
39 1.2 bouyer extern LIST_HEAD(xs_free_list, scsipi_xfer) xs_free_list;
40 1.2 bouyer
41 1.2 bouyer struct scsipi_xfer *scsipi_get_xs __P((struct scsipi_link *, int));
42 1.2 bouyer void scsipi_free_xs __P((struct scsipi_xfer *, int));
43 1.2 bouyer
44 1.2 bouyer static __inline struct scsipi_xfer *scsipi_make_xs __P((struct scsipi_link *,
45 1.3 cgd struct scsipi_generic *, int cmdlen, u_char *data_addr,
46 1.3 cgd int datalen, int retries, int timeout, struct buf *,
47 1.3 cgd int flags)) __attribute__ ((unused));
48 1.2 bouyer
49 1.2 bouyer /*
50 1.2 bouyer * Make a scsipi_xfer, and return a pointer to it.
51 1.2 bouyer */
52 1.2 bouyer
53 1.2 bouyer static __inline struct scsipi_xfer *
54 1.2 bouyer scsipi_make_xs(sc_link, scsipi_cmd, cmdlen, data_addr, datalen,
55 1.3 cgd retries, timeout, bp, flags)
56 1.2 bouyer struct scsipi_link *sc_link;
57 1.2 bouyer struct scsipi_generic *scsipi_cmd;
58 1.2 bouyer int cmdlen;
59 1.2 bouyer u_char *data_addr;
60 1.2 bouyer int datalen;
61 1.2 bouyer int retries;
62 1.2 bouyer int timeout;
63 1.2 bouyer struct buf *bp;
64 1.2 bouyer int flags;
65 1.2 bouyer {
66 1.2 bouyer struct scsipi_xfer *xs;
67 1.2 bouyer
68 1.2 bouyer if ((xs = scsipi_get_xs(sc_link, flags)) == NULL)
69 1.4 enami return (NULL);
70 1.2 bouyer
71 1.2 bouyer /*
72 1.2 bouyer * Fill out the scsipi_xfer structure. We don't know whose context
73 1.2 bouyer * the cmd is in, so copy it.
74 1.2 bouyer */
75 1.2 bouyer xs->sc_link = sc_link;
76 1.2 bouyer bcopy(scsipi_cmd, &xs->cmdstore, cmdlen);
77 1.2 bouyer xs->cmd = &xs->cmdstore;
78 1.2 bouyer xs->cmdlen = cmdlen;
79 1.2 bouyer xs->data = data_addr;
80 1.2 bouyer xs->datalen = datalen;
81 1.2 bouyer xs->retries = retries;
82 1.2 bouyer xs->timeout = timeout;
83 1.2 bouyer xs->bp = bp;
84 1.2 bouyer
85 1.4 enami return (xs);
86 1.2 bouyer }
87