1 /* $NetBSD: rumpcopy.c,v 1.1 2009/11/04 17:01:45 pooka Exp $ */
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
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
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>
33 #include <sys/systm.h>
35 #include <rump/rump.h>
37 #include "rump_private.h"
40 copyin(const void *uaddr
, void *kaddr
, size_t len
)
43 if (curproc
->p_vmspace
== &rump_vmspace
)
44 memcpy(kaddr
, uaddr
, len
);
46 rump_sysproxy_copyin(uaddr
, kaddr
, len
);
51 copyout(const void *kaddr
, void *uaddr
, size_t len
)
54 if (curproc
->p_vmspace
== &rump_vmspace
)
55 memcpy(uaddr
, kaddr
, len
);
57 rump_sysproxy_copyout(kaddr
, uaddr
, len
);
62 subyte(void *uaddr
, int byte
)
65 if (curproc
->p_vmspace
== &rump_vmspace
)
66 *(char *)uaddr
= byte
;
68 rump_sysproxy_copyout(&byte
, uaddr
, 1);
73 copystr(const void *kfaddr
, void *kdaddr
, size_t len
, size_t *done
)
76 return copyinstr(kfaddr
, kdaddr
, len
, done
);
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
);
86 rump_sysproxy_copyin(uaddr
, kaddr
, len
);
88 *done
= strlen(kaddr
)+1; /* includes termination */
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
);
99 rump_sysproxy_copyout(kaddr
, uaddr
, len
);
101 *done
= strlen(uaddr
)+1; /* includes termination */
106 kcopy(const void *src
, void *dst
, size_t len
)
109 memcpy(dst
, src
, len
);