diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2005-12-03 14:30:07 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2005-12-03 14:30:07 +0000 |
commit | adafd44db90a04c4df796b4e345001a39a835287 (patch) | |
tree | afd1335287af4838d4497cf55be1c065f245442c /sys/arch/m88k/include | |
parent | 5652cf70d1907362b0d7f661c5edbbf19e021b8e (diff) |
Switch m88k ports to __HAVE_CPUINFO. Current cpu pointer is held in SR0
on all running processors.
Tested aoyama@ and I
Diffstat (limited to 'sys/arch/m88k/include')
-rw-r--r-- | sys/arch/m88k/include/asm.h | 10 | ||||
-rw-r--r-- | sys/arch/m88k/include/cmmu.h | 7 | ||||
-rw-r--r-- | sys/arch/m88k/include/cpu.h | 106 | ||||
-rw-r--r-- | sys/arch/m88k/include/pcb.h | 4 | ||||
-rw-r--r-- | sys/arch/m88k/include/types.h | 4 |
5 files changed, 97 insertions, 34 deletions
diff --git a/sys/arch/m88k/include/asm.h b/sys/arch/m88k/include/asm.h index 20b21b078ca..536699246b4 100644 --- a/sys/arch/m88k/include/asm.h +++ b/sys/arch/m88k/include/asm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asm.h,v 1.6 2005/10/13 19:47:12 miod Exp $ */ +/* $OpenBSD: asm.h,v 1.7 2005/12/03 14:30:05 miod Exp $ */ /* * Mach Operating System @@ -160,12 +160,6 @@ #define RTE NOP ; rte /* - * Fields in cr18. More bits are used privately in the exception handling - * code. - */ -#define FLAG_CPU_FIELD_WIDTH 2 /* must match cpu_number() */ - -/* * Info about the PSR */ #define PSR_SHADOW_FREEZE_BIT 0 @@ -184,6 +178,8 @@ #define VECTOR(x) \ word _C_LABEL(x) +#define CPU SR0 + #endif /* _LOCORE */ #define FLUSH_PIPELINE_STRING "tb1 0, r0, 0" diff --git a/sys/arch/m88k/include/cmmu.h b/sys/arch/m88k/include/cmmu.h index cbaeb731f1e..632b9141474 100644 --- a/sys/arch/m88k/include/cmmu.h +++ b/sys/arch/m88k/include/cmmu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cmmu.h,v 1.11 2005/12/02 21:16:45 miod Exp $ */ +/* $OpenBSD: cmmu.h,v 1.12 2005/12/03 14:30:05 miod Exp $ */ /* * Mach Operating System * Copyright (c) 1993-1992 Carnegie Mellon University @@ -28,13 +28,10 @@ #ifndef _M88K_CMMU_H_ #define _M88K_CMMU_H_ -#if defined(_KERNEL) && !defined(_LOCORE) /* * Prototypes and stuff for cmmu.c. */ -extern unsigned cpu_sets[MAX_CPUS]; -extern unsigned master_cpu; -extern int max_cpus; +#if defined(_KERNEL) && !defined(_LOCORE) /* * This lock protects the cmmu SAR and SCR's; other ports diff --git a/sys/arch/m88k/include/cpu.h b/sys/arch/m88k/include/cpu.h index a69737ff09a..7e49360a207 100644 --- a/sys/arch/m88k/include/cpu.h +++ b/sys/arch/m88k/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.9 2005/11/28 22:22:51 miod Exp $ */ +/* $OpenBSD: cpu.h,v 1.10 2005/12/03 14:30:05 miod Exp $ */ /* * Copyright (c) 1996 Nivas Madhur * Copyright (c) 1992, 1993 @@ -54,24 +54,88 @@ #ifdef _KERNEL -#ifndef MAX_CPUS -#define MAX_CPUS 4 -#endif - #include <machine/pcb.h> #include <machine/psl.h> +#include <machine/intr.h> +#include <sys/sched.h> + +#if defined(MULTIPROCESSOR) +#if !defined(MAX_CPUS) || MAX_CPUS > 4 +#undef MAX_CPUS +#define MAX_CPUS 4 +#endif +#else +#undef MAX_CPUS +#define MAX_CPUS 1 +#endif #ifndef _LOCORE -static unsigned cpu_number(void); +extern u_int max_cpus; + +/* + * Per-CPU data structure + */ -static __inline__ unsigned cpu_number(void) -{ - unsigned cpu; +struct cpu_info { + u_int ci_alive; /* nonzero if CPU present */ - __asm__ __volatile__ ("ldcr %0, cr18" : "=r" (cpu)); - return (cpu & 3); -} + struct proc *ci_curproc; /* current process... */ + struct pcb *ci_curpcb; /* ...and its pcb */ + + u_int ci_cpuid; /* cpu number */ + u_int ci_primary; /* set if master cpu */ + + struct schedstate_percpu ci_schedstate; /* scheduling state */ + int ci_want_resched; /* need_resched() invoked */ + + struct pcb *ci_idle_pcb; /* idle pcb (and stack) */ + + u_int ci_intrdepth; /* interrupt depth */ + + u_long ci_spin_locks; /* spin locks counter */ + + /* XXX ddb state? */ +}; + +extern cpuid_t master_cpu; +extern struct cpu_info m88k_cpus[MAX_CPUS]; + +#define CPU_INFO_ITERATOR cpuid_t +#define CPU_INFO_FOREACH(cii, ci) \ + for ((cii) = 0; (cii) < MAX_CPUS; (cii)++) \ + if (((ci) = &m88k_cpus[cii])->ci_alive != 0) +#define CPU_INFO_UNIT(ci) ((ci)->ci_cpuid) + +#if defined(MULTIPROCESSOR) + +#define curcpu() \ +({ \ + struct cpu_info *cpuptr; \ + \ + __asm__ __volatile__ ("ldcr %0, cr17" : "=r" (cpuptr)); \ + cpuptr; \ +}) + +#define CPU_IS_PRIMARY(ci) ((ci)->ci_primary != 0) + +void cpu_boot_secondary_processors(void); + +#else /* MULTIPROCESSOR */ + +#define curcpu() (&m88k_cpus[0]) +#define CPU_IS_PRIMARY(ci) 1 + +#endif /* MULTIPROCESSOR */ + +/* + * The md code may hardcode this in some very specific situations. + */ +#if !defined(cpu_number) +#define cpu_number() curcpu()->ci_cpuid +#endif + +#define curpcb curcpu()->ci_curpcb #endif /* _LOCORE */ @@ -84,6 +148,11 @@ static __inline__ unsigned cpu_number(void) #define cpu_swapin(p) do { /* nothing */ } while (0) #define cpu_swapout(p) do { /* nothing */ } while (0) +#if defined(MULTIPROCESSOR) +#include <sys/lock.h> +#include <sys/mplock.h> +#endif + /* * Arguments to hardclock and gatherstats encapsulate the previous * machine state in an opaque clockframe. CLKF_INTR is only valid @@ -97,8 +166,8 @@ struct clockframe { #define CLKF_USERMODE(framep) (((framep)->tf.tf_epsr & PSR_MODE) == 0) #define CLKF_PC(framep) ((framep)->tf.tf_sxip & XIP_ADDR) -extern int intrdepth; -#define CLKF_INTR(framep) (intrdepth > 1) +#define CLKF_INTR(framep) \ + (((struct cpu_info *)(framep)->tf.tf_cpu)->ci_intrdepth > 1) /* * Get interrupt glue. @@ -122,17 +191,16 @@ extern int ssir; * Preempt the current process if in interrupt from user mode, * or after the current trap/syscall if in system mode. */ -extern int want_resched; /* resched() was called */ #define need_resched(ci) \ do { \ - want_resched = 1; \ - if (curproc != NULL) \ - aston(curproc); \ + ci->ci_want_resched = 1; \ + if (ci->ci_curproc != NULL) \ + aston(ci->ci_curproc); \ } while (0) /* * Give a profiling tick to the current process when the user profiling - * buffer pages are invalid. On the sparc, request an ast to send us + * buffer pages are invalid. On the m88k, request an ast to send us * through trap(), marking the proc as needing a profiling tick. */ #define need_proftick(p) ((p)->p_flag |= P_OWEUPC, aston(p)) diff --git a/sys/arch/m88k/include/pcb.h b/sys/arch/m88k/include/pcb.h index e6aaf9d9305..2ebb31accf0 100644 --- a/sys/arch/m88k/include/pcb.h +++ b/sys/arch/m88k/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.1 2004/04/26 12:34:05 miod Exp $ */ +/* $OpenBSD: pcb.h,v 1.2 2005/12/03 14:30:05 miod Exp $ */ /* * Copyright (c) 1996 Nivas Madhur * Mach Operating System @@ -81,7 +81,7 @@ struct trapframe { register_t tf_scratch1; /* reserved for use by locore */ register_t tf_ipfsr; /* P BUS status */ register_t tf_dpfsr; /* P BUS status */ - register_t tf_cpu; /* cpu number */ + void *tf_cpu; /* cpu_info pointer */ }; #define tf_r tf_regs.r diff --git a/sys/arch/m88k/include/types.h b/sys/arch/m88k/include/types.h index 25dc0d1dc0d..a733ec54414 100644 --- a/sys/arch/m88k/include/types.h +++ b/sys/arch/m88k/include/types.h @@ -1,5 +1,5 @@ /* $NetBSD: types.h,v 1.7 1995/07/05 17:46:11 pk Exp $ */ -/* $OpenBSD: types.h,v 1.3 2004/11/26 21:23:05 miod Exp $ */ +/* $OpenBSD: types.h,v 1.4 2005/12/03 14:30:05 miod Exp $ */ /* * Copyright (c) 1992, 1993 @@ -77,4 +77,6 @@ typedef unsigned long long uint64_t; typedef int32_t register_t; +#define __HAVE_CPUINFO + #endif /* _M88K_TYPES_H_ */ |