Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/mips - Make monolistic files into smaller manageabl...



details:   https://anonhg.NetBSD.org/src/rev/d23de99503f6
branches:  trunk
changeset: 539130:d23de99503f6
user:      nisimura <nisimura%NetBSD.org@localhost>
date:      Sat Nov 09 02:02:31 2002 +0000

description:
- Make monolistic files into smaller manageable pieces, resulting
three new files;
    sig_machdep.c (from mips_machdep.c)
    copy.S and sigcode.S (from locore.S)
- Nuke the local use of struct sigframe, which is now identical to
struct sigcontext, from sendsig() as the consequence of new signal
trampoline.

diffstat:

 sys/arch/mips/conf/files.mips     |   17 +-
 sys/arch/mips/mips/copy.S         |  459 ++++++++++++++++++++++++++++++++++++++
 sys/arch/mips/mips/locore.S       |  449 +-------------------------------------
 sys/arch/mips/mips/mips_machdep.c |  252 +-------------------
 sys/arch/mips/mips/sig_machdep.c  |  350 ++++++++++++++++++++++++++++
 sys/arch/mips/mips/sigcode.S      |   58 ++++
 6 files changed, 891 insertions(+), 694 deletions(-)

diffs (truncated from 1698 to 300 lines):

diff -r 2c843782077a -r d23de99503f6 sys/arch/mips/conf/files.mips
--- a/sys/arch/mips/conf/files.mips     Sat Nov 09 01:35:54 2002 +0000
+++ b/sys/arch/mips/conf/files.mips     Sat Nov 09 02:02:31 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.mips,v 1.43 2002/11/08 00:50:49 simonb Exp $
+#      $NetBSD: files.mips,v 1.44 2002/11/09 02:02:31 nisimura Exp $
 #
 
 defflag        opt_cputype.h           NOFPU   # and the rest...
@@ -20,20 +20,23 @@
 file   arch/mips/mips/mips5900_subr.S          mips3 & mips3_5900
 file   arch/mips/mips/mips32_subr.S            mips32
 file   arch/mips/mips/mips64_subr.S            mips64
+file   arch/mips/mips/sigcode.S
+file   arch/mips/mips/copy.S
 
 file   arch/mips/mips/db_disasm.c              ddb
 file   arch/mips/mips/db_interface.c           ddb | kgdb
 file   arch/mips/mips/db_trace.c               ddb
-file   arch/mips/mips/cpu_exec.c
 file   arch/mips/mips/kgdb_machdep.c           kgdb
 file   arch/mips/mips/mem.c
 file   arch/mips/mips/pmap.c
-file   arch/mips/mips/syscall.c                # syscalls
-file   arch/mips/mips/trap.c                   # interrupt, trap handlers
+file   arch/mips/mips/trap.c                   # trap handlers
+file   arch/mips/mips/syscall.c                # syscall entries
+file   arch/mips/mips/mips_machdep.c
+file   arch/mips/mips/sig_machdep.c            # signal delivery
+file   arch/mips/mips/sys_machdep.c
 file   arch/mips/mips/vm_machdep.c
-file   arch/mips/mips/mips_machdep.c           # shared mips machdep.c
-file   arch/mips/mips/sys_machdep.c            # shared mips sys_machdep
-file   arch/mips/mips/process_machdep.c        # shared process_machdep
+file   arch/mips/mips/process_machdep.c
+file   arch/mips/mips/cpu_exec.c
 
 file   arch/mips/mips/cache.c
 file   arch/mips/mips/cache_r3k.c              mips1
diff -r 2c843782077a -r d23de99503f6 sys/arch/mips/mips/copy.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mips/mips/copy.S Sat Nov 09 02:02:31 2002 +0000
@@ -0,0 +1,459 @@
+/*     $NetBSD: copy.S,v 1.1 2002/11/09 02:02:33 nisimura Exp $        */
+
+/*
+ * Copyright (c) 1992, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Digital Equipment Corporation and Ralph Campbell.
+ *
+ * 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 the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS 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.
+ *
+ * Copyright (C) 1989 Digital Equipment Corporation.
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appears in all copies.
+ * Digital Equipment Corporation makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/loMem.s,
+ *     v 1.1 89/07/11 17:55:04 nelson Exp  SPRITE (DECWRL)
+ * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machAsm.s,
+ *     v 9.2 90/01/29 18:00:39 shirriff Exp  SPRITE (DECWRL)
+ * from: Header: /sprite/src/kernel/vm/ds3100.md/vmPmaxAsm.s,
+ *     v 1.1 89/07/10 14:27:41 nelson Exp  SPRITE (DECWRL)
+ *
+ *     @(#)locore.s    8.5 (Berkeley) 1/4/94
+ */
+
+/*
+ * copy(9) - kernel space to/from user space copy functions.
+ * fetch(9) - fetch data from user-space.
+ * store(9) - store data to user-space.
+ */
+
+#include <sys/errno.h>
+#include <mips/asm.h>
+#include "assym.h"
+
+       .set    noreorder
+/*
+ * int copystr(void *kfaddr, void *kdaddr, size_t maxlen, size_t *lencopied)
+ * Copy a NIL-terminated string, at most maxlen characters long.  Return the
+ * number of characters copied (including the NIL) in *lencopied.  If the
+ * string is too long, return ENAMETOOLONG; else return 0.
+ */
+LEAF(copystr)
+       move    t0, a2
+       beq     a2, zero, 4f
+1:
+       lbu     v0, 0(a0)
+       subu    a2, a2, 1
+       beq     v0, zero, 2f
+       sb      v0, 0(a1)                       # each byte until NIL
+       addu    a0, a0, 1
+       bne     a2, zero, 1b                    # less than maxlen
+       addu    a1, a1, 1
+4:
+       li      v0, ENAMETOOLONG                # run out of space
+2:
+       beq     a3, zero, 3f                    # return num. of copied bytes
+       subu    a2, t0, a2                      # if the 4th arg was non-NULL
+       sw      a2, 0(a3)
+3:
+       j       ra                              # v0 is 0 or ENAMETOOLONG
+       nop
+END(copystr)
+
+/*
+ * int copyinstr(void *uaddr, void *kaddr, size_t maxlen, size_t *lencopied)
+ * Copy a NIL-terminated string, at most maxlen characters long, from the
+ * user's address space.  Return the number of characters copied (including
+ * the NIL) in *lencopied.  If the string is too long, return ENAMETOOLONG;
+ * else return 0 or EFAULT.
+ */
+LEAF(copyinstr)
+       lw      v1, _C_LABEL(curpcb)
+       la      v0, _C_LABEL(copystrerr)
+       blt     a0, zero, _C_LABEL(copystrerr)
+       sw      v0, U_PCB_ONFAULT(v1)
+       move    t0, a2
+       beq     a2, zero, 4f
+1:
+       lbu     v0, 0(a0)
+       subu    a2, a2, 1
+       beq     v0, zero, 2f
+       sb      v0, 0(a1)
+       addu    a0, a0, 1
+       bne     a2, zero, 1b
+       addu    a1, a1, 1
+4:
+       li      v0, ENAMETOOLONG
+2:
+       beq     a3, zero, 3f
+       subu    a2, t0, a2
+       sw      a2, 0(a3)
+3:
+       j       ra                              # v0 is 0 or ENAMETOOLONG
+       sw      zero, U_PCB_ONFAULT(v1)
+END(copyinstr)
+
+/*
+ * int copyoutstr(void *uaddr, void *kaddr, size_t maxlen, size_t *lencopied);
+ * Copy a NIL-terminated string, at most maxlen characters long, into the
+ * user's address space.  Return the number of characters copied (including
+ * the NIL) in *lencopied.  If the string is too long, return ENAMETOOLONG;
+ * else return 0 or EFAULT.
+ */
+LEAF(copyoutstr)
+       lw      v1, _C_LABEL(curpcb)
+       la      v0, _C_LABEL(copystrerr)
+       blt     a1, zero, _C_LABEL(copystrerr)
+       sw      v0, U_PCB_ONFAULT(v1)
+       move    t0, a2
+       beq     a2, zero, 4f
+1:
+       lbu     v0, 0(a0)
+       subu    a2, a2, 1
+       beq     v0, zero, 2f
+       sb      v0, 0(a1)
+       addu    a0, a0, 1
+       bne     a2, zero, 1b
+       addu    a1, a1, 1
+4:
+       li      v0, ENAMETOOLONG
+2:
+       beq     a3, zero, 3f
+       subu    a2, t0, a2
+       sw      a2, 0(a3)
+3:
+       j       ra                              # v0 is 0 or ENAMETOOLONG
+       sw      zero, U_PCB_ONFAULT(v1)
+END(copyoutstr)
+
+LEAF(copystrerr)
+       sw      zero, U_PCB_ONFAULT(v1)
+       j       ra
+       li      v0, EFAULT                      # return EFAULT
+END(copystrerr)
+
+/*
+ * kcopy(const void *src, void *dst, size_t len);
+ *
+ * Copy len bytes from src to dst, aborting if we encounter a fatal
+ * page fault.
+ *
+ * kcopy() _must_ save and restore the old fault handler since it is
+ * called by uiomove(), which may be in the path of servicing a non-fatal
+ * page fault.
+ */
+NESTED(kcopy, 48, ra)
+       subu    sp, sp, 48                      # set up stack frame
+       /* Frame contains RA (31) and S0 (16). */
+       .mask   0x80010000, -4
+       sw      ra, 44(sp)                      # save ra
+       sw      s0, 32(sp)                      # save s0
+       move    v0, a0                          # swap a0, a1 for call to memcpy
+       move    a0, a1
+       move    a1, v0
+       lw      v1, _C_LABEL(curpcb)            # set up fault handler
+       la      v0, _C_LABEL(kcopyerr)
+       lw      s0, U_PCB_ONFAULT(v1)           # save old handler
+       jal     memcpy
+       sw      v0, U_PCB_ONFAULT(v1)
+
+       lw      v1, _C_LABEL(curpcb)            # restore the old handler
+       lw      ra, 44(sp)                      # restore ra
+       sw      s0, U_PCB_ONFAULT(v1)
+       lw      s0, 32(sp)                      # restore s0
+       addu    sp, sp, 48                      # kill stack frame
+       j       ra
+       move    v0, zero                        # success!
+END(kcopy)
+
+LEAF(kcopyerr)
+       lw      v1, _C_LABEL(curpcb)            # restore the old handler
+       lw      ra, 44(sp)                      # restore ra
+       sw      s0, U_PCB_ONFAULT(v1)
+       lw      s0, 32(sp)                      # restore s0
+       addu    sp, sp, 48                      # kill stack frame
+       j       ra
+       li      v0, EFAULT                      # return EFAULT
+END(kcopyerr)
+
+/*
+ * int copyin(void *uaddr, void *kaddr, size_t len)
+ * Copies len bytes of data from the user-space address uaddr to the
+ * kernel-space address kaddr.  copyin returns 0 on success or EFAULT
+ * if a bad address is encountered.
+ */
+NESTED(copyin, CALLFRAME_SIZ, ra)
+       subu    sp, sp, CALLFRAME_SIZ
+       .mask   0x80000000, -4
+       sw      ra, CALLFRAME_RA(sp)
+       blt     a0, zero, _C_LABEL(copyerr)
+       move    v0, a0                          # swap a0, a1 for call to memcpy
+       move    a0, a1
+       move    a1, v0
+       lw      v1, _C_LABEL(curpcb)
+       la      v0, _C_LABEL(copyerr)
+       jal     memcpy
+       sw      v0, U_PCB_ONFAULT(v1)
+
+       lw      v1, _C_LABEL(curpcb)
+       lw      ra, CALLFRAME_RA(sp)
+       addu    sp, sp, CALLFRAME_SIZ
+       sw      zero, U_PCB_ONFAULT(v1)
+       j       ra
+       move    v0, zero
+END(copyin)
+
+/*
+ * int copyout(void *kaddr, void *uaddr, size_t len)
+ * Copies len bytes of data from the kernel-space address kaddr to the
+ * user-space address uaddr.  copyout returns 0 on success or EFAULT
+ * if a bad address is encountered.
+ */
+NESTED(copyout, CALLFRAME_SIZ, ra)
+       subu    sp, sp, CALLFRAME_SIZ
+       .mask   0x80000000, -4
+       sw      ra, CALLFRAME_RA(sp)
+       blt     a1, zero, _C_LABEL(copyerr)
+       move    v0, a0                          # swap a0, a1 for call to memcpy
+       move    a0, a1
+       move    a1, v0
+       lw      v1, _C_LABEL(curpcb)
+       la      v0, _C_LABEL(copyerr)
+       jal     memcpy
+       sw      v0, U_PCB_ONFAULT(v1)
+
+       lw      v1, _C_LABEL(curpcb)



Home | Main Index | Thread Index | Old Index