1 /* $NetBSD: copy.c,v 1.1 2007/12/29 14:38:36 jmcneill Exp $ */ 2 3 /*- 4 * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Jared D. McNeill. 18 * 4. Neither the name of The NetBSD Foundation nor the names of its 19 * contributors may be used to endorse or promote products derived 20 * from this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 * POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 #include <sys/cdefs.h> 36 __KERNEL_RCSID(0, "$NetBSD: copy.c,v 1.1 2007/12/29 14:38:36 jmcneill Exp $"); 37 38 #include <sys/types.h> 39 #include <sys/systm.h> 40 41 int 42 copyin(const void *uaddr, void *kaddr, size_t len) 43 { 44 memcpy(kaddr, uaddr, len); 45 return 0; 46 } 47 48 int 49 copyout(const void *kaddr, void *uaddr, size_t len) 50 { 51 memcpy(uaddr, kaddr, len); 52 return 0; 53 } 54 55 int 56 copyinstr(const void *uaddr, void *kaddr, size_t len, size_t *done) 57 { 58 strncpy(kaddr, uaddr, len); 59 if (done) 60 *done = min(strlen(uaddr), len); 61 return 0; 62 } 63 64 int 65 copyoutstr(const void *kaddr, void *uaddr, size_t len, size_t *done) 66 { 67 strncpy(uaddr, kaddr, len); 68 if (done) 69 *done = min(strlen(kaddr), len); 70 return 0; 71 } 72 73 int 74 copystr(const void *kfaddr, void *kdaddr, size_t len, size_t *done) 75 { 76 strncpy(kdaddr, kfaddr, len); 77 if (done) 78 *done = min(strlen(kfaddr), len); 79 return 0; 80 } 81 82 int 83 kcopy(const void *src, void *dst, size_t len) 84 { 85 memcpy(dst, src, len); 86 return 0; 87 } 88 89 int 90 fuswintr(const void *base) 91 { 92 return *(const short *)base; 93 } 94 95 int 96 suswintr(void *base, short c) 97 { 98 *(short *)base = c; 99 return 0; 100 } 101 102 int 103 subyte(void *base, int c) 104 { 105 *(char *)base = c; 106 return 0; 107 } 108 109 int 110 suword(void *base, long c) 111 { 112 *(long *)base = c; 113 return 0; 114 } 115