Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Rename ARM options PROCESS_ID_IS_CUR{CPU, LWP} to TP...



details:   https://anonhg.NetBSD.org/src/rev/f346e33a66c4
branches:  trunk
changeset: 781238:f346e33a66c4
user:      matt <matt%NetBSD.org@localhost>
date:      Wed Aug 29 07:14:03 2012 +0000

description:
Rename ARM options PROCESS_ID_IS_CUR{CPU,LWP} to TPIDRPRW_IS_CUR{CPU,LWP}
since TPIDRPRW is the cp15 register name.
Initialize it early in start along with CI_ARM_CPUID.
Remove other initializations.
We alays have ci_curlwp.
Enable TIPRPRW_IS_CURCPU in std.beagle.
[tested on a beaglboard (cortex-a8)]

diffstat:

 sys/arch/arm/arm/arm_machdep.c     |   6 +---
 sys/arch/arm/arm/cpufunc.c         |  36 +---------------------------
 sys/arch/arm/arm32/cpuswitch.S     |  47 +++++++++++++++++++++----------------
 sys/arch/arm/arm32/locore.S        |  41 +++++++++++++++++++++------------
 sys/arch/arm/conf/files.arm        |   6 ++--
 sys/arch/arm/include/cpu.h         |  12 ++++-----
 sys/arch/evbarm/conf/std.beagle    |   4 +-
 sys/arch/evbarm/conf/std.igepv2    |   4 +-
 sys/arch/evbarm/conf/std.overo     |   4 +-
 sys/arch/evbarm/conf/std.tisdp24xx |   6 ++--
 10 files changed, 73 insertions(+), 93 deletions(-)

diffs (truncated from 482 to 300 lines):

diff -r 1b6a4241aa35 -r f346e33a66c4 sys/arch/arm/arm/arm_machdep.c
--- a/sys/arch/arm/arm/arm_machdep.c    Wed Aug 29 07:09:12 2012 +0000
+++ b/sys/arch/arm/arm/arm_machdep.c    Wed Aug 29 07:14:03 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arm_machdep.c,v 1.33 2012/08/16 17:35:01 matt Exp $    */
+/*     $NetBSD: arm_machdep.c,v 1.34 2012/08/29 07:14:03 matt Exp $    */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -78,7 +78,7 @@
 
 #include <sys/param.h>
 
-__KERNEL_RCSID(0, "$NetBSD: arm_machdep.c,v 1.33 2012/08/16 17:35:01 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm_machdep.c,v 1.34 2012/08/29 07:14:03 matt Exp $");
 
 #include <sys/exec.h>
 #include <sys/proc.h>
@@ -103,9 +103,7 @@
 /* Our exported CPU info; we can have only one. */
 struct cpu_info cpu_info_store = {
        .ci_cpl = IPL_HIGH,
-#ifndef PROCESS_ID_IS_CURLWP
        .ci_curlwp = &lwp0,
-#endif
 };
 
 const pcu_ops_t * const pcu_ops_md_defs[PCU_UNIT_COUNT] = {
diff -r 1b6a4241aa35 -r f346e33a66c4 sys/arch/arm/arm/cpufunc.c
--- a/sys/arch/arm/arm/cpufunc.c        Wed Aug 29 07:09:12 2012 +0000
+++ b/sys/arch/arm/arm/cpufunc.c        Wed Aug 29 07:14:03 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpufunc.c,v 1.110 2012/08/16 18:22:38 matt Exp $       */
+/*     $NetBSD: cpufunc.c,v 1.111 2012/08/29 07:14:03 matt Exp $       */
 
 /*
  * arm7tdmi support code Copyright (c) 2001 John Fremlin
@@ -49,7 +49,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.110 2012/08/16 18:22:38 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.111 2012/08/29 07:14:03 matt Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_cpuoptions.h"
@@ -2697,14 +2697,6 @@
 {
        int cpuctrl, cpuctrlmask;
 
-#if defined(PROCESS_ID_IS_CURCPU)
-       /* set curcpu() */
-       __asm("mcr\tp15, 0, %0, c13, c0, 4" : : "r"(&cpu_info_store));
-#elif defined(PROCESS_ID_IS_CURLWP)
-       /* set curlwp() */
-       __asm("mcr\tp15, 0, %0, c13, c0, 4" : : "r"(&lwp0));
-#endif
-
        cpuctrl = CPU_CONTROL_MMU_ENABLE | CPU_CONTROL_SYST_ENABLE
            | CPU_CONTROL_IC_ENABLE | CPU_CONTROL_DC_ENABLE
            /* | CPU_CONTROL_BPRD_ENABLE */;
@@ -2752,14 +2744,6 @@
 {
        int cpuctrl, cpuctrlmask;
 
-#if defined(PROCESS_ID_IS_CURCPU)
-       /* set curcpu() */
-       __asm("mcr\tp15, 0, %0, c13, c0, 4" : : "r"(&cpu_info_store));
-#elif defined(PROCESS_ID_IS_CURLWP)
-       /* set curlwp() */
-       __asm("mcr\tp15, 0, %0, c13, c0, 4" : : "r"(&lwp0));
-#endif
-
        cpuctrl = CPU_CONTROL_IC_ENABLE
            | CPU_CONTROL_DC_ENABLE
            | CPU_CONTROL_BPRD_ENABLE ;
@@ -2815,14 +2799,6 @@
 {
        int cpuctrl, cpuctrlmask;
 
-#if defined(PROCESS_ID_IS_CURCPU)
-       /* set curcpu() */
-       __asm("mcr\tp15, 0, %0, c13, c0, 4" : : "r"(&cpu_info_store));
-#elif defined(PROCESS_ID_IS_CURLWP)
-       /* set curlwp() */
-       __asm("mcr\tp15, 0, %0, c13, c0, 4" : : "r"(&lwp0));
-#endif
-
        cpuctrl = CPU_CONTROL_MMU_ENABLE | CPU_CONTROL_IC_ENABLE
            | CPU_CONTROL_DC_ENABLE | CPU_CONTROL_BPRD_ENABLE ;
        cpuctrlmask = CPU_CONTROL_MMU_ENABLE | CPU_CONTROL_SYST_ENABLE
@@ -2911,14 +2887,6 @@
        uint32_t sbz=0;
        uint32_t cpuid;
 
-#if defined(PROCESS_ID_IS_CURCPU)
-       /* set curcpu() */
-       __asm("mcr\tp15, 0, %0, c13, c0, 4" : : "r"(&cpu_info_store));
-#elif defined(PROCESS_ID_IS_CURLWP)
-       /* set curlwp() */
-       __asm("mcr\tp15, 0, %0, c13, c0, 4" : : "r"(&lwp0));
-#endif
-
        cpuid = cpu_id();
 
        cpuctrl =
diff -r 1b6a4241aa35 -r f346e33a66c4 sys/arch/arm/arm32/cpuswitch.S
--- a/sys/arch/arm/arm32/cpuswitch.S    Wed Aug 29 07:09:12 2012 +0000
+++ b/sys/arch/arm/arm32/cpuswitch.S    Wed Aug 29 07:14:03 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpuswitch.S,v 1.66 2012/08/16 17:35:01 matt Exp $      */
+/*     $NetBSD: cpuswitch.S,v 1.67 2012/08/29 07:14:04 matt Exp $      */
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -89,7 +89,7 @@
 #include <machine/asm.h>
 #include <machine/cpu.h>
 
-       RCSID("$NetBSD: cpuswitch.S,v 1.66 2012/08/16 17:35:01 matt Exp $")
+       RCSID("$NetBSD: cpuswitch.S,v 1.67 2012/08/29 07:14:04 matt Exp $")
 
 /* LINTSTUB: include <sys/param.h> */
        
@@ -140,9 +140,9 @@
        mov     r6, r1
        mov     r4, r0
 
-#ifdef PROCESS_ID_CURCPU
+#ifdef TPIDRPRW_ID_IS_CURCPU
        GET_CURCPU(r7)
-#elif defined(PROCESS_ID_IS_CURLWP)
+#elif defined(TPIDRPRW_IS_CURLWP)
        mcr     p15, 0, r0, c13, c0, 4          /* get old lwp (r4 maybe 0) */
        ldr     r7, [r0, #(L_CPU)]              /* get cpu from old lwp */
 #elif !defined(MULTIPROCESSOR) 
@@ -165,13 +165,11 @@
        /* l->l_cpu initialized in fork1() for single-processor */
 #endif
 
-#if defined(PROCESS_ID_IS_CURLWP)
+#if defined(TPIDRPRW_IS_CURLWP)
        mcr     p15, 0, r6, c13, c0, 4          /* set current lwp */
 #endif
-#if !defined(PROCESS_ID_IS_CURLWP) || defined(MULTIPROCESSOR)
        /* We have a new curlwp now so make a note it */
        str     r6, [r7, #(CI_CURLWP)]
-#endif
 
        /* Get the new pcb */
        ldr     r7, [r6, #(L_PCB)]
@@ -305,6 +303,10 @@
        /* lwp_trampoline expects new lwp as it's second argument */
        mov     r1, r6
 
+#ifdef _ARM_ARCH_7
+       clrex                           /* cause any subsequent STREX* to fail */
+#endif
+
        /*
         * Pull the registers that got pushed when cpu_switchto() was called,
         * and return.
@@ -323,22 +325,29 @@
 ENTRY(lwp_trampoline)
        /*
         * cpu_switchto gives us:
-        *
-        * arg0(r0) = old lwp
-        * arg1(r1) = new lwp
+        *      arg0(r0) = old lwp
+        *      arg1(r1) = new lwp
+        * setup by cpu_lwp_fork:
+        *      r4 = func to call
+        *      r5 = arg to func
+        *      r6 = <unused>
+        *      r7 = spsr mode
         */
        bl      _C_LABEL(lwp_startup)
 
        mov     r0, r5
        mov     r1, sp
+#ifdef _ARM_ARCH_4T
+       blx     r4
+#else
        mov     lr, pc
        mov     pc, r4
+#endif
 
-       /* Kill irq's */
-        mrs     r0, cpsr
-        orr     r0, r0, #(IF32_bits)
-        msr     cpsr_c, r0
+       GET_CPSR(r0)
+       CPSID_I(r0, r0)                 /* Kill irq's */
 
+       DO_AST_AND_RESTORE_ALIGNMENT_FAULTS
        PULLFRAME
 
        movs    pc, lr                  /* Exit */
@@ -353,7 +362,7 @@
        stmfd   sp!, {r4, r6, r7, lr}
 
        ldr     r7, [r0, #L_CPU]                /* get curcpu */
-#if defined(PROCESS_ID_IS_CURLWP)
+#if defined(TPIDRPRW_IS_CURLWP)
        mrc     p15, 0, r4, c13, c0, 4          /* get old lwp */
 #else
        ldr     r4, [r7, #(CI_CURLWP)]          /* get old lwp */
@@ -391,12 +400,10 @@
        /*
         * We're switching to a bound LWP so its l_cpu is already correct.
         */
-#if defined(PROCESS_ID_IS_CURLWP)
+#if defined(TPIDRPRW_IS_CURLWP)
        mcr     p15, 0, r5, c13, c0, 4          /* save new lwp */
 #endif
-#if !defined(PROCESS_ID_IS_CURLWP) || defined(MULTIPROCESSOR)
        str     r5, [r7, #(CI_CURLWP)]          /* save new lwp */
-#endif
 
        /*
         * Normally, we'd get {r8-r13} but since this is a softint lwp
@@ -426,12 +433,10 @@
         * never executed.  But we do need the SP from the formerly pinned lwp.
         */
 
-#if defined(PROCESS_ID_IS_CURLWP)
+#if defined(TPIDRPRW_IS_CURLWP)
        mcr     p15, 0, r4, c13, c0, 4          /* restore pinned lwp */
 #endif
-#if !defined(PROCESS_ID_IS_CURLWP) || defined(MULTIPROCESSOR)
        str     r4, [r7, #(CI_CURLWP)]          /* restore pinned lwp */
-#endif
        ldr     sp, [r2, #(PCB_SP)]     /* now running on the old stack. */
 
        /* At this point we can allow IRQ's again. */
diff -r 1b6a4241aa35 -r f346e33a66c4 sys/arch/arm/arm32/locore.S
--- a/sys/arch/arm/arm32/locore.S       Wed Aug 29 07:09:12 2012 +0000
+++ b/sys/arch/arm/arm32/locore.S       Wed Aug 29 07:14:03 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.26 2012/08/16 18:22:40 matt Exp $ */
+/*     $NetBSD: locore.S,v 1.27 2012/08/29 07:14:04 matt Exp $ */
 
 /*
  * Copyright (C) 1994-1997 Mark Brinicombe
@@ -42,7 +42,7 @@
 /* What size should this really be ? It is only used by init_arm() */
 #define INIT_ARM_STACK_SIZE    2048
 
-       RCSID("$NetBSD: locore.S,v 1.26 2012/08/16 18:22:40 matt Exp $")
+       RCSID("$NetBSD: locore.S,v 1.27 2012/08/29 07:14:04 matt Exp $")
 
 /*
  * This is for kvm_mkdb, and should be the address of the beginning
@@ -56,12 +56,11 @@
 
 ASENTRY_NP(start)
        adr     r1, .Lstart
-       ldmia   r1, {r1, r2, sp}        /* Set initial stack and */
-       sub     r2, r2, r1              /* get zero init data */
+       ldmia   r1, {r1, r2, r8, sp}    /* Set initial stack and */
+       sub     r2, r2, r1              /* get zero init data and cpu_info_store */
 
-#ifdef PROCESS_ID_IS_CURCPU
-       ldr     r3, .Lcpu_info_store
-       mcr     p15, 0, r3, c13, c0, 4
+#if defined(TPIDRPRW_IS_CURCPU) || defined(TPIDRPRW_IS_CURLWP)
+       mcr     p15, 0, r8, c13, c0, 4
 #endif
 
        mov     r3, #0
@@ -70,6 +69,9 @@
        subs    r2, r2, #4
        bgt     .L1
 
+       mrc     p15, 0, r3, c0, c0, 0   /* get our cpuid and save it early */
+       str     r3, [r8, #CI_ARM_CPUID]
+
        mov     fp, #0x00000000         /* trace back starts here */
        bl      _C_LABEL(initarm)       /* Off we go */
 
@@ -87,14 +89,16 @@
        b       _C_LABEL(panic)
        /* NOTREACHED */
 
-#ifdef PROCESS_ID_IS_CURCPU
-.Lcpu_info_store:      
-       .word   _C_LABEL(cpu_info_store)
-#endif
-
 .Lstart:
        .word   _edata
        .word   _end
+#if defined(TPIDRPRW_IS_CURCPU)
+       .word   _C_LABEL(cpu_info_store)
+#elif defined(TPIDRPRW_IS_CURLWP)
+       .word   _C_LABEL(lwp0)
+#else
+       .word   0
+#endif



Home | Main Index | Thread Index | Old Index