Add SMP support for all architectures.

tested on sparc64 by martin
This commit is contained in:
pooka 2011-01-04 16:23:35 +00:00
parent 6152a60b95
commit a9dcf542ce
4 changed files with 26 additions and 29 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.h,v 1.13 2010/12/02 21:20:39 pooka Exp $ */
/* $NetBSD: cpu.h,v 1.14 2011/01/04 16:23:35 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -40,6 +40,8 @@ struct cpu_info {
cpuid_t ci_cpuid;
struct lwp *ci_curlwp;
struct cpu_info *ci_next;
/*
* XXX: horrible workaround for vax lock.h.
* I eventually want to nuke rump include/machine, so don't waste
@ -77,7 +79,14 @@ struct lwp *rumpuser_get_curlwp(void);
#define curlwp rumpuser_get_curlwp()
#define curcpu() (curlwp->l_cpu)
#define cpu_number() 0 /* XXX: not good enuf */
#define cpu_number() (cpu_index(curcpu))
extern struct cpu_info *rumpcpu_info_list;
#define CPU_INFO_ITERATOR int
#define CPU_INFO_FOREACH(_cii_, _ci_) _cii_ = 0, _ci_ = rumpcpu_info_list; \
_ci_ != NULL; _ci_ = _ci_->ci_next
#define CPU_IS_PRIMARY(_ci_) (_ci_->ci_index == 0)
#endif /* !_LOCORE */

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.rumpkern,v 1.104 2010/12/17 00:53:16 joerg Exp $
# $NetBSD: Makefile.rumpkern,v 1.105 2011/01/04 16:23:36 pooka Exp $
#
.include "${RUMPTOP}/Makefile.rump"
@ -25,12 +25,6 @@ SRCS+= compat.c
SRCS+= locks.c
#SRCS+= locks_up.c
# Does the arch support multiple processors?
.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
RUMP_SMP= # defined
CPPFLAGS.rump.c+= -DRUMP_SMP
.endif
MKREPRO?=no
.if ${MKREPRO} == "yes"
@ -180,20 +174,14 @@ KERNMISCCPPFLAGS+= -D_RUMPKERNEL
# Some architectures require a little special massage with atomic
# compare-and-swap. This is because the kernel version is using
# instructions or routines unavailable to us in userspace. We
# use a very simple CAS routine which (correctly) assumes non-SMP
# and no preemption. If some of these archs later develop MP
# support, switch them to use atomic_cas_generic.c
# instructions or routines unavailable to us in userspace.
#
.if ${MACHINE_CPU} == "arm" || ${MACHINE_CPU} == "hppa" \
|| ${MACHINE_CPU} == "mips" || ${MACHINE_CPU} == "sh3" \
|| ${MACHINE_CPU} == "vax" || ${MACHINE_ARCH} == "m68000"
CPPFLAGS+= -I${RUMPTOP}/../../common/lib/libc/atomic
.ifdef RUMP_SMP
SRCS+= atomic_cas_generic.c
.else
SRCS+= rump_atomic_cas_up.c
.endif
#SRCS+= rump_atomic_cas_up.c
.endif
.include <bsd.lib.mk>

View File

@ -1,4 +1,4 @@
/* $NetBSD: rump.c,v 1.214 2011/01/02 12:52:25 pooka Exp $ */
/* $NetBSD: rump.c,v 1.215 2011/01/04 16:23:36 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.214 2011/01/02 12:52:25 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.215 2011/01/04 16:23:36 pooka Exp $");
#include <sys/systm.h>
#define ELFSIZE ARCH_ELFSIZE
@ -255,8 +255,6 @@ rump__init(int rump_version)
if (rumpuser_getenv("RUMP_NCPU", buf, sizeof(buf), &error) == 0)
error = 0;
/* non-x86 is missing CPU_INFO_FOREACH() support */
#ifdef RUMP_SMP
if (error == 0) {
numcpu = strtoll(buf, NULL, 10);
if (numcpu < 1)
@ -264,11 +262,6 @@ rump__init(int rump_version)
} else {
numcpu = rumpuser_getnhostcpu();
}
#else
if (error == 0)
printf("NCPU limited to 1 on this machine architecture\n");
numcpu = 1;
#endif
rump_cpus_bootstrap(&numcpu);
rumpuser_gettime(&sec, &nsec, &error);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rumpcpu_generic.c,v 1.2 2010/04/27 23:30:30 pooka Exp $ */
/* $NetBSD: rumpcpu_generic.c,v 1.3 2011/01/04 16:23:36 pooka Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@ -29,15 +29,22 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rumpcpu_generic.c,v 1.2 2010/04/27 23:30:30 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: rumpcpu_generic.c,v 1.3 2011/01/04 16:23:36 pooka Exp $");
#include <sys/param.h>
#include "rump_private.h"
struct cpu_info *rumpcpu_info_list;
void
rump_cpu_attach(struct cpu_info *ci)
{
static int nattached;
/* nada */
/* XXX: wrong order, but ... */
ci->ci_next = rumpcpu_info_list;
rumpcpu_info_list = ci;
ci->ci_index = nattached++;
}