smp.h revision 83366
125164Speter/*
225164Speter * ----------------------------------------------------------------------------
325164Speter * "THE BEER-WARE LICENSE" (Revision 42):
425164Speter * <phk@FreeBSD.org> wrote this file.  As long as you retain this notice you
525164Speter * can do whatever you want with this stuff. If we meet some day, and you think
625164Speter * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
725164Speter * ----------------------------------------------------------------------------
825164Speter *
950477Speter * $FreeBSD: head/sys/sys/smp.h 83366 2001-09-12 08:38:13Z julian $
1025164Speter */
1125164Speter
1276078Sjhb#ifndef _SYS_SMP_H_
1376078Sjhb#define _SYS_SMP_H_
1425164Speter
1555205Speter#ifdef _KERNEL
1676078Sjhb#include <machine/smp.h>
1725164Speter
1876078Sjhb#ifndef LOCORE
1925517Sfsmp
2076078Sjhb#ifdef SMP
2176078Sjhbextern void (*cpustop_restartfunc)(void);
2276078Sjhbextern int mp_ncpus;
2376078Sjhbextern int smp_active;
2476078Sjhbextern int smp_started;
2576078Sjhbextern int smp_cpus;
2676078Sjhbextern u_int all_cpus;
2776078Sjhbextern volatile u_int started_cpus;
2876078Sjhbextern volatile u_int stopped_cpus;
2927728Sfsmp
3027002Sfsmp/*
3180779Sbmilekic * Macro allowing us to determine whether a CPU is absent at any given
3280779Sbmilekic * time, thus permitting us to configure sparse maps of cpuid-dependent
3380779Sbmilekic * (per-CPU) structures.
3480779Sbmilekic */
3580779Sbmilekic#define	CPU_ABSENT(x_cpu)	((all_cpus & (1 << (x_cpu))) == 0)
3680779Sbmilekic
3780779Sbmilekic/*
3876078Sjhb * Machine dependent functions used to initialize MP support.
3976078Sjhb *
4076078Sjhb * The cpu_mp_probe() should check to see if MP support is present and return
4176078Sjhb * zero if it is not or non-zero if it is.  If MP support is present, then
4276078Sjhb * cpu_mp_start() will be called so that MP can be enabled.  This function
4376078Sjhb * should do things such as startup secondary processors.  It should also
4476078Sjhb * setup mp_ncpus, all_cpus, and smp_cpus.  It should also ensure that
4576078Sjhb * smp_active and smp_started are initialized at the appropriate time.
4676078Sjhb * Once cpu_mp_start() returns, machine independent MP startup code will be
4776078Sjhb * executed and a simple message will be output to the console.  Finally,
4876078Sjhb * cpu_mp_announce() will be called so that machine dependent messages about
4976078Sjhb * the MP support may be output to the console if desired.
5027002Sfsmp */
5176078Sjhbvoid	cpu_mp_announce(void);
5276078Sjhbint	cpu_mp_probe(void);
5376078Sjhbvoid	cpu_mp_start(void);
5427002Sfsmp
5583366Sjulianvoid	forward_signal(struct thread *);
5676078Sjhbvoid	forward_roundrobin(void);
5776078Sjhbint	restart_cpus(u_int);
5876078Sjhbint	stop_cpus(u_int);
5976078Sjhbvoid	smp_rendezvous_action(void);
6076078Sjhbvoid	smp_rendezvous(void (*)(void *),
6176078Sjhb		       void (*)(void *),
6276078Sjhb		       void (*)(void *),
6376078Sjhb		       void *arg);
6480779Sbmilekic#else /* SMP */
6580779Sbmilekic#define	CPU_ABSENT(x_cpu)	(0)
6676078Sjhb#endif /* SMP */
6727728Sfsmp#endif /* !LOCORE */
6855205Speter#endif /* _KERNEL */
6976078Sjhb#endif /* _SYS_SMP_H_ */
70