diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/sparc64/include/cpu.h | 48 | ||||
-rw-r--r-- | sys/arch/sparc64/include/param.h | 14 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/genassym.cf | 3 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/pmap.c | 5 |
4 files changed, 52 insertions, 18 deletions
diff --git a/sys/arch/sparc64/include/cpu.h b/sys/arch/sparc64/include/cpu.h index 598948b989f..09ca5f0bc0e 100644 --- a/sys/arch/sparc64/include/cpu.h +++ b/sys/arch/sparc64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.44 2007/09/09 12:57:40 kettenis Exp $ */ +/* $OpenBSD: cpu.h,v 1.45 2007/09/09 14:59:37 kettenis Exp $ */ /* $NetBSD: cpu.h,v 1.28 2001/06/14 22:56:58 thorpej Exp $ */ /* @@ -95,6 +95,17 @@ */ struct cpu_info { + /* + * SPARC cpu_info structures live at two VAs: one global + * VA (so each CPU can access any other CPU's cpu_info) + * and an alias VA CPUINFO_VA which is the same on each + * CPU and maps to that CPU's cpu_info. Since the alias + * CPUINFO_VA is how we locate our cpu_info, we have to + * self-reference the global VA so that we can return it + * in the curcpu() macro. + */ + struct cpu_info * volatile ci_self; + /* Most important fields first */ struct proc *ci_curproc; struct pcb *ci_cpcb; /* also initial stack */ @@ -103,6 +114,7 @@ struct cpu_info { struct proc *ci_fpproc; int ci_number; int ci_upaid; + int ci_node; struct schedstate_percpu ci_schedstate; /* scheduler state */ int ci_want_resched; @@ -120,6 +132,28 @@ struct cpu_info { extern struct cpu_info *cpus; +#define curpcb curcpu()->ci_cpcb +#define fpproc curcpu()->ci_fpproc + +#ifdef MULTIPROCESSOR + +#define cpu_number() (curcpu()->ci_number) +#define curcpu() (((struct cpu_info *)CPUINFO_VA)->ci_self) + +#define CPU_IS_PRIMARY(ci) ((ci)->ci_number == 0) +#define CPU_INFO_ITERATOR int +#define CPU_INFO_FOREACH(cii, ci) \ + for (cii = 0, ci = cpus; ci != NULL; ci = ci->ci_next) +#define CPU_INFO_UNIT(ci) ((ci)->ci_number) + +void cpu_boot_secondary_processors(void); + +void sparc64_send_ipi(int, void (*)(void), u_int64_t, u_int64_t); +void sparc64_broadcast_ipi(void (*)(void), u_int64_t, u_int64_t); + +#else + +#define cpu_number() 0 #define curcpu() ((struct cpu_info *)CPUINFO_VA) #define CPU_IS_PRIMARY(ci) 1 @@ -127,19 +161,13 @@ extern struct cpu_info *cpus; #define CPU_INFO_FOREACH(cii, ci) \ for (cii = 0, ci = curcpu(); ci != NULL; ci = NULL) -#define curpcb curcpu()->ci_cpcb -#define fpproc curcpu()->ci_fpproc +#endif /* * definitions of cpu-dependent requirements * referenced in generic code */ #define cpu_wait(p) /* nothing */ -#if 1 -#define cpu_number() 0 -#else -#define cpu_number() (curcpu()->ci_number) -#endif /* * Arguments to hardclock, softclock and gatherstats encapsulate the @@ -266,5 +294,9 @@ struct blink_led { extern void blink_led_register(struct blink_led *); +#ifdef MULTIPROCESSOR +#include <sys/mplock.h> +#endif + #endif /* _KERNEL */ #endif /* _CPU_H_ */ diff --git a/sys/arch/sparc64/include/param.h b/sys/arch/sparc64/include/param.h index 90794eaa1ca..37038b88296 100644 --- a/sys/arch/sparc64/include/param.h +++ b/sys/arch/sparc64/include/param.h @@ -1,4 +1,4 @@ -/* $OpenBSD: param.h,v 1.27 2007/07/24 15:45:10 kettenis Exp $ */ +/* $OpenBSD: param.h,v 1.28 2007/09/09 14:59:37 kettenis Exp $ */ /* $NetBSD: param.h,v 1.25 2001/05/30 12:28:51 mrg Exp $ */ /* @@ -73,12 +73,6 @@ #define MACHINE_ARCH "sparc64" #define MID_MACHINE MID_SPARC64 -#ifdef _KERNEL /* XXX */ -#ifndef _LOCORE /* XXX */ -#include <machine/cpu.h> /* XXX */ -#endif /* XXX */ -#endif /* XXX */ - /* * Round p (pointer or byte index) up to a correctly-aligned value for * the machine's strictest data type. The result is u_int and must be @@ -221,4 +215,10 @@ extern void delay(unsigned int); #define PAGE_SIZE (1 << PAGE_SHIFT) #define PAGE_MASK (PAGE_SIZE - 1) +#ifdef _KERNEL +#ifndef _LOCORE +#include <machine/cpu.h> +#endif +#endif + #endif /* _SPARC64_PARAM_H_ */ diff --git a/sys/arch/sparc64/sparc64/genassym.cf b/sys/arch/sparc64/sparc64/genassym.cf index 53f50b7d6c7..41ee8730e31 100644 --- a/sys/arch/sparc64/sparc64/genassym.cf +++ b/sys/arch/sparc64/sparc64/genassym.cf @@ -1,4 +1,4 @@ -# $OpenBSD: genassym.cf,v 1.20 2007/09/09 10:17:33 kettenis Exp $ +# $OpenBSD: genassym.cf,v 1.21 2007/09/09 14:59:37 kettenis Exp $ # $NetBSD: genassym.cf,v 1.23 2001/08/08 00:09:30 eeh Exp $ # @@ -144,6 +144,7 @@ member faults # CPU info structure struct cpu_info +member ci_self member ci_curproc member ci_cpcb member ci_next diff --git a/sys/arch/sparc64/sparc64/pmap.c b/sys/arch/sparc64/sparc64/pmap.c index f014c7fe07b..e2900c78a79 100644 --- a/sys/arch/sparc64/sparc64/pmap.c +++ b/sys/arch/sparc64/sparc64/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.42 2007/06/06 17:15:13 deraadt Exp $ */ +/* $OpenBSD: pmap.c,v 1.43 2007/09/09 14:59:37 kettenis Exp $ */ /* $NetBSD: pmap.c,v 1.107 2001/08/31 16:47:41 eeh Exp $ */ #undef NO_VCACHE /* Don't forget the locked TLB in dostart */ /* @@ -1395,11 +1395,12 @@ remap_data: /* Initialize our cpu_info structure */ bzero((void *)intstk, 8*NBPG); + cpus->ci_self = cpus; cpus->ci_next = NULL; /* Redundant, I know. */ cpus->ci_curproc = &proc0; cpus->ci_cpcb = (struct pcb *)u0[0]; /* Need better source */ cpus->ci_upaid = CPU_UPAID; - cpus->ci_number = cpus->ci_upaid; /* How do we figure this out? */ + cpus->ci_number = 0; cpus->ci_fpproc = NULL; cpus->ci_spinup = main; /* Call main when we're running. */ cpus->ci_initstack = (void *)u0[1]; |