From owner-svn-src-head@FreeBSD.ORG Mon May 7 04:36:48 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D39211065673; Mon, 7 May 2012 04:36:48 +0000 (UTC) (envelope-from jmallett@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BE3D58FC08; Mon, 7 May 2012 04:36:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q474amWp046585; Mon, 7 May 2012 04:36:48 GMT (envelope-from jmallett@svn.freebsd.org) Received: (from jmallett@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q474amCk046581; Mon, 7 May 2012 04:36:48 GMT (envelope-from jmallett@svn.freebsd.org) Message-Id: <201205070436.q474amCk046581@svn.freebsd.org> From: Juli Mallett Date: Mon, 7 May 2012 04:36:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235118 - in head/sys/mips: conf gxemul X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 May 2012 04:36:48 -0000 Author: jmallett Date: Mon May 7 04:36:48 2012 New Revision: 235118 URL: http://svn.freebsd.org/changeset/base/235118 Log: Add basic SMP support for GXemul. Ideally we would have some way to override some of the IPI mechanisms used by the common MIPS SMP code so we could use the multicast IPI facilities, on GXemul as well as on several real hardware platforms, and the ability to have multiple hard IPI types. Modified: head/sys/mips/conf/GXEMUL head/sys/mips/gxemul/gxemul_machdep.c head/sys/mips/gxemul/mpreg.h Modified: head/sys/mips/conf/GXEMUL ============================================================================== --- head/sys/mips/conf/GXEMUL Mon May 7 04:15:46 2012 (r235117) +++ head/sys/mips/conf/GXEMUL Mon May 7 04:36:48 2012 (r235118) @@ -26,6 +26,9 @@ makeoptions MODULES_OVERRIDE="" options DDB options KDB +# Make an SMP-capable kernel by default +options SMP # Symmetric MultiProcessor Kernel + options SCHED_ULE options INET # InterNETworking options INET6 # IPv6 communications protocols Modified: head/sys/mips/gxemul/gxemul_machdep.c ============================================================================== --- head/sys/mips/gxemul/gxemul_machdep.c Mon May 7 04:15:46 2012 (r235117) +++ head/sys/mips/gxemul/gxemul_machdep.c Mon May 7 04:36:48 2012 (r235118) @@ -62,6 +62,11 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef SMP +#include +#include +#endif + #include extern int *edata; @@ -167,3 +172,67 @@ platform_start(__register_t a0, __regist mips_timer_init_params(platform_counter_freq, 0); } + +#ifdef SMP +void +platform_ipi_send(int cpuid) +{ + GXEMUL_MP_DEV_WRITE(GXEMUL_MP_DEV_IPI_ONE, (1 << 16) | cpuid); +} + +void +platform_ipi_clear(void) +{ + GXEMUL_MP_DEV_WRITE(GXEMUL_MP_DEV_IPI_READ, 0); +} + +int +platform_ipi_intrnum(void) +{ + return (GXEMUL_MP_DEV_IPI_INTERRUPT - 2); +} + +struct cpu_group * +platform_smp_topo(void) +{ + return (smp_topo_none()); +} + +void +platform_init_ap(int cpuid) +{ + int ipi_int_mask, clock_int_mask; + + /* + * Unmask the clock and ipi interrupts. + */ + clock_int_mask = hard_int_mask(5); + ipi_int_mask = hard_int_mask(platform_ipi_intrnum()); + set_intr_mask(ipi_int_mask | clock_int_mask); +} + +void +platform_cpu_mask(cpuset_t *mask) +{ + unsigned i, n; + + n = GXEMUL_MP_DEV_READ(GXEMUL_MP_DEV_NCPUS); + CPU_ZERO(mask); + for (i = 0; i < n; i++) + CPU_SET(i, mask); +} + +int +platform_processor_id(void) +{ + return (GXEMUL_MP_DEV_READ(GXEMUL_MP_DEV_WHOAMI)); +} + +int +platform_start_ap(int cpuid) +{ + GXEMUL_MP_DEV_WRITE(GXEMUL_MP_DEV_STARTADDR, (intptr_t)mpentry); + GXEMUL_MP_DEV_WRITE(GXEMUL_MP_DEV_START, cpuid); + return (0); +} +#endif /* SMP */ Modified: head/sys/mips/gxemul/mpreg.h ============================================================================== --- head/sys/mips/gxemul/mpreg.h Mon May 7 04:15:46 2012 (r235117) +++ head/sys/mips/gxemul/mpreg.h Mon May 7 04:36:48 2012 (r235118) @@ -36,10 +36,12 @@ #define GXEMUL_MP_DEV_START 0x0020 #define GXEMUL_MP_DEV_STARTADDR 0x0030 #define GXEMUL_MP_DEV_STACK 0x0070 +#define GXEMUL_MP_DEV_RANDOM 0x0080 #define GXEMUL_MP_DEV_MEMORY 0x0090 #define GXEMUL_MP_DEV_IPI_ONE 0x00a0 #define GXEMUL_MP_DEV_IPI_MANY 0x00b0 #define GXEMUL_MP_DEV_IPI_READ 0x00c0 +#define GXEMUL_MP_DEV_CYCLES 0x00d0 #define GXEMUL_MP_DEV_FUNCTION(f) \ (volatile uint64_t *)MIPS_PHYS_TO_DIRECT_UNCACHED(GXEMUL_MP_DEV_BASE + (f))