diff options
author | jhb <jhb@FreeBSD.org> | 2003-12-03 14:55:31 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2003-12-03 14:55:31 +0000 |
commit | 907202ec1f57f255a3cb7245df54cf0e74dc5e43 (patch) | |
tree | 43e2b5c4b744220483a5d1abfee49180d1fc4324 /sys/kern/subr_smp.c | |
parent | e57603da9f15ad23d90b15e7ad5464e3b5398310 (diff) | |
download | FreeBSD-src-907202ec1f57f255a3cb7245df54cf0e74dc5e43.zip FreeBSD-src-907202ec1f57f255a3cb7245df54cf0e74dc5e43.tar.gz |
Export a few SMP related symbols in UP kernels as well. This is needed to
aid other kernel code, especially code which can be in a module such as
the acpi_cpu(4) driver, to work properly with both SMP and UP kernels.
The exported symbols include mp_ncpus, all_cpus, mp_maxid, smp_started, and
the smp_rendezvous() function. This also means that CPU_ABSENT() is now
always implemented the same on all kernels.
Approved by: re (scottl)
Diffstat (limited to 'sys/kern/subr_smp.c')
-rw-r--r-- | sys/kern/subr_smp.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index b6fd97f..b3b81ac 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -48,10 +48,13 @@ __FBSDID("$FreeBSD$"); #include <machine/smp.h> +#ifdef SMP volatile u_int stopped_cpus; volatile u_int started_cpus; void (*cpustop_restartfunc)(void); +#endif + int mp_ncpus; volatile int smp_started; @@ -73,6 +76,7 @@ int smp_cpus = 1; /* how many cpu's running */ SYSCTL_INT(_kern_smp, OID_AUTO, cpus, CTLFLAG_RD, &smp_cpus, 0, "Number of CPUs online"); +#ifdef SMP /* Enable forwarding of a signal to a process running on a different CPU */ static int forward_signal_enabled = 1; SYSCTL_INT(_kern_smp, OID_AUTO, forward_signal_enabled, CTLFLAG_RW, @@ -331,3 +335,35 @@ smp_rendezvous(void (* setup_func)(void *), /* release lock */ mtx_unlock_spin(&smp_rv_mtx); } +#else /* !SMP */ + +/* + * Provide dummy SMP support for UP kernels. Modules that need to use SMP + * APIs will still work using this dummy support. + */ +static void +mp_setvariables_for_up(void *dummy) +{ + mp_ncpus = 1; + mp_maxid = PCPU_GET(cpuid); + all_cpus = PCPU_GET(cpumask); + KASSERT(PCPU_GET(cpuid) == 0, ("UP must have a CPU ID of zero")); +} +SYSINIT(cpu_mp_setvariables, SI_SUB_TUNABLES, SI_ORDER_FIRST, + mp_setvariables_for_up, NULL) + +void +smp_rendezvous(void (* setup_func)(void *), + void (* action_func)(void *), + void (* teardown_func)(void *), + void *arg) +{ + + if (setup_func != NULL) + setup_func(arg); + if (action_func != NULL) + action_func(arg); + if (teardown_func != NULL) + teardown_func(arg); +} +#endif /* SMP */ |