reimplement copy{in,out}str() similarly to copy{in,out}()
(instead of the old way of calling [fs]ubyte() in a loop).
This commit is contained in:
parent
293cf6ffe0
commit
804e68d33a
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.powerpc,v 1.33 2002/07/17 03:11:07 matt Exp $
|
||||
# $NetBSD: files.powerpc,v 1.34 2002/07/24 04:59:32 chs Exp $
|
||||
|
||||
defflag opt_altivec.h ALTIVEC K_ALTIVEC
|
||||
defflag opt_openpic.h OPENPIC OPENPIC_SERIAL_MODE
|
||||
|
@ -48,8 +48,6 @@ file arch/powerpc/mpc6xx/pmap.c ppc_mpc6xx & !oldpmap
|
|||
file arch/powerpc/powerpc/fpu.c ppc_mpc6xx
|
||||
file arch/powerpc/powerpc/pmap.c ppc_mpc6xx & oldpmap
|
||||
file arch/powerpc/powerpc/trap.c ppc_mpc6xx
|
||||
file arch/powerpc/powerpc/copyinstr.c ppc_mpc6xx
|
||||
file arch/powerpc/powerpc/copyoutstr.c ppc_mpc6xx
|
||||
|
||||
# Binary compatibility with previous NetBSD releases (COMPAT_XX)
|
||||
file arch/powerpc/powerpc/compat_13_machdep.c compat_13
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
/* $NetBSD: copyinstr.c,v 1.3 2000/02/19 23:29:16 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1995 Wolfgang Solfrank.
|
||||
* Copyright (C) 1995 TooLs GmbH.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by TooLs GmbH.
|
||||
* 4. The name of TooLs GmbH may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
/*
|
||||
* Emulate copyinstr.
|
||||
*/
|
||||
int
|
||||
copyinstr(udaddr, kaddr, len, done)
|
||||
const void *udaddr;
|
||||
void *kaddr;
|
||||
size_t len;
|
||||
size_t *done;
|
||||
{
|
||||
const u_char *up = udaddr;
|
||||
u_char *kp = kaddr;
|
||||
size_t l;
|
||||
int c, rv;
|
||||
|
||||
rv = ENAMETOOLONG;
|
||||
for (l = 0; len-- > 0; l++) {
|
||||
if ((c = fubyte(up++)) < 0) {
|
||||
rv = EFAULT;
|
||||
break;
|
||||
}
|
||||
if (!(*kp++ = c)) {
|
||||
l++;
|
||||
rv = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (done != NULL) {
|
||||
*done = l;
|
||||
}
|
||||
return rv;
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
/* $NetBSD: copyoutstr.c,v 1.3 2000/02/19 23:29:17 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1995 Wolfgang Solfrank.
|
||||
* Copyright (C) 1995 TooLs GmbH.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by TooLs GmbH.
|
||||
* 4. The name of TooLs GmbH may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
/*
|
||||
* Emulate copyoutstr.
|
||||
*/
|
||||
int
|
||||
copyoutstr(kaddr, udaddr, len, done)
|
||||
const void *kaddr;
|
||||
void *udaddr;
|
||||
size_t len;
|
||||
size_t *done;
|
||||
{
|
||||
const u_char *kp = kaddr;
|
||||
u_char *up = udaddr;
|
||||
size_t l;
|
||||
int rv;
|
||||
|
||||
rv = ENAMETOOLONG;
|
||||
for (l = 0; len-- > 0; l++) {
|
||||
if (subyte(up++, *kp) < 0) {
|
||||
rv = EFAULT;
|
||||
break;
|
||||
}
|
||||
if (!*kp++) {
|
||||
l++;
|
||||
rv = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (done != NULL) {
|
||||
*done = l;
|
||||
}
|
||||
return rv;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: trap.c,v 1.63 2002/07/05 18:45:22 matt Exp $ */
|
||||
/* $NetBSD: trap.c,v 1.64 2002/07/24 04:59:33 chs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
|
@ -606,3 +606,94 @@ fix_unaligned(p, frame)
|
|||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
copyinstr(udaddr, kaddr, len, done)
|
||||
const void *udaddr;
|
||||
void *kaddr;
|
||||
size_t len;
|
||||
size_t *done;
|
||||
{
|
||||
const char *up = udaddr;
|
||||
char *kp = kaddr;
|
||||
char *p;
|
||||
size_t l, ls, d;
|
||||
faultbuf env;
|
||||
int rv;
|
||||
|
||||
if ((rv = setfault(env)) != 0) {
|
||||
curpcb->pcb_onfault = 0;
|
||||
return rv;
|
||||
}
|
||||
d = 0;
|
||||
while (len > 0) {
|
||||
p = (char *)USER_ADDR + ((uintptr_t)up & ~SEGMENT_MASK);
|
||||
l = ((char *)USER_ADDR + SEGMENT_LENGTH) - p;
|
||||
if (l > len)
|
||||
l = len;
|
||||
setusr(curpcb->pcb_pm->pm_sr[(uintptr_t)up >> ADDR_SR_SHFT]);
|
||||
for (ls = l; ls > 0; ls--) {
|
||||
if ((*kp++ = *p++) == 0) {
|
||||
d += l - ls + 1;
|
||||
rv = 0;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
d += l;
|
||||
len -= l;
|
||||
}
|
||||
rv = ENAMETOOLONG;
|
||||
|
||||
out:
|
||||
curpcb->pcb_onfault = 0;
|
||||
if (done != NULL) {
|
||||
*done = d;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
copyoutstr(kaddr, udaddr, len, done)
|
||||
const void *kaddr;
|
||||
void *udaddr;
|
||||
size_t len;
|
||||
size_t *done;
|
||||
{
|
||||
const char *kp = kaddr;
|
||||
char *up = udaddr;
|
||||
char *p;
|
||||
int rv;
|
||||
size_t l, ls, d;
|
||||
faultbuf env;
|
||||
|
||||
if ((rv = setfault(env)) != 0) {
|
||||
curpcb->pcb_onfault = 0;
|
||||
return rv;
|
||||
}
|
||||
d = 0;
|
||||
while (len > 0) {
|
||||
p = (char *)USER_ADDR + ((uintptr_t)up & ~SEGMENT_MASK);
|
||||
l = ((char *)USER_ADDR + SEGMENT_LENGTH) - p;
|
||||
if (l > len)
|
||||
l = len;
|
||||
setusr(curpcb->pcb_pm->pm_sr[(uintptr_t)up >> ADDR_SR_SHFT]);
|
||||
for (ls = l; ls > 0; ls--) {
|
||||
if ((*p++ = *kp++) == 0) {
|
||||
d += l - ls + 1;
|
||||
rv = 0;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
d += l;
|
||||
len -= l;
|
||||
}
|
||||
rv = ENAMETOOLONG;
|
||||
|
||||
out:
|
||||
curpcb->pcb_onfault = 0;
|
||||
if (done != NULL) {
|
||||
*done = d;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue