Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / rump / librump / rumpkern / rumpcopy.c
blob4f28cb51904adbad7888ba34358f2b76ff724815
1 /* $NetBSD: rumpcopy.c,v 1.1 2009/11/04 17:01:45 pooka Exp $ */
3 /*
4 * Copyright (c) 2009 Antti Kantee. All Rights Reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
28 #include <sys/cdefs.h>
29 __KERNEL_RCSID(0, "$NetBSD: rumpcopy.c,v 1.1 2009/11/04 17:01:45 pooka Exp $");
31 #include <sys/param.h>
32 #include <sys/lwp.h>
33 #include <sys/systm.h>
35 #include <rump/rump.h>
37 #include "rump_private.h"
39 int
40 copyin(const void *uaddr, void *kaddr, size_t len)
43 if (curproc->p_vmspace == &rump_vmspace)
44 memcpy(kaddr, uaddr, len);
45 else
46 rump_sysproxy_copyin(uaddr, kaddr, len);
47 return 0;
50 int
51 copyout(const void *kaddr, void *uaddr, size_t len)
54 if (curproc->p_vmspace == &rump_vmspace)
55 memcpy(uaddr, kaddr, len);
56 else
57 rump_sysproxy_copyout(kaddr, uaddr, len);
58 return 0;
61 int
62 subyte(void *uaddr, int byte)
65 if (curproc->p_vmspace == &rump_vmspace)
66 *(char *)uaddr = byte;
67 else
68 rump_sysproxy_copyout(&byte, uaddr, 1);
69 return 0;
72 int
73 copystr(const void *kfaddr, void *kdaddr, size_t len, size_t *done)
76 return copyinstr(kfaddr, kdaddr, len, done);
79 int
80 copyinstr(const void *uaddr, void *kaddr, size_t len, size_t *done)
83 if (curproc->p_vmspace == &rump_vmspace)
84 strlcpy(kaddr, uaddr, len);
85 else
86 rump_sysproxy_copyin(uaddr, kaddr, len);
87 if (done)
88 *done = strlen(kaddr)+1; /* includes termination */
89 return 0;
92 int
93 copyoutstr(const void *kaddr, void *uaddr, size_t len, size_t *done)
96 if (curproc->p_vmspace == &rump_vmspace)
97 strlcpy(uaddr, kaddr, len);
98 else
99 rump_sysproxy_copyout(kaddr, uaddr, len);
100 if (done)
101 *done = strlen(uaddr)+1; /* includes termination */
102 return 0;
106 kcopy(const void *src, void *dst, size_t len)
109 memcpy(dst, src, len);
110 return 0;