1 /* $FreeBSD: src/sys/opencrypto/criov.c,v 1.1.2.1 2002/11/21 23:34:23 sam Exp $ */
2 /* $DragonFly: src/sys/opencrypto/criov.c,v 1.2 2003/06/17 04:28:54 dillon Exp $ */
3 /* $OpenBSD: criov.c,v 1.9 2002/01/29 15:48:29 jason Exp $ */
6 * Copyright (c) 1999 Theo de Raadt
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/param.h>
33 #include <sys/systm.h>
35 #include <sys/errno.h>
36 #include <sys/malloc.h>
37 #include <sys/kernel.h>
40 #include <opencrypto/cryptodev.h>
43 cuio_copydata(struct uio* uio, int off, int len, caddr_t cp)
45 struct iovec *iov = uio->uio_iov;
46 int iol = uio->uio_iovcnt;
50 panic("cuio_copydata: off %d < 0", off);
52 panic("cuio_copydata: len %d < 0", len);
55 panic("iov_copydata: empty in skip");
56 if (off < iov->iov_len)
64 panic("cuio_copydata: empty");
65 count = min(iov->iov_len - off, len);
66 bcopy(((caddr_t)iov->iov_base) + off, cp, count);
76 cuio_copyback(struct uio* uio, int off, int len, caddr_t cp)
78 struct iovec *iov = uio->uio_iov;
79 int iol = uio->uio_iovcnt;
83 panic("cuio_copyback: off %d < 0", off);
85 panic("cuio_copyback: len %d < 0", len);
88 panic("cuio_copyback: empty in skip");
89 if (off < iov->iov_len)
97 panic("uio_copyback: empty");
98 count = min(iov->iov_len - off, len);
99 bcopy(cp, ((caddr_t)iov->iov_base) + off, count);
109 * Return a pointer to iov/offset of location in iovec list.
112 cuio_getptr(struct uio *uio, int loc, int *off)
114 struct iovec *iov = uio->uio_iov;
115 int iol = uio->uio_iovcnt;
118 /* Normal end of search */
119 if (loc < iov->iov_len) {
127 /* Point at the end of valid data */