Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm Make cpu_reset, most of initarm and the kvm ini...



details:   https://anonhg.NetBSD.org/src/rev/36a57e3bbeb3
branches:  trunk
changeset: 781312:36a57e3bbeb3
user:      matt <matt%NetBSD.org@localhost>
date:      Fri Aug 31 23:59:51 2012 +0000

description:
Make cpu_reset, most of initarm and the kvm init code common.
Add MP hooks for cpu_need_resced
Add idlestck which is allocated in arm32_kvminit

diffstat:

 sys/arch/arm/arm/arm_machdep.c       |   67 ++-
 sys/arch/arm/arm32/arm32_boot.c      |  354 ++++++++++++++
 sys/arch/arm/arm32/arm32_kvminit.c   |  866 +++++++++++++++++++++++++++++++++++
 sys/arch/arm/arm32/arm32_machdep.c   |  105 +++-
 sys/arch/arm/arm32/arm32_reboot.c    |  191 +++++++
 sys/arch/arm/arm32/genassym.cf       |    6 +-
 sys/arch/arm/include/arm32/machdep.h |   40 +-
 sys/arch/arm/include/bootconfig.h    |   10 +-
 8 files changed, 1606 insertions(+), 33 deletions(-)

diffs (truncated from 1822 to 300 lines):

diff -r 2ed27f073e7c -r 36a57e3bbeb3 sys/arch/arm/arm/arm_machdep.c
--- a/sys/arch/arm/arm/arm_machdep.c    Fri Aug 31 23:56:15 2012 +0000
+++ b/sys/arch/arm/arm/arm_machdep.c    Fri Aug 31 23:59:51 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arm_machdep.c,v 1.35 2012/08/29 23:10:31 matt Exp $    */
+/*     $NetBSD: arm_machdep.c,v 1.36 2012/08/31 23:59:51 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.35 2012/08/29 23:10:31 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm_machdep.c,v 1.36 2012/08/31 23:59:51 matt Exp $");
 
 #include <sys/exec.h>
 #include <sys/proc.h>
@@ -87,6 +87,8 @@
 #include <sys/ucontext.h>
 #include <sys/evcnt.h>
 #include <sys/cpu.h>
+#include <sys/atomic.h>
+#include <sys/kcpuset.h>
 
 #ifdef EXEC_AOUT
 #include <sys/exec_aout.h>
@@ -211,20 +213,73 @@
 void
 cpu_need_resched(struct cpu_info *ci, int flags)
 {
-       bool immed = (flags & RESCHED_IMMED) != 0;
+       struct lwp * const l = ci->ci_data.cpu_onproc;
+       const bool immed = (flags & RESCHED_IMMED) != 0;
+#ifdef MULTIPROCESSOR
+       struct cpu_info * const cur_ci = curcpu();
+       u_long ipi = IPI_NOP;
+#endif
 
+       if (__predict_false((l->l_pflag & LP_INTR) != 0)) {
+               /*
+                * No point doing anything, it will switch soon.
+                * Also here to prevent an assertion failure in
+                * kpreempt() due to preemption being set on a
+                * soft interrupt LWP.
+                */
+               return;
+       }
        if (ci->ci_want_resched && !immed)
                return;
 
+       if (l == ci->ci_data.cpu_idlelwp) {
+#ifdef MULTIPROCESSOR
+               /*
+                * If the other CPU is idling, it must be waiting for an
+                * event.  So give it one.
+                */
+               if (ci != cur_ci)
+                       goto send_ipi;
+#endif
+               return;
+       }
+#ifdef MULTIPROCESSOR
+       atomic_swap_uint(&ci->ci_want_resched, 1);
+#else
        ci->ci_want_resched = 1;
-       if (curlwp != ci->ci_data.cpu_idlelwp)
-               setsoftast();
+#endif
+       if (flags & RESCHED_KPREEMPT) {
+#ifdef __HAVE_PREEMPTION
+               atomic_or_uint(&l->l_dopreempt, DOPREEMPT_ACITBE);
+               if (ci == cur_ci) {
+                       softint_trigger(SOFTINT_KPREEMPT);
+               } else {
+                       ipi = IPI_KPREEMPT;
+                       goto send_ipi;
+               }
+#endif /* __HAVE_PREEMPTION */
+               return;
+       }
+       ci->ci_astpending = 1;
+#ifdef MULTIPROCESSOR
+       if (ci == curcpu() || !immed)
+               return;
+       ipi = IPI_AST;
+
+   send_ipi:
+       intr_ipi_send(ci->ci_kcpuset, ipi);
+#endif /* MULTIPROCESSOR */
 }
 
 bool
 cpu_intr_p(void)
 {
-       return curcpu()->ci_intr_depth != 0;
+       struct cpu_info * const ci = curcpu();
+#ifdef __HAVE_PIC_FAST_SOFTINTS
+       if (ci->ci_cpl < IPL_VM)
+               return false;
+#endif
+       return ci->ci_intr_depth != 0;
 }
 
 void
diff -r 2ed27f073e7c -r 36a57e3bbeb3 sys/arch/arm/arm32/arm32_boot.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/arm32/arm32_boot.c   Fri Aug 31 23:59:51 2012 +0000
@@ -0,0 +1,354 @@
+/*     $NetBSD: arm32_boot.c,v 1.1 2012/08/31 23:59:51 matt Exp $      */
+
+/*
+ * Copyright (c) 2002, 2003, 2005  Genetec Corporation.  All rights reserved.
+ * Written by Hiroyuki Bessho for Genetec Corporation.
+ *
+ * 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. The name of Genetec Corporation may not be used to endorse or
+ *    promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``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 GENETEC CORPORATION
+ * 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) 2001 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Jason R. Thorpe for Wasabi Systems, Inc.
+ *
+ * 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 for the NetBSD Project by
+ *     Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ *    or promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
+ * 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) 1997,1998 Mark Brinicombe.
+ * Copyright (c) 1997,1998 Causality Limited.
+ * 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
+ *     for the NetBSD Project.
+ * 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.
+ *
+ * Copyright (c) 2007 Microsoft
+ * 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 Microsoft
+ *
+ * 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 CONTRIBUTERS 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.
+ */
+
+#include <sys/cdefs.h>
+
+__KERNEL_RCSID(1, "$NetBSD: arm32_boot.c,v 1.1 2012/08/31 23:59:51 matt Exp $");
+
+#include <sys/param.h>
+#include <sys/reboot.h>
+#include <sys/cpu.h>
+#include <sys/intr.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <arm/undefined.h>
+#include <arm/arm32/machdep.h>
+
+#include <machine/db_machdep.h>
+#include <ddb/db_extern.h>
+
+#include <machine/bootconfig.h>
+
+vaddr_t
+initarm_common(vaddr_t kvm_base, vsize_t kvm_size,
+       const struct boot_physmem *bp, size_t nbp)
+{
+       struct bootmem_info * const bmi = &bootmem_info;
+
+#ifdef VERBOSE_INIT_ARM
+       printf("nfreeblocks = %u, free_pages = %d (%#x)\n",
+           bmi->bmi_nfreeblocks, bmi->bmi_freepages,
+           bmi->bmi_freepages);
+#endif
+
+       /*
+        * Moved from cpu_startup() as data_abort_handler() references
+        * this during uvm init.
+        */
+       uvm_lwp_setuarea(&lwp0, kernelstack.pv_va);
+
+#ifdef VERBOSE_INIT_ARM
+       printf("bootstrap done.\n");
+#endif
+
+       arm32_vector_init(systempage.pv_va, ARM_VEC_ALL);
+
+       /*
+        * Pages were allocated during the secondary bootstrap for the
+        * stacks for different CPU modes.
+        * We must now set the r13 registers in the different CPU modes to
+        * point to these stacks.
+        * Since the ARM stacks use STMFD etc. we must set r13 to the top end
+        * of the stack memory.
+        */
+#ifdef VERBOSE_INIT_ARM
+       printf("init subsystems: stacks ");
+#endif
+       set_stackptr(PSR_FIQ32_MODE,
+           fiqstack.pv_va + FIQ_STACK_SIZE * PAGE_SIZE);
+       set_stackptr(PSR_IRQ32_MODE,
+           irqstack.pv_va + IRQ_STACK_SIZE * PAGE_SIZE);
+       set_stackptr(PSR_ABT32_MODE,
+           abtstack.pv_va + ABT_STACK_SIZE * PAGE_SIZE);
+       set_stackptr(PSR_UND32_MODE,
+           undstack.pv_va + UND_STACK_SIZE * PAGE_SIZE);
+
+       /*
+        * Well we should set a data abort handler.
+        * Once things get going this will change as we will need a proper
+        * handler.
+        * Until then we will use a handler that just panics but tells us



Home | Main Index | Thread Index | Old Index