Home | History | Annotate | Line # | Download | only in scsipi
scsipi_base.h revision 1.20.14.1
      1  1.20.14.1       ad /*	$NetBSD: scsipi_base.h,v 1.20.14.1 2006/11/18 21:34:49 ad Exp $	*/
      2        1.2   bouyer 
      3        1.8  mycroft /*-
      4       1.15  mycroft  * Copyright (c) 1998, 2004 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.13     matt #ifndef _DEV_SCSIPI_SCSIPI_BASE_H_
     40       1.13     matt #define _DEV_SCSIPI_SCSIPI_BASE_H_
     41       1.13     matt 
     42       1.14  thorpej struct scsipi_xfer *scsipi_get_xs(struct scsipi_periph *, int);
     43       1.14  thorpej void	scsipi_put_xs(struct scsipi_xfer *);
     44        1.2   bouyer 
     45       1.20    perry static __inline struct scsipi_xfer *scsipi_make_xs(struct scsipi_periph *,
     46       1.17  reinoud 	    struct scsipi_generic *, int cmdlen, u_char *data_addr,
     47        1.3      cgd 	    int datalen, int retries, int timeout, struct buf *,
     48       1.14  thorpej 	    int flags) __unused;
     49        1.2   bouyer 
     50        1.2   bouyer /*
     51        1.2   bouyer  * Make a scsipi_xfer, and return a pointer to it.
     52        1.2   bouyer  */
     53        1.2   bouyer 
     54  1.20.14.1       ad static __inline struct scsipi_xfer *
     55       1.15  mycroft scsipi_make_xs(struct scsipi_periph *periph, struct scsipi_generic *cmd,
     56       1.17  reinoud     int cmdlen, u_char *data_addr, int datalen, int retries, int timeout,
     57       1.14  thorpej     struct buf *bp, int flags)
     58        1.2   bouyer {
     59        1.2   bouyer 	struct scsipi_xfer *xs;
     60        1.2   bouyer 
     61       1.11   bouyer 	if ((xs = scsipi_get_xs(periph, flags)) == NULL)
     62        1.4    enami 		return (NULL);
     63        1.2   bouyer 
     64        1.2   bouyer 	/*
     65        1.2   bouyer 	 * Fill out the scsipi_xfer structure.  We don't know whose context
     66        1.2   bouyer 	 * the cmd is in, so copy it.
     67        1.2   bouyer 	 */
     68       1.15  mycroft 	memcpy(&xs->cmdstore, cmd, cmdlen);
     69        1.2   bouyer 	xs->cmd = &xs->cmdstore;
     70        1.2   bouyer 	xs->cmdlen = cmdlen;
     71        1.2   bouyer 	xs->data = data_addr;
     72        1.2   bouyer 	xs->datalen = datalen;
     73       1.11   bouyer 	xs->xs_retries = retries;
     74        1.2   bouyer 	xs->timeout = timeout;
     75        1.2   bouyer 	xs->bp = bp;
     76        1.2   bouyer 
     77        1.4    enami 	return (xs);
     78        1.2   bouyer }
     79       1.13     matt 
     80       1.13     matt #endif /* _DEV_SCSIPI_SCSIPI_BASE_H_ */
     81