Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64 Split copy related functions out of locore....



details:   https://anonhg.NetBSD.org/src/rev/80dfaec8aa4d
branches:  trunk
changeset: 755132:80dfaec8aa4d
user:      martin <martin%NetBSD.org@localhost>
date:      Sun May 23 18:49:14 2010 +0000

description:
Split copy related functions out of locore.s into copy.S, move functions
only needed on multiprocessors into mp_subr.S.

diffstat:

 sys/arch/sparc64/conf/Makefile.sparc64 |    13 +-
 sys/arch/sparc64/include/locore.h      |   155 +++-
 sys/arch/sparc64/sparc64/copy.S        |  1189 +++++++++++++++++++++++
 sys/arch/sparc64/sparc64/locore.s      |  1598 +-------------------------------
 sys/arch/sparc64/sparc64/mp_subr.S     |   411 ++++++++
 5 files changed, 1774 insertions(+), 1592 deletions(-)

diffs (truncated from 3486 to 300 lines):

diff -r 5cff004a0ca8 -r 80dfaec8aa4d sys/arch/sparc64/conf/Makefile.sparc64
--- a/sys/arch/sparc64/conf/Makefile.sparc64    Sun May 23 14:08:05 2010 +0000
+++ b/sys/arch/sparc64/conf/Makefile.sparc64    Sun May 23 18:49:14 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.sparc64,v 1.68 2008/12/11 05:27:42 alc Exp $
+#      $NetBSD: Makefile.sparc64,v 1.69 2010/05/23 18:49:14 martin Exp $
 
 #=========================================================================
 #
@@ -85,13 +85,20 @@
 ##
 ## (4) local objects, compile rules, and dependencies
 ##
-MD_OBJS=       locore.o
+MD_OBJS=       locore.o copy.o mp_subr.o
 MD_CFILES=
-MD_SFILES=     ${SPARC64}/sparc64/locore.s
+MD_SFILES=     ${SPARC64}/sparc64/locore.s ${SPARC64}/sparc64/copy.S \
+        ${SPARC64}/sparc64/mp_subr.S
 
 locore.o: ${SPARC64}/sparc64/locore.s assym.h
        ${NORMAL_S}
 
+copy.o:        ${SPARC64}/sparc64/copy.S assym.h
+       ${NORMAL_S}
+
+mp_subr.o:     ${SPARC64}/sparc64/mp_subr.S assym.h
+       ${NORMAL_S}
+
 ##
 ## (5) link settings
 ##
diff -r 5cff004a0ca8 -r 80dfaec8aa4d sys/arch/sparc64/include/locore.h
--- a/sys/arch/sparc64/include/locore.h Sun May 23 14:08:05 2010 +0000
+++ b/sys/arch/sparc64/include/locore.h Sun May 23 18:49:14 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.h,v 1.3 2010/03/07 01:52:44 mrg Exp $   */
+/*     $NetBSD: locore.h,v 1.4 2010/05/23 18:49:14 martin Exp $        */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath
@@ -90,3 +90,156 @@
 /* use as needed to align things on longword boundaries */
 #define        _ALIGN  .align 8
 #define ICACHE_ALIGN   .align  32
+
+/* A few convenient abbreviations for trapframe fields. */
+#define        TF_G    TF_GLOBAL
+#define        TF_O    TF_OUT
+#define        TF_L    TF_LOCAL
+#define        TF_I    TF_IN
+
+/* Let us use same syntax as C code */
+#define Debugger()     ta      1; nop
+
+
+/*
+ * This macro will clear out a cache line before an explicit
+ * access to that location.  It's mostly used to make certain
+ * loads bypassing the D$ do not get stale D$ data.
+ *
+ * It uses a register with the address to clear and a temporary
+ * which is destroyed.
+ */
+#ifdef DCACHE_BUG
+#define DLFLUSH(a,t) \
+       andn    a, 0x3f, t; \
+       stxa    %g0, [ t ] ASI_DCACHE_TAG; \
+       membar  #Sync
+/* The following can be used if the pointer is 32-byte aligned */
+#define DLFLUSH2(t) \
+       stxa    %g0, [ t ] ASI_DCACHE_TAG; \
+       membar  #Sync
+#else
+#define DLFLUSH(a,t)
+#define DLFLUSH2(t)
+#endif
+
+
+/*
+ * Combine 2 regs -- used to convert 64-bit ILP32
+ * values to LP64.
+ */
+#define        COMBINE(r1, r2, d)      \
+       sllx    r1, 32, d;      \
+       or      d, r2, d
+
+/*
+ * Split 64-bit value in 1 reg into high and low halves.
+ * Used for ILP32 return values.
+ */
+#define        SPLIT(r0, r1)           \
+       srl     r0, 0, r1;      \
+       srlx    r0, 32, r0
+
+
+/*
+ * A handy macro for maintaining instrumentation counters.
+ * Note that this clobbers %o0, %o1 and %o2.  Normal usage is
+ * something like:
+ *     foointr:
+ *             TRAP_SETUP(...)         ! makes %o registers safe
+ *             INCR(_C_LABEL(cnt)+V_FOO)       ! count a foo
+ */
+#define INCR(what) \
+       sethi   %hi(what), %o0; \
+       or      %o0, %lo(what), %o0; \
+99:    \
+       lduw    [%o0], %o1; \
+       add     %o1, 1, %o2; \
+       casa    [%o0] ASI_P, %o1, %o2; \
+       cmp     %o1, %o2; \
+       bne,pn  %icc, 99b; \
+        nop
+
+/*
+ * A couple of handy macros to save and restore globals to/from
+ * locals.  Since udivrem uses several globals, and it's called
+ * from vsprintf, we need to do this before and after doing a printf.
+ */
+#define GLOBTOLOC \
+       mov     %g1, %l1; \
+       mov     %g2, %l2; \
+       mov     %g3, %l3; \
+       mov     %g4, %l4; \
+       mov     %g5, %l5; \
+       mov     %g6, %l6; \
+       mov     %g7, %l7
+
+#define LOCTOGLOB \
+       mov     %l1, %g1; \
+       mov     %l2, %g2; \
+       mov     %l3, %g3; \
+       mov     %l4, %g4; \
+       mov     %l5, %g5; \
+       mov     %l6, %g6; \
+       mov     %l7, %g7
+
+/* Load strings address into register; NOTE: hidden local label 99 */
+#define LOAD_ASCIZ(reg, s)     \
+       set     99f, reg ;      \
+       .data ;                 \
+99:    .asciz  s ;             \
+       _ALIGN ;                \
+       .text
+
+/*
+ * Handy stack conversion macros.
+ * They correctly switch to requested stack type
+ * regardless of the current stack.
+ */
+
+#define TO_STACK64(size)                                       \
+       save    %sp, size, %sp;                                 \
+       add     %sp, -BIAS, %o0; /* Convert to 64-bits */       \
+       andcc   %sp, 1, %g0; /* 64-bit stack? */                \
+       movz    %icc, %o0, %sp
+
+#define TO_STACK32(size)                                       \
+       save    %sp, size, %sp;                                 \
+       add     %sp, +BIAS, %o0; /* Convert to 32-bits */       \
+       andcc   %sp, 1, %g0; /* 64-bit stack? */                \
+       movnz   %icc, %o0, %sp
+
+#ifdef _LP64
+#define        STACKFRAME(size)        TO_STACK64(size)
+#else
+#define        STACKFRAME(size)        TO_STACK32(size)
+#endif
+
+/*
+ * Primitives
+ */
+#ifdef ENTRY
+#undef ENTRY
+#endif
+
+#ifdef GPROF
+       .globl  _mcount
+#define        ENTRY(x) \
+       .globl _C_LABEL(x); .proc 1; .type _C_LABEL(x),@function; \
+_C_LABEL(x): ; \
+       .data; \
+       .align 8; \
+0:     .uaword 0; .uaword 0; \
+       .text;  \
+       save    %sp, -CC64FSZ, %sp; \
+       sethi   %hi(0b), %o0; \
+       call    _mcount; \
+       or      %o0, %lo(0b), %o0; \
+       restore
+#else
+#define        ENTRY(x)        .globl _C_LABEL(x); .proc 1; \
+       .type _C_LABEL(x),@function; _C_LABEL(x):
+#endif
+#define        ALTENTRY(x)     .globl _C_LABEL(x); _C_LABEL(x):
+
+
diff -r 5cff004a0ca8 -r 80dfaec8aa4d sys/arch/sparc64/sparc64/copy.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sparc64/sparc64/copy.S   Sun May 23 18:49:14 2010 +0000
@@ -0,0 +1,1189 @@
+/*     $NetBSD: copy.S,v 1.1 2010/05/23 18:49:14 martin Exp $  */
+
+/*
+ * Copyright (c) 2006-2010 Matthew R. Green
+ * Copyright (c) 1996-2002 Eduardo Horvath
+ * Copyright (c) 1996 Paul Kranenburg
+ * Copyright (c) 1996
+ *     The President and Fellows of Harvard College.
+ *     All rights reserved.
+ * Copyright (c) 1992, 1993
+ *     The Regents of the University of California.
+ *     All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * 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, Lawrence Berkeley Laboratory.
+ *     This product includes software developed by Harvard University.
+ *
+ * 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.
+ *     This product includes software developed by Harvard University.
+ *     This product includes software developed by Paul Kranenburg.
+ * 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.
+ *
+ *     @(#)locore.s    8.4 (Berkeley) 12/10/93
+ */
+
+
+#include "opt_ddb.h"
+#include "opt_kgdb.h"
+#include "opt_multiprocessor.h"
+#include "opt_compat_netbsd.h"
+#include "opt_compat_netbsd32.h"
+#include "opt_lockdebug.h"
+
+#include "assym.h"
+#include <machine/param.h>
+#include <machine/ctlreg.h>
+#include <machine/asm.h>
+#include <machine/locore.h>
+
+#include "ksyms.h"
+
+       .register       %g2,#scratch
+       .register       %g3,#scratch
+
+/*
+ * copyinstr(fromaddr, toaddr, maxlength, &lencopied)
+ *
+ * Copy a null terminated string from the user address space into
+ * the kernel address space.
+ */
+ENTRY(copyinstr)
+       ! %o0 = fromaddr, %o1 = toaddr, %o2 = maxlen, %o3 = &lencopied
+#ifdef NOTDEF_DEBUG
+       save    %sp, -CC64FSZ, %sp
+       set     8f, %o0
+       mov     %i0, %o1
+       mov     %i1, %o2
+       mov     %i2, %o3
+       call    printf
+        mov    %i3, %o4
+       restore
+       .data
+8:     .asciz  "copyinstr: from=%x to=%x max=%x &len=%x\n"
+       _ALIGN



Home | Main Index | Thread Index | Old Index