Home | History | Annotate | Line # | Download | only in scsipi
scsipi_base.h revision 1.10.6.2
      1  1.10.6.2  nathanw /*	$NetBSD: scsipi_base.h,v 1.10.6.2 2001/08/24 00:10:49 nathanw 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.10.6.1  nathanw struct scsipi_xfer *scsipi_get_xs __P((struct scsipi_periph *, int));
     40  1.10.6.1  nathanw void	scsipi_put_xs __P((struct scsipi_xfer *));
     41       1.2   bouyer 
     42  1.10.6.1  nathanw static __inline struct scsipi_xfer *scsipi_make_xs __P((struct scsipi_periph *,
     43       1.3      cgd 	    struct scsipi_generic *, int cmdlen, u_char *data_addr,
     44       1.3      cgd 	    int datalen, int retries, int timeout, struct buf *,
     45  1.10.6.1  nathanw 	    int flags)) __attribute__ ((__unused__));
     46       1.2   bouyer 
     47       1.2   bouyer /*
     48       1.2   bouyer  * Make a scsipi_xfer, and return a pointer to it.
     49       1.2   bouyer  */
     50       1.2   bouyer 
     51       1.2   bouyer static __inline struct scsipi_xfer *
     52  1.10.6.1  nathanw scsipi_make_xs(periph, scsipi_cmd, cmdlen, data_addr, datalen,
     53       1.3      cgd     retries, timeout, bp, flags)
     54  1.10.6.1  nathanw 	struct scsipi_periph *periph;
     55       1.2   bouyer 	struct scsipi_generic *scsipi_cmd;
     56       1.2   bouyer 	int cmdlen;
     57       1.2   bouyer 	u_char *data_addr;
     58       1.2   bouyer 	int datalen;
     59       1.2   bouyer 	int retries;
     60       1.2   bouyer 	int timeout;
     61       1.2   bouyer 	struct buf *bp;
     62       1.2   bouyer 	int flags;
     63       1.2   bouyer {
     64       1.2   bouyer 	struct scsipi_xfer *xs;
     65       1.2   bouyer 
     66  1.10.6.1  nathanw 	if ((xs = scsipi_get_xs(periph, flags)) == NULL)
     67       1.4    enami 		return (NULL);
     68       1.2   bouyer 
     69       1.2   bouyer 	/*
     70       1.2   bouyer 	 * Fill out the scsipi_xfer structure.  We don't know whose context
     71       1.2   bouyer 	 * the cmd is in, so copy it.
     72       1.2   bouyer 	 */
     73  1.10.6.2  nathanw 	memcpy(&xs->cmdstore, scsipi_cmd, cmdlen);
     74       1.2   bouyer 	xs->cmd = &xs->cmdstore;
     75       1.2   bouyer 	xs->cmdlen = cmdlen;
     76       1.2   bouyer 	xs->data = data_addr;
     77       1.2   bouyer 	xs->datalen = datalen;
     78  1.10.6.1  nathanw 	xs->xs_retries = retries;
     79       1.2   bouyer 	xs->timeout = timeout;
     80       1.2   bouyer 	xs->bp = bp;
     81       1.2   bouyer 
     82       1.4    enami 	return (xs);
     83       1.2   bouyer }
     84