Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Move the arm32 copystr.S from arch/arm/arm32 to arc...



details:   https://anonhg.NetBSD.org/src/rev/3464717041ea
branches:  trunk
changeset: 535201:3464717041ea
user:      bjh21 <bjh21%NetBSD.org@localhost>
date:      Sun Aug 11 23:17:24 2002 +0000

description:
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.

diffstat:

 sys/arch/acorn26/acorn26/copyinout.S |  103 +-----------------
 sys/arch/arm/arm/copystr.S           |  204 +++++++++++++++++++++++++++++++++++
 sys/arch/arm/arm32/copystr.S         |  196 ---------------------------------
 sys/arch/arm/conf/files.arm          |    4 +-
 4 files changed, 208 insertions(+), 299 deletions(-)

diffs (truncated from 554 to 300 lines):

diff -r 3c9c1ba2524f -r 3464717041ea sys/arch/acorn26/acorn26/copyinout.S
--- a/sys/arch/acorn26/acorn26/copyinout.S      Sun Aug 11 22:29:07 2002 +0000
+++ b/sys/arch/acorn26/acorn26/copyinout.S      Sun Aug 11 23:17:24 2002 +0000
@@ -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 */
diff -r 3c9c1ba2524f -r 3464717041ea sys/arch/arm/arm/copystr.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/arm/copystr.S        Sun Aug 11 23:17:24 2002 +0000
@@ -0,0 +1,204 @@
+/*     $NetBSD: copystr.S,v 1.1 2002/08/11 23:17:25 bjh21 Exp $        */
+
+/*
+ * Copyright (c) 1995 Mark Brinicombe.
+ * 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 Mark Brinicombe.
+ * 4. The name of the company nor the name of the author may be used to
+ *    endorse or promote products derived from this software without specific
+ *    prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR OR CONTRIBUTORS 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.
+ *
+ * copystr.S
+ *
+ * optimised and fault protected copystr functions
+ *
+ * Created      : 16/05/95
+ */
+
+#include "assym.h"
+#include <machine/asm.h>
+#include <sys/errno.h>
+
+       .text
+       .align  0
+Lcurpcb:
+       .word   _C_LABEL(curpcb)
+
+/*
+ * r0 - from
+ * r1 - to
+ * r2 - maxlens
+ * r3 - lencopied
+ *
+ * Copy string from r0 to r1
+ */
+ENTRY(copystr)
+       stmfd   sp!, {r4-r5}                    /* stack is 8 byte aligned */
+       teq     r2, #0x00000000
+       mov     r5, #0x00000000
+       moveq   r0, #ENAMETOOLONG
+       beq     2f
+
+1:     ldrb    r4, [r0], #0x0001
+       add     r5, r5, #0x00000001
+       teq     r4, #0x00000000
+       strb    r4, [r1], #0x0001
+       teqne   r5, r2
+       bne     1b
+
+       teq     r4, #0x00000000
+       moveq   r0, #0x00000000
+       movne   r0, #ENAMETOOLONG
+
+2:     teq     r3, #0x00000000
+       strne   r5, [r3]
+
+       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
+ * r1 - kernel space address
+ * r2 - maxlens
+ * r3 - lencopied
+ *
+ * Copy string from user space to kernel space
+ */
+ENTRY(copyinstr)
+       SAVE_REGS
+
+       teq     r2, #0x00000000
+       mov     r6, #0x00000000
+       moveq   r0, #ENAMETOOLONG
+       beq     2f
+
+       ldr     r4, Lcurpcb
+       ldr     r4, [r4]
+
+#ifdef DIAGNOSTIC
+       teq     r4, #0x00000000
+       beq     Lcopystrpcbfault
+#endif
+
+       add     r5, pc, #Lcopystrfault - . - 8
+       str     r5, [r4, #PCB_ONFAULT]
+
+1:     ldrbt   r5, [r0], #0x0001
+       add     r6, r6, #0x00000001
+       teq     r5, #0x00000000
+       strb    r5, [r1], #0x0001
+       teqne   r6, r2
+       bne     1b
+
+       mov     r0, #0x00000000
+       str     r0, [r4, #PCB_ONFAULT]
+
+       teq     r5, #0x00000000
+       moveq   r0, #0x00000000
+       movne   r0, #ENAMETOOLONG
+
+2:     teq     r3, #0x00000000
+       strne   r6, [r3]
+
+       RESTORE_REGS
+       mov     pc, lr
+
+/*
+ * r0 - kernel space address
+ * r1 - user space address
+ * r2 - maxlens
+ * r3 - lencopied
+ *
+ * Copy string from kernel space to user space
+ */
+ENTRY(copyoutstr)
+       SAVE_REGS
+
+       teq     r2, #0x00000000
+       mov     r6, #0x00000000
+       moveq   r0, #ENAMETOOLONG
+       beq     2f
+
+       ldr     r4, Lcurpcb
+       ldr     r4, [r4]
+
+#ifdef DIAGNOSTIC
+       teq     r4, #0x00000000
+       beq     Lcopystrpcbfault
+#endif
+
+       add     r5, pc, #Lcopystrfault - . - 8
+       str     r5, [r4, #PCB_ONFAULT]
+
+1:     ldrb    r5, [r0], #0x0001
+       add     r6, r6, #0x00000001
+       teq     r5, #0x00000000
+       strbt   r5, [r1], #0x0001
+       teqne   r6, r2
+       bne     1b
+
+       mov     r0, #0x00000000
+       str     r0, [r4, #PCB_ONFAULT]
+
+       teq     r5, #0x00000000



Home | Main Index | Thread Index | Old Index