Home | History | Annotate | Line # | Download | only in scsipi
scsipi_base.h revision 1.21.50.1
      1  1.21.50.1      yamt /*	$NetBSD: scsipi_base.h,v 1.21.50.1 2008/05/18 12:34:45 yamt 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  *
     19        1.8   mycroft  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20        1.8   mycroft  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21        1.8   mycroft  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22        1.8   mycroft  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23        1.8   mycroft  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24        1.8   mycroft  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25        1.8   mycroft  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26        1.8   mycroft  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27        1.8   mycroft  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28        1.8   mycroft  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29        1.8   mycroft  * POSSIBILITY OF SUCH DAMAGE.
     30        1.2    bouyer  */
     31        1.2    bouyer 
     32       1.13      matt #ifndef _DEV_SCSIPI_SCSIPI_BASE_H_
     33       1.13      matt #define _DEV_SCSIPI_SCSIPI_BASE_H_
     34       1.13      matt 
     35       1.14   thorpej struct scsipi_xfer *scsipi_get_xs(struct scsipi_periph *, int);
     36       1.14   thorpej void	scsipi_put_xs(struct scsipi_xfer *);
     37        1.2    bouyer 
     38       1.20     perry static __inline struct scsipi_xfer *scsipi_make_xs(struct scsipi_periph *,
     39       1.17   reinoud 	    struct scsipi_generic *, int cmdlen, u_char *data_addr,
     40        1.3       cgd 	    int datalen, int retries, int timeout, struct buf *,
     41       1.14   thorpej 	    int flags) __unused;
     42        1.2    bouyer 
     43        1.2    bouyer /*
     44        1.2    bouyer  * Make a scsipi_xfer, and return a pointer to it.
     45        1.2    bouyer  */
     46        1.2    bouyer 
     47       1.21  christos static __inline struct scsipi_xfer *
     48       1.15   mycroft scsipi_make_xs(struct scsipi_periph *periph, struct scsipi_generic *cmd,
     49       1.17   reinoud     int cmdlen, u_char *data_addr, int datalen, int retries, int timeout,
     50       1.14   thorpej     struct buf *bp, int flags)
     51        1.2    bouyer {
     52        1.2    bouyer 	struct scsipi_xfer *xs;
     53        1.2    bouyer 
     54       1.11    bouyer 	if ((xs = scsipi_get_xs(periph, flags)) == NULL)
     55        1.4     enami 		return (NULL);
     56        1.2    bouyer 
     57        1.2    bouyer 	/*
     58        1.2    bouyer 	 * Fill out the scsipi_xfer structure.  We don't know whose context
     59        1.2    bouyer 	 * the cmd is in, so copy it.
     60        1.2    bouyer 	 */
     61       1.15   mycroft 	memcpy(&xs->cmdstore, cmd, cmdlen);
     62        1.2    bouyer 	xs->cmd = &xs->cmdstore;
     63        1.2    bouyer 	xs->cmdlen = cmdlen;
     64        1.2    bouyer 	xs->data = data_addr;
     65        1.2    bouyer 	xs->datalen = datalen;
     66       1.11    bouyer 	xs->xs_retries = retries;
     67        1.2    bouyer 	xs->timeout = timeout;
     68        1.2    bouyer 	xs->bp = bp;
     69        1.2    bouyer 
     70        1.4     enami 	return (xs);
     71        1.2    bouyer }
     72       1.13      matt 
     73       1.13      matt #endif /* _DEV_SCSIPI_SCSIPI_BASE_H_ */
     74