Move the arm32 copystr.S from arch/arm/arm32 to arch/arm/arm and add support

for 26-bit modes (basically saving R14 when we might get a page fault).
Use it on all ARM architectures now.
This commit is contained in:
bjh21 2002-08-11 23:17:24 +00:00
parent 02f0a2cf44
commit 206c97ccc2
3 changed files with 18 additions and 109 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: copyinout.S,v 1.3 2002/08/11 21:19:15 bjh21 Exp $ */
/* $NetBSD: copyinout.S,v 1.4 2002/08/11 23:17:24 bjh21 Exp $ */
/*-
* Copyright (c) 2000 Ben Harris
@ -32,110 +32,11 @@
#include <machine/asm.h>
RCSID("$NetBSD: copyinout.S,v 1.3 2002/08/11 21:19:15 bjh21 Exp $")
RCSID("$NetBSD: copyinout.S,v 1.4 2002/08/11 23:17:24 bjh21 Exp $")
#include <sys/errno.h>
#include "assym.h"
/* LINTSTUB: Func: int copyinstr(const void *uaddr, void *kaddr, size_t len, size_t *done) */
ENTRY(copyinstr)
mov ip, sp
stmfd sp!, {r4, r5, r6, fp, ip, lr, pc}
sub fp, ip, #4
adr r4, Lcopystrfault
ldr r5, Lcurproc
ldr r5, [r5]
ldr r5, [r5, #P_ADDR]
str r4, [r5, #(U_PCB + PCB_ONFAULT)]
mov r6, r1
Lcopyinstrloop:
ldrbt r4, [r0], #1
strb r4, [r1], #1
subs r2, r2, #1
teqne r4, #0
bne Lcopyinstrloop
teq r3, #0
subne r6, r1, r6
strne r6, [r3]
mov r0, #0
str r0, [r5, #(U_PCB + PCB_ONFAULT)]
teq r4, #0
movne r0, #ENAMETOOLONG
#ifdef __APCS_26__
ldmdb fp, {r4, r5, r6, fp, sp, pc}^
#else
ldmdb fp, {r4, r5, r6, fp, sp, pc}
#endif
/* LINTSTUB: Func: int copyoutstr(const void *kaddr, void *uaddr, size_t len, size_t *done) */
ENTRY(copyoutstr)
mov ip, sp
stmfd sp!, {r4, r5, r6, fp, ip, lr, pc}
sub fp, ip, #4
adr r4, Lcopystrfault
ldr r5, Lcurproc
ldr r5, [r5]
ldr r5, [r5, #P_ADDR]
str r4, [r5, #(U_PCB + PCB_ONFAULT)]
mov r6, r1
Lcopyoutstrloop:
ldrb r4, [r0], #1
strbt r4, [r1], #1
subs r2, r2, #1
teqne r4, #0
bne Lcopyoutstrloop
teq r3, #0
subne r6, r1, r6
strne r6, [r3]
mov r0, #0
str r0, [r5, #(U_PCB + PCB_ONFAULT)]
teq r4, #0
movne r0, #ENAMETOOLONG
#ifdef __APCS_26__
ldmdb fp, {r4, r5, r6, fp, sp, pc}^
#else
ldmdb fp, {r4, r5, r6, fp, sp, pc}
#endif
/* LINTSTUB: Func: int copystr(const void *kfaddr, void *kdaddr, size_t len, size_t *done) */
ENTRY(copystr)
mov ip, sp
stmfd sp!, {r4, r5, r6, fp, ip, lr, pc}
sub fp, ip, #4
adr r4, Lcopystrfault
ldr r5, Lcurproc
ldr r5, [r5]
ldr r5, [r5, #P_ADDR]
str r4, [r5, #(U_PCB + PCB_ONFAULT)]
mov r6, r1
Lcopystrloop:
ldrb r4, [r0], #1
strb r4, [r1], #1
subs r2, r2, #1
teqne r4, #0
bne Lcopystrloop
teq r3, #0
subne r6, r1, r6
strne r6, [r3]
mov r0, #0
str r0, [r5, #(U_PCB + PCB_ONFAULT)]
teq r4, #0
movne r0, #ENAMETOOLONG
ldmdb fp, {r4, r5, r6, fp, sp, pc}^
Lcopystrfault:
teq r3, #0
subne r6, r1, r6
strne r6, [r3]
mov r1, #0
str r1, [r5, #(U_PCB + PCB_ONFAULT)]
/* Return value is provided by fault handler. */
#ifdef __APCS_26__
ldmdb fp, {r4, r5, r6, fp, sp, pc}^
#else
ldmdb fp, {r4, r5, r6, fp, sp, pc}
#endif
/* LINTSTUB: Func: int fubyte(void *base) */
ENTRY(fubyte)
mov ip, lr /* data-abort safety */

View File

@ -1,4 +1,4 @@
/* $NetBSD: copystr.S,v 1.5 2002/08/09 06:18:24 thorpej Exp $ */
/* $NetBSD: copystr.S,v 1.1 2002/08/11 23:17:25 bjh21 Exp $ */
/*
* Copyright (c) 1995 Mark Brinicombe.
@ -79,6 +79,14 @@ ENTRY(copystr)
ldmfd sp!, {r4-r5} /* stack is 8 byte aligned */
mov pc, lr
#ifdef __PROG32
#define SAVE_REGS stmfd sp!, {r4-r6}
#define RESTORE_REGS ldmfd sp!, {r4-r6}
#else
/* Need to save R14_svc because it'll get trampled if we take a page fault. */
#define SAVE_REGS stmfd sp!, {r4-r6, r14}
#define RESTORE_REGS ldmfd sp!, {r4-r6, r14}
#endif
/*
* r0 - user space address
@ -89,7 +97,7 @@ ENTRY(copystr)
* Copy string from user space to kernel space
*/
ENTRY(copyinstr)
stmfd sp!, {r4-r6}
SAVE_REGS
teq r2, #0x00000000
mov r6, #0x00000000
@ -124,7 +132,7 @@ ENTRY(copyinstr)
2: teq r3, #0x00000000
strne r6, [r3]
ldmfd sp!, {r4-r6} /* stack is 8 byte aligned */
RESTORE_REGS
mov pc, lr
/*
@ -136,7 +144,7 @@ ENTRY(copyinstr)
* Copy string from kernel space to user space
*/
ENTRY(copyoutstr)
stmfd sp!, {r4-r6} /* stack isn't 8 byte aligned */
SAVE_REGS
teq r2, #0x00000000
mov r6, #0x00000000
@ -171,14 +179,14 @@ ENTRY(copyoutstr)
2: teq r3, #0x00000000
strne r6, [r3]
ldmfd sp!, {r4-r6} /* stack is 8 byte aligned */
RESTORE_REGS
mov pc, lr
/* A fault occurred during the copy */
Lcopystrfault:
mov r0, #0x00000000
str r0, [r4, #PCB_ONFAULT]
ldmfd sp!, {r4-r6} /* stack is 8 byte aligned */
RESTORE_REGS
mov r0, #EFAULT
mov pc, lr

View File

@ -1,4 +1,4 @@
# $NetBSD: files.arm,v 1.62 2002/08/11 21:19:14 bjh21 Exp $
# $NetBSD: files.arm,v 1.63 2002/08/11 23:17:25 bjh21 Exp $
# temporary define to allow easy moving to ../arch/arm/arm32
defflag ARM32
@ -64,6 +64,7 @@ file arch/arm/arm/bcopyinout.S
file arch/arm/arm/blockio.S
file arch/arm/arm/bootconfig.c
file arch/arm/arm/compat_13_machdep.c compat_13
file arch/arm/arm/copystr.S
file arch/arm/arm/cpufunc.c
file arch/arm/arm/cpufunc_asm.S
file arch/arm/arm/cpufunc_asm_arm3.S cpu_arm3
@ -114,7 +115,6 @@ file arch/arm/arm32/vm_machdep.c arm32
# arm32 library functions
file arch/arm/arm32/bcopy_page.S arm32
file arch/arm/arm32/copystr.S arm32
# Linux binary compatibility (COMPAT_LINUX)
include "compat/ossaudio/files.ossaudio"