Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm Add core locator to mainbus. Add support for a...



details:   https://anonhg.NetBSD.org/src/rev/1c451cf0e052
branches:  trunk
changeset: 781272:1c451cf0e052
user:      matt <matt%NetBSD.org@localhost>
date:      Wed Aug 29 23:16:35 2012 +0000

description:
Add core locator to mainbus.  Add support for attaching multiple CPUs

diffstat:

 sys/arch/arm/conf/files.arm        |   4 +-
 sys/arch/arm/mainbus/cpu_mainbus.c |  53 +++++++++++++++++++++++++++----------
 sys/arch/arm/mainbus/mainbus.c     |   7 +++-
 sys/arch/arm/mainbus/mainbus.h     |   3 +-
 4 files changed, 47 insertions(+), 20 deletions(-)

diffs (161 lines):

diff -r 6abe5b268830 -r 1c451cf0e052 sys/arch/arm/conf/files.arm
--- a/sys/arch/arm/conf/files.arm       Wed Aug 29 23:10:31 2012 +0000
+++ b/sys/arch/arm/conf/files.arm       Wed Aug 29 23:16:35 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.arm,v 1.109 2012/08/29 07:14:04 matt Exp $
+#      $NetBSD: files.arm,v 1.110 2012/08/29 23:16:35 matt Exp $
 
 # temporary define to allow easy moving to ../arch/arm/arm32
 defflag                                ARM32
@@ -78,7 +78,7 @@
 file   arch/arm/arm/fiq_subr.S
 
 # mainbus files
-device mainbus { [base = -1], [size = 0], [dack = -1], [irq = -1], [intrbase = -1] }
+device mainbus { [base = -1], [size = 0], [dack = -1], [irq = -1], [intrbase = -1], [core = -1] }
 attach mainbus at root
 file   arch/arm/mainbus/mainbus.c              mainbus & arm32
 file   arch/arm/mainbus/mainbus_io.c           mainbus & arm32
diff -r 6abe5b268830 -r 1c451cf0e052 sys/arch/arm/mainbus/cpu_mainbus.c
--- a/sys/arch/arm/mainbus/cpu_mainbus.c        Wed Aug 29 23:10:31 2012 +0000
+++ b/sys/arch/arm/mainbus/cpu_mainbus.c        Wed Aug 29 23:16:35 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu_mainbus.c,v 1.12 2012/08/29 17:44:25 matt Exp $    */
+/*     $NetBSD: cpu_mainbus.c,v 1.13 2012/08/29 23:16:35 matt Exp $    */
 
 /*
  * Copyright (c) 1995 Mark Brinicombe.
@@ -41,24 +41,18 @@
  * Created      : 10/10/95
  */
 
+#include "locators.h"
+
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_mainbus.c,v 1.12 2012/08/29 17:44:25 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_mainbus.c,v 1.13 2012/08/29 23:16:35 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
+#include <sys/cpu.h>
 #include <sys/device.h>
 #include <sys/proc.h>
-#if 0
-#include <sys/conf.h>
-#include <uvm/uvm_extern.h>
-#include <machine/io.h>
-#endif
-#include <machine/cpu.h>
-#if 0
-#include <arm/cpus.h>
-#include <arm/undefined.h>
-#endif
+
+#include <arm/mainbus/mainbus.h>
 
 /*
  * Prototypes
@@ -72,11 +66,38 @@
  * Probe for the main cpu. Currently all this does is return 1 to
  * indicate that the cpu was found.
  */ 
+#ifdef MULTIPROCESSOR
+extern u_int arm_cpu_max;
+#else
+#define        arm_cpu_max             0
+#endif
  
 static int
 cpu_mainbus_match(device_t parent, cfdata_t cf, void *aux)
 {
-       return(1);
+       struct mainbus_attach_args * const mb = aux;
+       int id = mb->mb_core;
+
+       if (id != MAINBUSCF_CORE_DEFAULT) {
+               if (id > arm_cpu_max || kcpuset_isset(kcpuset_attached, id))
+                       return 0;
+               if (id == 0 && cpu_info_store.ci_dev != NULL)
+                       return 0;
+               return 1;
+       }
+
+       for (id = 0; id <= arm_cpu_max; id++) {
+#ifdef MULTIPROCESSOR
+               if (cpu_info[id] != NULL && cpu_info[id]->ci_dev != NULL)
+                       continue;
+#else
+               if (id != 0 || cpu_info_store.ci_dev != NULL)
+                       continue;
+#endif
+               mb->mb_core = id;
+               return 1;
+       }
+       return 0;
 }
 
 /*
@@ -88,7 +109,9 @@
 static void
 cpu_mainbus_attach(device_t parent, device_t self, void *aux)
 {
-       cpu_attach(self, 0);
+       struct mainbus_attach_args * const mb = aux;
+
+       cpu_attach(self, mb->mb_core);
 }
 
 CFATTACH_DECL_NEW(cpu_mainbus, 0,
diff -r 6abe5b268830 -r 1c451cf0e052 sys/arch/arm/mainbus/mainbus.c
--- a/sys/arch/arm/mainbus/mainbus.c    Wed Aug 29 23:10:31 2012 +0000
+++ b/sys/arch/arm/mainbus/mainbus.c    Wed Aug 29 23:16:35 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mainbus.c,v 1.19 2012/07/14 07:57:26 matt Exp $ */
+/* $NetBSD: mainbus.c,v 1.20 2012/08/29 23:16:35 matt Exp $ */
 
 /*
  * Copyright (c) 1994,1995 Mark Brinicombe.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.19 2012/07/14 07:57:26 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.20 2012/08/29 23:16:35 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -110,6 +110,8 @@
                aprint_normal(" irq %d", mb->mb_irq);
        if (mb->mb_drq != -1)
                aprint_normal(" drq 0x%08x", mb->mb_drq);
+       if (mb->mb_core != MAINBUSCF_CORE_DEFAULT)
+               aprint_normal(" core %d", mb->mb_core);
 
 /* XXXX print flags */
        return (QUIET);
@@ -142,6 +144,7 @@
                        mb.mb_drq = cf->cf_loc[MAINBUSCF_DACK];
                        mb.mb_irq = cf->cf_loc[MAINBUSCF_IRQ];
                }
+               mb.mb_core = cf->cf_loc[MAINBUSCF_CORE];
                mb.mb_intrbase = cf->cf_loc[MAINBUSCF_INTRBASE];
                mb.mb_iot = &mainbus_bs_tag;
 
diff -r 6abe5b268830 -r 1c451cf0e052 sys/arch/arm/mainbus/mainbus.h
--- a/sys/arch/arm/mainbus/mainbus.h    Wed Aug 29 23:10:31 2012 +0000
+++ b/sys/arch/arm/mainbus/mainbus.h    Wed Aug 29 23:16:35 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mainbus.h,v 1.3 2012/07/14 07:57:26 matt Exp $ */
+/* $NetBSD: mainbus.h,v 1.4 2012/08/29 23:16:35 matt Exp $ */
 
 /*
  * Copyright (c) 1994,1995 Mark Brinicombe.
@@ -53,6 +53,7 @@
        int             mb_irq;         /* interrupt request */
        int             mb_drq;         /* DMA request */
        int             mb_intrbase;    /* interrupt numbering base */
+       int             mb_core;        /* cpu core # */
        void            *mb_aux;        /* driver specific */
        bus_space_tag_t mb_iot;         /* bus space tag */
 };



Home | Main Index | Thread Index | Old Index