summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2005-12-03 14:30:07 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2005-12-03 14:30:07 +0000
commitadafd44db90a04c4df796b4e345001a39a835287 (patch)
treeafd1335287af4838d4497cf55be1c065f245442c /sys/arch
parent5652cf70d1907362b0d7f661c5edbbf19e021b8e (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')
-rw-r--r--sys/arch/luna88k/include/locore.h6
-rw-r--r--sys/arch/luna88k/luna88k/eh.S5
-rw-r--r--sys/arch/luna88k/luna88k/locore.S41
-rw-r--r--sys/arch/luna88k/luna88k/m8820x.c5
-rw-r--r--sys/arch/luna88k/luna88k/machdep.c29
-rw-r--r--sys/arch/m88k/conf/files.m88k3
-rw-r--r--sys/arch/m88k/include/asm.h10
-rw-r--r--sys/arch/m88k/include/cmmu.h7
-rw-r--r--sys/arch/m88k/include/cpu.h106
-rw-r--r--sys/arch/m88k/include/pcb.h4
-rw-r--r--sys/arch/m88k/include/types.h4
-rw-r--r--sys/arch/m88k/m88k/cmmu.c80
-rw-r--r--sys/arch/m88k/m88k/eh_common.S59
-rw-r--r--sys/arch/m88k/m88k/genassym.cf17
-rw-r--r--sys/arch/m88k/m88k/m88k_machdep.c59
-rw-r--r--sys/arch/m88k/m88k/pmap.c58
-rw-r--r--sys/arch/m88k/m88k/process.S107
-rw-r--r--sys/arch/m88k/m88k/subr.S95
-rw-r--r--sys/arch/m88k/m88k/trap.c33
-rw-r--r--sys/arch/m88k/m88k/vm_machdep.c24
-rw-r--r--sys/arch/mvme88k/include/locore.h11
-rw-r--r--sys/arch/mvme88k/mvme88k/eh.S5
-rw-r--r--sys/arch/mvme88k/mvme88k/locore.S39
-rw-r--r--sys/arch/mvme88k/mvme88k/m188_machdep.c6
-rw-r--r--sys/arch/mvme88k/mvme88k/m88110.c3
-rw-r--r--sys/arch/mvme88k/mvme88k/m8820x.c4
-rw-r--r--sys/arch/mvme88k/mvme88k/machdep.c28
27 files changed, 390 insertions, 458 deletions
diff --git a/sys/arch/luna88k/include/locore.h b/sys/arch/luna88k/include/locore.h
index f31fd89595b..eeaacb50714 100644
--- a/sys/arch/luna88k/include/locore.h
+++ b/sys/arch/luna88k/include/locore.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.h,v 1.5 2005/04/27 14:09:45 miod Exp $ */
+/* $OpenBSD: locore.h,v 1.6 2005/12/03 14:30:02 miod Exp $ */
#ifndef _MACHINE_LOCORE_H_
#define _MACHINE_LOCORE_H_
@@ -12,12 +12,12 @@
unsigned read_processor_identification_register(void);
int badaddr(vaddr_t addr, int size);
#define badwordaddr(x) badaddr(x, 4)
-void set_cpu_number(unsigned number);
void doboot(void);
-/* locore_c_routines.c */
+/* machdep.c */
unsigned getipl(void);
+void set_cpu_number(cpuid_t);
/* eh.S */
diff --git a/sys/arch/luna88k/luna88k/eh.S b/sys/arch/luna88k/luna88k/eh.S
index 2ac63b1b267..2924d40a308 100644
--- a/sys/arch/luna88k/luna88k/eh.S
+++ b/sys/arch/luna88k/luna88k/eh.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: eh.S,v 1.5 2004/08/05 21:34:08 miod Exp $ */
+/* $OpenBSD: eh.S,v 1.6 2005/12/03 14:30:05 miod Exp $ */
/*
* Mach Operating System
* Copyright (c) 1993-1991 Carnegie Mellon University
@@ -36,7 +36,8 @@
*/
#define PFSR_SAVE \
- extu TMP, FLAGS, FLAG_CPU_FIELD_WIDTH<0>; /* TMP = cpu# */ \
+ ldcr TMP, CPU; \
+ ld TMP, TMP, CI_CPUID; /* TMP = cpu# */ \
cmp TMP2, TMP, 0x0; /* CPU0 ? */ \
bb1 eq, TMP2, 1f; \
cmp TMP2, TMP, 0x1; /* CPU1 ? */ \
diff --git a/sys/arch/luna88k/luna88k/locore.S b/sys/arch/luna88k/luna88k/locore.S
index 79c0a1ebf04..73bb31395ed 100644
--- a/sys/arch/luna88k/luna88k/locore.S
+++ b/sys/arch/luna88k/luna88k/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.9 2005/10/12 19:32:17 miod Exp $ */
+/* $OpenBSD: locore.S,v 1.10 2005/12/03 14:30:05 miod Exp $ */
/*
* Copyright (c) 1998 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -120,7 +120,7 @@ GLOBAL(start_text)
or.u r13, r0, hi16(_C_LABEL(brdtyp))
st r8, r13, lo16(_C_LABEL(brdtyp))
- /* set _cputyp */
+ /* set cputyp */
cmp r2, r8, BRD_197 /* r8 contains brdtyp */
bb1 ne, r2, 1f /* if it's a '197, CPU is 88110 */
or.u r13, r0, hi16(CPU_88110)
@@ -157,12 +157,12 @@ GLOBAL(start_text)
* The manual says not to disable interrupts and freeze shadowing
* at the same time because interrupts are not actually disabled
* until after the next instruction. Well, if an interrupt
- * occurs now, we're in deep anyway, so I'm going to do
+ * occurs now, we're in deep trouble anyway, so I'm going to do
* the two together.
*
* Upon a reset (or poweron, I guess), the PSR indicates:
* supervisor mode
- * interrupts, shadowing, FPU, missaligned exception: all disabled
+ * interrupts, shadowing, FPU, misaligned exception: all disabled
*
* We'll just construct our own turning on what we want.
*
@@ -170,7 +170,6 @@ GLOBAL(start_text)
*/
stcr r0, SSBR /* clear this for later */
- stcr r0, SR0 /* clear "current thread" */
stcr r0, SR1 /* clear the CPU flags */
set r11, r0, 1<PSR_SUPERVISOR_MODE_BIT>
@@ -263,7 +262,6 @@ ASLOCAL(master_start)
*/
or.u r31, r0, hi16(_ASM_LABEL(intstack_end))
or r31, r31, lo16(_ASM_LABEL(intstack_end))
- clr r31, r31, 3<0> /* round down to 8-byte boundary */
or.u r3, r0, hi16(_C_LABEL(vector_list))
or r3, r3, lo16(_C_LABEL(vector_list))
@@ -320,8 +318,8 @@ ASLOCAL(master_start)
/*
* ...and we can switch to the u area stack now.
*/
- or.u r10, r0, hi16(_C_LABEL(curpcb))
- ld r31, r10, lo16(_C_LABEL(curpcb))
+ ldcr r10, CPU
+ ld r31, r10, CI_CURPCB
addu r31, r31, USIZE
/* call main() - no arguments although main() still defines one */
@@ -382,12 +380,6 @@ GLOBAL(spin_cpu)
* The processor loops (busy waits) for the given number of microseconds:
* Thus, delay(1000000) will delay for one second.
* (originally from Mach 2.5)
- *
- * REGISTER USAGE:
- * IN r1 - return address
- * IN r2 - number of microseconds
- * r3 - cpu speed in MHz
- * r4 - number of cycles to delay
*/
GLOBAL(delay)
@@ -412,7 +404,7 @@ GLOBAL(kernel_sdt) /* SDT (segment descriptor table */
.align NBPG
GLOBAL(intstack)
- space INTSTACK_SIZE /* 16K, just to be safe */
+ space USIZE
ASGLOBAL(intstack_end)
ASGLOBAL(slavestack)
space NBPG /* 4K, small, interim stack */
@@ -429,7 +421,7 @@ ASGLOBAL(slavestack_end)
*/
.align NBPG
GLOBAL(idle_u)
- space UPAGES * NBPG
+ space USIZE
/*
* Process 0's u.
@@ -439,6 +431,8 @@ GLOBAL(idle_u)
.align NBPG
ASLOCAL(u0)
space UPAGES * NBPG
+GLOBAL(proc0paddr)
+ word _ASM_LABEL(u0) /* KVA of proc0 uarea */
GLOBAL(ret_addr)
word 0
@@ -454,21 +448,8 @@ ASLOCAL(master_processor_chosen)
/* XMEM spin lock -- controls access to master_processor_chosen */
ASLOCAL(inter_processor_lock)
word 0
+
#if defined(DDB) || NKSYMS > 0
GLOBAL(esym)
word 0
#endif /* DDB || NKSYMS > 0 */
-GLOBAL(proc0paddr)
- word _ASM_LABEL(u0) /* KVA of proc0 uarea */
-
-/*
- * curpcb points to the current pcb (and hence u. area).
- * Initially this is the special one.
- */
-/*
- * pcb is composed of kernel state + user state
- * I may have to change curpcb to u0 + PCB_USER based on what
- * other parts expect XXX nivas
- */
-GLOBAL(curpcb)
- word _ASM_LABEL(u0) /* curpcb = &u0 */
diff --git a/sys/arch/luna88k/luna88k/m8820x.c b/sys/arch/luna88k/luna88k/m8820x.c
index fcaa0c8423f..adfa70058cb 100644
--- a/sys/arch/luna88k/luna88k/m8820x.c
+++ b/sys/arch/luna88k/luna88k/m8820x.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: m8820x.c,v 1.8 2005/12/02 21:16:43 miod Exp $ */
+/* $OpenBSD: m8820x.c,v 1.9 2005/12/03 14:30:05 miod Exp $ */
/*
* Copyright (c) 2004, Miodrag Vallat.
*
@@ -101,8 +101,6 @@ m8820x_setup_board_config()
struct m8820x_cmmu *cmmu;
int num;
- master_cpu = 0; /* temp to get things going */
-
m8820x_cmmu[0].cmmu_regs = (void *)CMMU_I0;
m8820x_cmmu[1].cmmu_regs = (void *)CMMU_D0;
m8820x_cmmu[2].cmmu_regs = (void *)CMMU_I1;
@@ -150,7 +148,6 @@ m8820x_setup_board_config()
for (num = 0; num < max_cpus; num++) {
int type;
- cpu_sets[num] = 1; /* This cpu installed... */
type = CMMU_TYPE(m8820x_cmmu[num << cmmu_shift].
cmmu_regs[CMMU_IDR]);
diff --git a/sys/arch/luna88k/luna88k/machdep.c b/sys/arch/luna88k/luna88k/machdep.c
index 2efd7c4b6e4..a0082c2bb82 100644
--- a/sys/arch/luna88k/luna88k/machdep.c
+++ b/sys/arch/luna88k/luna88k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.26 2005/12/01 22:14:52 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.27 2005/12/03 14:30:05 miod Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -200,7 +200,6 @@ struct nvram_t {
vaddr_t obiova;
int ssir;
-int want_resched;
int physmem; /* available physical memory, in pages */
@@ -261,7 +260,6 @@ vaddr_t last_addr;
vaddr_t avail_start, avail_end;
vaddr_t virtual_avail, virtual_end;
-extern struct pcb *curpcb;
extern struct user *proc0paddr;
/*
@@ -1106,16 +1104,9 @@ luna88k_bootstrap()
extern struct consdev *cn_tab;
extern struct cmmu_p cmmu8820x;
extern char *end;
-
- /*
- * Must initialize p_addr before autoconfig or
- * the fault handler will get a NULL reference.
- * Do this early so that we can take a data or
- * instruction fault and survive it.
- */
- proc0.p_addr = proc0paddr;
- curproc = &proc0;
- curpcb = &proc0paddr->u_pcb;
+#ifndef MULTIPROCESSOR
+ u_int master_cpu;
+#endif
cmmu = &cmmu8820x;
@@ -1143,6 +1134,16 @@ luna88k_bootstrap()
set_cpu_number(master_cpu);
/*
+ * Now that set_cpu_number() set us with a valid cpu_info pointer,
+ * we need to initialize p_addr and curpcb before autoconf, for the
+ * fault handler to behave properly [except for badaddr() faults,
+ * which can be taken care of without a valid curcpu()].
+ */
+ proc0.p_addr = proc0paddr;
+ curproc = &proc0;
+ curpcb = &proc0paddr->u_pcb;
+
+ /*
* We may have more than one CPU, so mention which one is the master.
* We will also want to spin up slave CPUs on the long run...
*/
@@ -1441,8 +1442,10 @@ setlevel(unsigned int level)
set_value = int_set_val[level];
+#ifdef MULTIPROCESSOR
if (cpu != master_cpu)
set_value &= INT_SLAVE_MASK;
+#endif
*int_mask_reg[cpu] = set_value;
luna88k_curspl[cpu] = level;
diff --git a/sys/arch/m88k/conf/files.m88k b/sys/arch/m88k/conf/files.m88k
index 08e8d158101..924ea6f2662 100644
--- a/sys/arch/m88k/conf/files.m88k
+++ b/sys/arch/m88k/conf/files.m88k
@@ -1,6 +1,5 @@
-# $OpenBSD: files.m88k,v 1.14 2005/10/24 19:28:28 miod Exp $
+# $OpenBSD: files.m88k,v 1.15 2005/12/03 14:30:05 miod Exp $
-file arch/m88k/m88k/cmmu.c
file arch/m88k/m88k/db_disasm.c ddb
file arch/m88k/m88k/db_interface.c ddb
file arch/m88k/m88k/db_sstep.c ddb
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_ */
diff --git a/sys/arch/m88k/m88k/cmmu.c b/sys/arch/m88k/m88k/cmmu.c
deleted file mode 100644
index dbf6f223747..00000000000
--- a/sys/arch/m88k/m88k/cmmu.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/* $OpenBSD: cmmu.c,v 1.4 2005/10/13 19:48:33 miod Exp $ */
-/*
- * Copyright (c) 1998 Steve Murphree, Jr.
- * Copyright (c) 1996 Nivas Madhur
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Nivas Madhur.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-/*
- * Mach Operating System
- * Copyright (c) 1993-1991 Carnegie Mellon University
- * Copyright (c) 1991 OMRON Corporation
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON AND OMRON ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON AND OMRON DISCLAIM ANY LIABILITY OF ANY KIND
- * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the
- * rights to redistribute these changes.
- */
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/simplelock.h>
-
-#include <uvm/uvm_extern.h>
-
-#include <machine/cmmu.h>
-
-/*
- * This lock protects the cmmu SAR and SCR's; other ports
- * can be accessed without locking it.
- *
- * May be used from "db_interface.c".
- */
-struct simplelock cmmu_cpu_lock;
-
-unsigned cpu_sets[MAX_CPUS];
-unsigned master_cpu = 0;
-int max_cpus;
-
-struct cmmu_p *cmmu;
diff --git a/sys/arch/m88k/m88k/eh_common.S b/sys/arch/m88k/m88k/eh_common.S
index c85d9172c2b..df15ba03372 100644
--- a/sys/arch/m88k/m88k/eh_common.S
+++ b/sys/arch/m88k/m88k/eh_common.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: eh_common.S,v 1.13 2005/11/28 22:21:15 miod Exp $ */
+/* $OpenBSD: eh_common.S,v 1.14 2005/12/03 14:30:06 miod Exp $ */
/*
* Mach Operating System
* Copyright (c) 1993-1991 Carnegie Mellon University
@@ -133,7 +133,7 @@
* system will hang waiting for a bit to clear that will never.
*
* 3) If the exception is the privilege violation exception, the bounds
- * violation exception, or the misaligned access exception, the
+ * check exception, or the misaligned access exception, the
* destination register bit in the SSBR may need to be cleared.
*
* 4) If the exception is one of the floating exceptions, then the
@@ -172,7 +172,6 @@
* register during the FPU restart (it could get overwritten by the FPU!),
* we save it in a control register, SR3, during the restart.
*
- *
* HOWEVER .....
*
* Because other uncompleted actions in the FPU may fault when the FPU is
@@ -211,10 +210,6 @@
/*
* SR1 - CPU FLAGS REGISTER
- * XXX clean this when the trap handler is reworked. Among the things
- * I like to see is having the trap frame on the kernel stack instead
- * of putting in the PCB. If done properly, we don't need SR1 for doing
- * anything special. nivas
*
* SR1 contains flags about the current CPU status.
*
@@ -247,10 +242,10 @@
*
* Also, if any are 'r2' or 'r3', be careful using with CALL above!
*/
-#define FLAGS r2
-#define TMP r3
-#define TMP2 r10
-#define TMP3 r11
+#define FLAGS r2
+#define TMP r3
+#define TMP2 r10
+#define TMP3 r11
#define SAVE_TMP2 st r10, r31, GENREG_OFF(10)
#define SAVE_TMP3 st r11, r31, GENREG_OFF(11)
#define RESTORE_TMP2 ld r10, r31, GENREG_OFF(10)
@@ -611,7 +606,6 @@ GLOBAL(error_handler)
GLOBAL(reset_handler)
or r29, r0, 0
1:
- /* pick up the slavestack */
or r26, r0, r31 /* save old stack */
or.u r31, r0, hi16(_ASM_LABEL(intstack_end))
or r31, r31, lo16(_ASM_LABEL(intstack_end))
@@ -743,7 +737,7 @@ ASLOCAL(m88100_ignore_data_exception)
/*
* SR1: previous FLAGS reg
* SR2: free
- * SR3: must presere
+ * SR3: must preserve
* FLAGS: CPU status flags
*/
xcr FLAGS, FLAGS, SR1 /* replace SR1, FLAGS */
@@ -753,7 +747,7 @@ ASLOCAL(m88100_ignore_data_exception)
*
* We just want to jump to "badaddr__return_nonzero" below.
*
- * We don't worry about trashing R2 here because we're
+ * We don't worry about trashing r2 here because we're
* jumping back to the function badaddr() where we're allowed
* to blast r2..r9 as we see fit.
*/
@@ -1010,8 +1004,8 @@ ASLOCAL(m88100_use_SR3_pcb)
* Consequently, we never picked up a stack. Do so now.
* R1 is currently free (saved in the exception frame pointed at by
* r30) */
- or.u r1, r0, hi16(_C_LABEL(curpcb))
- ld r1, r1, lo16(_C_LABEL(curpcb))
+ ldcr r1, CPU
+ ld r1, r1, CI_CURPCB
addu r1, r1, USIZE - SIZEOF_EF
st FLAGS,r1, REG_OFF(EF_FLAGS) /* store flags */
st r31, r1, GENREG_OFF(31) /* store r31 - now free */
@@ -1038,8 +1032,8 @@ ASLOCAL(m88100_pickup_stack)
stcr r31, SR3 /* save previous r31 */
/* switch to the process kernel stack. */
- or.u r31, r0, hi16(_C_LABEL(curpcb))
- ld r31, r31, lo16(_C_LABEL(curpcb))
+ ldcr r31, CPU
+ ld r31, r31, CI_CURPCB
addu r31, r31, PCB_USER_STATE /* point to user save area */
/*
@@ -1082,8 +1076,8 @@ ASLOCAL(m88100_have_pcb)
st TMP3, r31, REG_OFF(EF_SNIP)
ldcr TMP2, SFIP
st TMP2, r31, REG_OFF(EF_SFIP)
- /* get and store the cpu number */
- extu TMP, FLAGS, FLAG_CPU_FIELD_WIDTH<0> /* TMP = cpu# */
+ /* get and store the cpu_info pointer */
+ ldcr TMP, CPU
st TMP, r31, REG_OFF(EF_CPU)
/*
@@ -1531,8 +1525,8 @@ ASLOCAL(m88100_fpu_enable)
ld r2, r31, REG_OFF(EF_EPSR)
bb1 PSR_SUPERVISOR_MODE_BIT, r2, 1f /* if in kernel mode */
- or.u r31, r0, hi16(_C_LABEL(curpcb))
- ld r31, r31, lo16(_C_LABEL(curpcb))
+ ldcr r31, CPU
+ ld r31, r31, CI_CURPCB
addu r31, r31, USIZE /* point at proper end */
1:
@@ -1707,8 +1701,8 @@ ASLOCAL(no_softint)
ld r2, FPTR, REG_OFF(EF_EPSR)
bb1 PSR_SUPERVISOR_MODE_BIT, r2, _ASM_LABEL(no_ast)
- or.u r2, r0, hi16(_C_LABEL(curproc))
- ld r3, r2, lo16(_C_LABEL(curproc))
+ ldcr r2, CPU
+ ld r3, r2, CI_CURPROC
bcnd.n eq0, r3, _ASM_LABEL(no_ast) /* no AST if no process! */
ld r2, r3, P_ASTPENDING
bcnd.n eq0, r3, _ASM_LABEL(no_ast) /* .n safe since the first
@@ -2020,7 +2014,6 @@ GLOBAL(m88110_error_handler)
GLOBAL(m88110_reset_handler)
or r29, r0, 0
1:
- /* pick up the slavestack */
or r26, r0, r31 /* save old stack */
or.u r31, r0, hi16(_ASM_LABEL(intstack_end))
or r31, r31, lo16(_ASM_LABEL(intstack_end))
@@ -2269,8 +2262,8 @@ ASLOCAL(m88110_use_SR3_pcb)
* R1 is currently free (saved in the exception frame pointed at by
* r30)
*/
- or.u r1, r0, hi16(_C_LABEL(curpcb))
- ld r1, r1, lo16(_C_LABEL(curpcb))
+ ldcr r1, CPU
+ ld r1, r1, CI_CURPCB
addu r1, r1, USIZE - SIZEOF_EF
st FLAGS,r1, REG_OFF(EF_FLAGS) /* store flags */
st r31, r1, GENREG_OFF(31) /* store r31 - now free */
@@ -2298,8 +2291,8 @@ ASLOCAL(m88110_pickup_stack)
stcr r31, SR3 /* save previous r31 */
/* switch to the process kernel stack. */
- or.u r31, r0, hi16(_C_LABEL(curpcb))
- ld r31, r31, lo16(_C_LABEL(curpcb))
+ ldcr r31, CPU
+ ld r31, r31, CI_CURPCB
addu r31, r31, PCB_USER_STATE /* point to user save area */
/*
@@ -2343,8 +2336,8 @@ ASLOCAL(m88110_have_pcb)
st TMP2, r31, REG_OFF(EF_EXIP)
st TMP3, r31, REG_OFF(EF_ENIP)
- /* get and store the cpu number */
- extu TMP, FLAGS, FLAG_CPU_FIELD_WIDTH<0> /* TMP = cpu# */
+ /* get and store the cpu_info pointer */
+ ldcr TMP, CPU
st TMP, r31, REG_OFF(EF_CPU)
/*
@@ -2533,8 +2526,8 @@ ASLOCAL(m88110_fpu_enable)
ld r2, r31, REG_OFF(EF_EPSR)
bb1 PSR_SUPERVISOR_MODE_BIT, r2, 1f /* if in kernel mode */
- or.u r31, r0, hi16(_C_LABEL(curpcb))
- ld r31, r31, lo16(_C_LABEL(curpcb))
+ ldcr r31, CPU
+ ld r31, r31, CI_CURPCB
addu r31, r31, USIZE /* point at proper end */
1:
diff --git a/sys/arch/m88k/m88k/genassym.cf b/sys/arch/m88k/m88k/genassym.cf
index 41ef2f83384..8e7b869bdb1 100644
--- a/sys/arch/m88k/m88k/genassym.cf
+++ b/sys/arch/m88k/m88k/genassym.cf
@@ -1,4 +1,4 @@
-# $OpenBSD: genassym.cf,v 1.3 2005/11/28 22:21:15 miod Exp $
+# $OpenBSD: genassym.cf,v 1.4 2005/12/03 14:30:06 miod Exp $
#
# Copyright (c) 1982, 1990 The Regents of the University of California.
# All rights reserved.
@@ -28,7 +28,7 @@
# SUCH DAMAGE.
#
# @(#)genassym.c 7.8 (Berkeley) 5/7/91
-# $Id: genassym.cf,v 1.3 2005/11/28 22:21:15 miod Exp $
+# $Id: genassym.cf,v 1.4 2005/12/03 14:30:06 miod Exp $
#
include <sys/param.h>
@@ -37,10 +37,12 @@ include <sys/time.h>
include <sys/proc.h>
include <sys/mbuf.h>
include <sys/msgbuf.h>
+
include <machine/cpu.h>
include <machine/trap.h>
include <machine/psl.h>
include <machine/vmparam.h>
+
include <sys/syscall.h>
include <sys/user.h>
@@ -56,8 +58,19 @@ member P_ASTPENDING p_md.md_astpending
export SRUN
export SONPROC
+# cpu fields
+struct cpu_info
+member ci_curproc
+member ci_curpcb
+member ci_cpuid
+member ci_primary
+member ci_idle_pcb
+member ci_want_resched
+
# general constants
export UPAGES
+# We export USPACE under another name to allow C code to include "assym.h".
+#export USPACE
define USIZE USPACE
# pcb fields
diff --git a/sys/arch/m88k/m88k/m88k_machdep.c b/sys/arch/m88k/m88k/m88k_machdep.c
index 0c9b6d2fdc9..3f815e42736 100644
--- a/sys/arch/m88k/m88k/m88k_machdep.c
+++ b/sys/arch/m88k/m88k/m88k_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: m88k_machdep.c,v 1.9 2005/11/28 22:22:55 miod Exp $ */
+/* $OpenBSD: m88k_machdep.c,v 1.10 2005/12/03 14:30:06 miod Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -53,8 +53,10 @@
#include <sys/exec.h>
#include <sys/errno.h>
+#include <machine/asm_macro.h>
#include <machine/cmmu.h>
#include <machine/cpu.h>
+#include <machine/locore.h>
#include <machine/reg.h>
#ifdef M88100
#include <machine/m88100.h>
@@ -73,9 +75,26 @@ void regdump(struct trapframe *f);
void dumpsys(void);
void dumpconf(void);
-int longformat = 1; /* for regdump() */
+/*
+ * CMMU and CPU variables
+ */
-int intrdepth;
+#ifdef MULTIPROCESSOR
+cpuid_t master_cpu;
+#endif
+
+struct cpu_info m88k_cpus[MAX_CPUS];
+u_int max_cpus;
+
+struct cmmu_p *cmmu;
+
+/*
+ * This lock protects the cmmu SAR and SCR's; other ports
+ * can be accessed without locking it.
+ */
+struct simplelock cmmu_cpu_lock;
+
+int longformat = 1; /* for regdump() */
/*
* safepri is a safe priority for sleep to set for a spin-wait
@@ -279,7 +298,7 @@ regdump(struct trapframe *f)
f->tf_fphs2, f->tf_fpls2);
printf("fppt %x fprh %x fprl %x fpit %x\n",
f->tf_fppt, f->tf_fprh, f->tf_fprl, f->tf_fpit);
- printf("vector %d mask %x mode %x scratch1 %x cpu %x\n",
+ printf("vector %d mask %x mode %x scratch1 %x cpu %p\n",
f->tf_vector, f->tf_mask, f->tf_mode,
f->tf_scratch1, f->tf_cpu);
}
@@ -292,9 +311,39 @@ regdump(struct trapframe *f)
f->tf_dsap, f->tf_duap, f->tf_dsr, f->tf_dlar, f->tf_dpar);
printf("isap %x iuap %x isr %x ilar %x ipar %x\n",
f->tf_isap, f->tf_iuap, f->tf_isr, f->tf_ilar, f->tf_ipar);
- printf("vector %d mask %x mode %x scratch1 %x cpu %x\n",
+ printf("vector %d mask %x mode %x scratch1 %x cpu %p\n",
f->tf_vector, f->tf_mask, f->tf_mode,
f->tf_scratch1, f->tf_cpu);
}
#endif
}
+
+/*
+ * Set up the cpu_info pointer and the cpu number for the current processor.
+ */
+void
+set_cpu_number(cpuid_t number)
+{
+ struct cpu_info *ci;
+ extern struct pcb idle_u;
+
+#ifdef MULTIPROCESSOR
+ ci = &m88k_cpus[number];
+#else
+ ci = &m88k_cpus[0];
+#endif
+ ci->ci_cpuid = number;
+
+ __asm__ __volatile__ ("stcr %0, cr17" :: "r" (ci));
+ flush_pipeline();
+
+#ifdef MULTIPROCESSOR
+ if (number == master_cpu)
+#endif
+ {
+ ci->ci_primary = 1;
+ ci->ci_idle_pcb = &idle_u;
+ }
+
+ ci->ci_alive = 1;
+}
diff --git a/sys/arch/m88k/m88k/pmap.c b/sys/arch/m88k/m88k/pmap.c
index 96afc0d2b02..52fdd4ef852 100644
--- a/sys/arch/m88k/m88k/pmap.c
+++ b/sys/arch/m88k/m88k/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.17 2005/12/01 22:24:52 miod Exp $ */
+/* $OpenBSD: pmap.c,v 1.18 2005/12/03 14:30:06 miod Exp $ */
/*
* Copyright (c) 2001-2004, Miodrag Vallat
* Copyright (c) 1998-2001 Steve Murphree, Jr.
@@ -203,31 +203,30 @@ boolean_t pmap_testbit(struct vm_page *, int);
* va virtual address that should be flushed
* kernel TRUE if supervisor mode, FALSE if user mode
*/
-static __inline__ void
+static
+#ifndef MULTIPROCESSOR
+__inline__
+#endif
+void
flush_atc_entry(long users, vaddr_t va, boolean_t kernel)
{
-#if defined(MULTIPROCESSOR)
+#ifdef MULTIPROCESSOR
int cpu;
if (users == 0)
return;
-#ifdef DEBUG
- if (ff1(users) >= MAX_CPUS) {
- panic("flush_atc_entry: invalid ff1 users = %d", ff1(users));
- }
-#endif
-
while ((cpu = ff1(users)) != 32) {
- if (cpu_sets[cpu]) { /* just checking to make sure */
+#ifdef DIAGNOSTIC
+ if (m88k_cpus[cpu].ci_alive)
+#endif
cmmu_flush_tlb(cpu, kernel, va, 1);
- }
- users &= ~(1 << cpu);
+ users ^= 1 << cpu;
}
-#else
+#else /* MULTIPROCESSOR */
if (users != 0)
cmmu_flush_tlb(cpu_number(), kernel, va, 1);
-#endif
+#endif /* MULTIPROCESSOR */
}
/*
@@ -448,7 +447,7 @@ pmap_cache_ctrl(pmap_t pmap, vaddr_t s, vaddr_t e, u_int mode)
vaddr_t va;
paddr_t pa;
boolean_t kflush;
- int cpu;
+ cpuid_t cpu;
u_int users;
#ifdef DEBUG
@@ -489,8 +488,12 @@ pmap_cache_ctrl(pmap_t pmap, vaddr_t s, vaddr_t e, u_int mode)
* Data cache should be copied back and invalidated.
*/
pa = ptoa(PG_PFNUM(*pte));
+#ifdef MULTIPROCESSOR
for (cpu = 0; cpu < MAX_CPUS; cpu++)
- if (cpu_sets[cpu])
+ if (m88k_cpus[cpu].ci_alive != 0)
+#else
+ cpu = cpu_number();
+#endif
cmmu_flush_cache(cpu, pa, PAGE_SIZE);
}
PMAP_UNLOCK(pmap, spl);
@@ -543,6 +546,9 @@ pmap_bootstrap(vaddr_t load_start)
paddr_t s_text, e_text, kpdt_phys;
unsigned int kernel_pmap_size, pdt_size;
int i;
+#ifndef MULTIPROCESSOR
+ cpuid_t cpu;
+#endif
pmap_table_t ptable;
extern void *etext;
@@ -724,17 +730,19 @@ pmap_bootstrap(vaddr_t load_start)
CACHE_GLOBAL | CACHE_WT | APR_V;
/* Invalidate entire kernel TLB and get ready for address translation */
- for (i = 0; i < MAX_CPUS; i++)
- if (cpu_sets[i]) {
- cmmu_flush_tlb(i, TRUE, VM_MIN_KERNEL_ADDRESS,
- btoc(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS));
- /* Load supervisor pointer to segment table. */
- cmmu_set_sapr(i, kernel_pmap->pm_apr);
+#ifdef MULTIPROCESSOR
+ pmap_bootstrap_cpu(cpu_number());
+#else
+ cpu = cpu_number();
+ cmmu_flush_tlb(cpu, TRUE, VM_MIN_KERNEL_ADDRESS,
+ btoc(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS));
+ /* Load supervisor pointer to segment table. */
+ cmmu_set_sapr(cpu, kernel_pmap->pm_apr);
#ifdef DEBUG
- printf("cpu%d: running virtual\n", i);
+ printf("cpu%d: running virtual\n", cpu);
#endif
- SETBIT_CPUSET(i, &kernel_pmap->pm_cpus);
- }
+ SETBIT_CPUSET(cpu, &kernel_pmap->pm_cpus);
+#endif /* MULTIPROCESSOR */
}
/*
diff --git a/sys/arch/m88k/m88k/process.S b/sys/arch/m88k/m88k/process.S
index 5b3b139e343..fc60307c3ae 100644
--- a/sys/arch/m88k/m88k/process.S
+++ b/sys/arch/m88k/m88k/process.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: process.S,v 1.10 2005/11/27 11:06:15 miod Exp $ */
+/* $OpenBSD: process.S,v 1.11 2005/12/03 14:30:06 miod Exp $ */
/*
* Copyright (c) 1996 Nivas Madhur
* All rights reserved.
@@ -70,19 +70,17 @@ ASLOCAL(Lswsrunpanic)
ENTRY(switch_exit)
/*
* Change pcb to idle u. area, i.e., set r31 to top of stack
- * and set curpcb to point to _idle_u.
+ * and set curpcb to point to the cpu's idle stack.
* r2 contains proc *p.
*/
- or.u r30, r0, hi16(_C_LABEL(idle_u))
- or r30, r30,lo16(_C_LABEL(idle_u))
- addu r31, r30, USIZE /* now on idle_u stack */
- or.u r10, r0, hi16(_C_LABEL(curpcb))
- st r30, r10,lo16(_C_LABEL(curpcb)) /* curpcb = &idle_u */
+ ldcr r10, CPU
+ ld r30, r10, CI_IDLE_PCB
+ addu r31, r30, USIZE /* now on idle stack */
+ st r30, r10, CI_CURPCB /* curpcb = idle_pcb */
/* Schedule the vmspace and stack to be freed. */
- or.u r10, r0, hi16(_C_LABEL(curproc))
bsr.n _C_LABEL(exit2)
- st r0, r10, lo16(_C_LABEL(curproc)) /* curproc = NULL */
+ st r0, r10, CI_CURPROC /* curproc = NULL */
/*
* exit2() has acquired the scheduler lock for us. Jump into
@@ -96,20 +94,24 @@ ENTRY(switch_exit)
*
* Find a runnable process and switch to it. On entry, the scheduler lock is
* held; it has to be released before returning to the process.
+ *
+ * Note that this code ignores its proc parameter and assumes it has the
+ * same value as curproc. This may change in mi_switch() in the future,
+ * be careful.
*/
ENTRY(cpu_switch)
/*
* Save state of previous process in its pcb, and pmap_deactivate()
* the process.
*/
- or.u r2, r0, hi16(_C_LABEL(curpcb))
- ld r2, r2, lo16(_C_LABEL(curpcb))
- st r1, r2, PCB_PC /* save return address */
+ ldcr r2, CPU
+ ld r2, r2, CI_CURPCB
+ st r1, r2, PCB_PC /* save return address */
bsr _ASM_LABEL(__savectx)
/* note that we don't need to recover r1 at this point */
- or.u r11, r0, hi16(_C_LABEL(curproc))
- ld r2, r11, lo16(_C_LABEL(curproc))
+ ldcr r11, CPU
+ ld r2, r11, CI_CURPROC
/*
* Note that we can still use curpcb as our stack after
@@ -117,7 +119,7 @@ ENTRY(cpu_switch)
* area mappings.
*/
bsr.n _C_LABEL(pmap_deactivate)
- st r0, r11, lo16(_C_LABEL(curproc)) /* curproc = NULL */
+ st r0, r11, CI_CURPROC /* curproc = NULL */
ASLOCAL(cpu_switch_search)
/*
@@ -206,62 +208,57 @@ ASLOCAL(cpu_switch_found)
bb1 ne, r2, _ASM_LABEL(Lswsrunpanic)
#endif
- or.u r11, r0, hi16(_C_LABEL(want_resched))
- st r0, r11, lo16(_C_LABEL(want_resched)) /* clear want_resched */
+ ldcr r11, CPU
+ st r0, r11, CI_WANT_RESCHED /* clear want_resched */
- or.u r11, r0, hi16(_C_LABEL(curproc))
- st r9, r11,lo16(_C_LABEL(curproc)) /* curproc = p */
- or r2, r0, SONPROC
- st.b r2, r9, P_STAT
+ st r9, r11, CI_CURPROC /* curproc = p */
+ or r2, r0, SONPROC
+ st.b r2, r9, P_STAT
- /* r9 is curproc */
- st r0, r9, P_BACK /* p->p_back = 0 */
- ld r3, r9, P_ADDR
- or.u r10, r0, hi16(_C_LABEL(curpcb))
- st r3, r10, lo16(_C_LABEL(curpcb)) /* curpcb = p->p_addr */
+ ld r3, r9, P_ADDR
+ st r0, r9, P_BACK /* p->p_back = 0 */
+ st r3, r11, CI_CURPCB /* curpcb = p->p_addr */
/* pmap_activate() the process' pmap */
- or r14, r0, r9 /* save p in r14 */
bsr.n _C_LABEL(pmap_activate)
or r2, r0, r9
- or r9, r0, r14 /* restore p saved in r14 */
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
bsr _C_LABEL(sched_unlock_idle)
#endif
- or.u r10, r0, hi16(_C_LABEL(curpcb))
- ld r10, r10, lo16(_C_LABEL(curpcb))
+ ldcr r10, CPU
+ ld r10, r10, CI_CURPCB
/* restore from the current context */
- ld r2, r10, PCB_FCR62
- ld r3, r10, PCB_FCR63
- fstcr r2, fcr62
- fstcr r3, fcr63
- ld r15,r10, PCB_R15
- ld r16,r10, PCB_R16
- ld r17,r10, PCB_R17
- ld r18,r10, PCB_R18
- ld r19,r10, PCB_R19
- ld r20,r10, PCB_R20
- ld r21,r10, PCB_R21
- ld r22,r10, PCB_R22
- ld r23,r10, PCB_R23
- ld r24,r10, PCB_R24
- ld r25,r10, PCB_R25
- ld r26,r10, PCB_R26
- ld r27,r10, PCB_R27
- ld r28,r10, PCB_R28
- ld r29,r10, PCB_R29
- or r14,r10, r0 /* preserve curpcb in a register... */
+ ld r2, r10, PCB_FCR62
+ ld r3, r10, PCB_FCR63
+ fstcr r2, fcr62
+ fstcr r3, fcr63
+ ld r15, r10, PCB_R15
+ ld r16, r10, PCB_R16
+ ld r17, r10, PCB_R17
+ ld r18, r10, PCB_R18
+ ld r19, r10, PCB_R19
+ ld r20, r10, PCB_R20
+ ld r21, r10, PCB_R21
+ ld r22, r10, PCB_R22
+ ld r23, r10, PCB_R23
+ ld r24, r10, PCB_R24
+ ld r25, r10, PCB_R25
+ ld r26, r10, PCB_R26
+ ld r27, r10, PCB_R27
+ ld r28, r10, PCB_R28
+ ld r29, r10, PCB_R29
+ or r14, r10, r0 /* preserve curpcb in a register... */
bsr.n _C_LABEL(setipl)
- ld r2, r10, PCB_IPL /* restore interrupt mask */
- ld r1, r14, PCB_PC
- ld r30,r14, PCB_R30 /* restore frame pointer & stack */
- ld r31,r14, PCB_SP
+ ld r2, r10, PCB_IPL /* restore interrupt mask */
+ ld r1, r14, PCB_PC
+ ld r30, r14, PCB_R30 /* restore frame pointer & stack */
+ ld r31, r14, PCB_SP
jmp.n r1
- ld r14,r14, PCB_R14
+ ld r14, r14, PCB_R14
/*
* savectx(pcb)
diff --git a/sys/arch/m88k/m88k/subr.S b/sys/arch/m88k/m88k/subr.S
index 8a9d909e0d2..247190c49dd 100644
--- a/sys/arch/m88k/m88k/subr.S
+++ b/sys/arch/m88k/m88k/subr.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr.S,v 1.8 2005/10/13 19:48:33 miod Exp $ */
+/* $OpenBSD: subr.S,v 1.9 2005/12/03 14:30:06 miod Exp $ */
/*
* Mach Operating System
* Copyright (c) 1993-1992 Carnegie Mellon University
@@ -194,8 +194,8 @@ ENTRY(do_xmem_byte) /* do_xmem_byte(address, data, supervisor) */
ENTRY(copyin)
/* set up fault handler */
- or.u r5, r0, hi16(_C_LABEL(curpcb))
- ld r6, r5, lo16(_C_LABEL(curpcb))
+ ldcr r5, CPU
+ ld r6, r5, CI_CURPCB
or.u r5, r0, hi16(_ASM_LABEL(Lciflt))
or r5, r5, lo16(_ASM_LABEL(Lciflt))
st r5, r6, PCB_ONFAULT /* pcb_onfault = Lciflt */
@@ -231,7 +231,7 @@ ASLOCAL(copyin_right_aligned_to_halfword)
ASLOCAL(copyin_right_aligned_to_word)
/* At this point, both SRC and DEST are aligned to a word */
- /* boundry, and LEN is an even multiple of 4. */
+ /* boundary, and LEN is an even multiple of 4. */
bb1.n 2, LEN, _ASM_LABEL(copyin_right_align_to_doubleword)
or r7, r0, 4
@@ -357,8 +357,8 @@ ASLOCAL(copyin_byte_only)
or r2, r0, r0 /* successful return */
ASLOCAL(Lcidone)
- or.u r5,r0,hi16(_C_LABEL(curpcb))
- ld r6,r5,lo16(_C_LABEL(curpcb))
+ ldcr r5, CPU
+ ld r6, r5, CI_CURPCB
jmp.n r1
st r0,r6,PCB_ONFAULT
@@ -391,8 +391,8 @@ ASLOCAL(Lciflt)
ENTRY(copyinstr)
/* setup fault handler */
- or.u r6, r0, hi16(_C_LABEL(curpcb))
- ld r7, r6, lo16(_C_LABEL(curpcb))
+ ldcr r6, CPU
+ ld r7, r6, CI_CURPCB
or.u r6, r0, hi16(_ASM_LABEL(Lcisflt))
or r6, r6, lo16(_ASM_LABEL(Lcisflt))
st r6, r7, PCB_ONFAULT
@@ -432,8 +432,8 @@ ASLOCAL(Lcisdone)
bcnd eq0, LEN, 3f
st r6, r0, LEN
3:
- or.u r5,r0,hi16(_C_LABEL(curpcb))
- ld r6,r5,lo16(_C_LABEL(curpcb))
+ ldcr r5, CPU
+ ld r6, r5, CI_CURPCB
jmp.n r1
st r0,r6,PCB_ONFAULT /* clear the handler */
@@ -460,8 +460,8 @@ ASLOCAL(Lcisflt)
ENTRY(copyout)
/* setup fault handler */
- or.u r5, r0, hi16(_C_LABEL(curpcb))
- ld r6, r5, lo16(_C_LABEL(curpcb))
+ ldcr r5, CPU
+ ld r6, r5, CI_CURPCB
or.u r5, r0, hi16(_ASM_LABEL(Lcoflt))
or r5, r5, lo16(_ASM_LABEL(Lcoflt))
st r5, r6, PCB_ONFAULT /* pcb_onfault = Lcoflt */
@@ -496,7 +496,7 @@ ASLOCAL(copyout_right_aligned_to_word)
/*
* At this point, both SRC and DEST are aligned to a word
- * boundry, and LEN is an even multiple of 4.
+ * boundary, and LEN is an even multiple of 4.
*/
bb1.n 2, LEN, _ASM_LABEL(copyout_right_align_to_doubleword)
or r7, r0, 4
@@ -631,8 +631,8 @@ ASLOCAL(copyout_byte_only)
or r2, r0, r0 /* successful return */
ASLOCAL(Lcodone)
- or.u r5,r0,hi16(_C_LABEL(curpcb))
- ld r6,r5,lo16(_C_LABEL(curpcb))
+ ldcr r5, CPU
+ ld r6, r5, CI_CURPCB
jmp.n r1
st r0,r6,PCB_ONFAULT /* clear the handler */
@@ -662,8 +662,8 @@ ASLOCAL(Lcoflt)
ENTRY(copyoutstr)
/* setup fault handler */
- or.u r6, r0, hi16(_C_LABEL(curpcb))
- ld r7, r6, lo16(_C_LABEL(curpcb))
+ ldcr r6, CPU
+ ld r7, r6, CI_CURPCB
or.u r6, r0, hi16(_ASM_LABEL(Lcosflt))
or r6, r6, lo16(_ASM_LABEL(Lcosflt))
st r6, r7, PCB_ONFAULT
@@ -698,8 +698,9 @@ ASLOCAL(Lcosflt)
ASLOCAL(Lcosdone)
bcnd eq0, LEN, 3f
st r6, r0, LEN
-3: or.u r5,r0,hi16(_C_LABEL(curpcb))
- ld r6,r5,lo16(_C_LABEL(curpcb))
+3:
+ ldcr r5, CPU
+ ld r6, r5, CI_CURPCB
jmp.n r1
st r0,r6,PCB_ONFAULT /* clear the handler */
@@ -716,8 +717,8 @@ ASLOCAL(Lcosdone)
* Copy len bytes from src to dst, aborting if we encounter a page fault.
*/
ENTRY(kcopy)
- or.u r5, r0, hi16(_C_LABEL(curpcb))
- ld r6, r5, lo16(_C_LABEL(curpcb))
+ ldcr r5, CPU
+ ld r6, r5, CI_CURPCB
or.u r5, r0, hi16(_ASM_LABEL(kcopy_fault))
or r5, r5, lo16(_ASM_LABEL(kcopy_fault))
st r5, r6, PCB_ONFAULT /* pcb_onfault = kcopy_fault */
@@ -968,8 +969,8 @@ ASLOCAL(kr_byte_copy)
ASLOCAL(kcopy_out)
or r2, r0, 0 /* return success */
ASLOCAL(kcopy_out_fault)
- or.u r5,r0,hi16(_C_LABEL(curpcb))
- ld r6,r5,lo16(_C_LABEL(curpcb))
+ ldcr r5, CPU
+ ld r6, r5, CI_CURPCB
st r0,r6,PCB_ONFAULT /* clear the handler */
jmp r1 /* all done, return to caller */
@@ -1548,54 +1549,6 @@ ENTRY(read_processor_identification_register)
ldcr r2, PID
/*
- * void set_cpu_number(unsigned number);
- *
- * Sets the kernel cpu number for this cpu to the given value.
- *
- * Input:
- * r1 return address
- * r2 the number (should be 0, 1, 2, or 3).
- *
- * Other registers used:
- * r3 temp
- * r4 original PSR
- * r5 temporary new PSR
- */
-ENTRY(set_cpu_number)
-#ifdef DEBUG
- /* make sure the CPU number is valid */
- clr r3, r2, FLAG_CPU_FIELD_WIDTH<0>
- bcnd ne0, r3, 1f /* bad cpu number */
-#endif
-
- /* going to change a control register -- disable interrupts */
- ldcr r4, PSR
- set r5, r4, 1<PSR_INTERRUPT_DISABLE_BIT>
- stcr r5, PSR
- FLUSH_PIPELINE
-
- /* put in the cpu number */
- ldcr r3, SR1 /* get the flags */
- clr r3, r3, FLAG_CPU_FIELD_WIDTH<0> /* clean the slate */
- or r3, r3, r2 /* add the cpu number */
- stcr r3, SR1 /* put back */
-
- /* put back the PSR to what it was before and return */
- stcr r4, PSR
- FLUSH_PIPELINE
- jmp r1
-
-#ifdef DEBUG
-1: /* bad cpu number*/
- or.u r2, r0, hi16(9f)
- bsr.n _C_LABEL(panic)
- or r2, r2, lo16(9f)
-
- data
-9: string "set_cpu_number: bad CPU number %x\0"
-#endif
-
-/*
* Trampoline code. Gets copied to the top of
* user stack in exec.
*/
diff --git a/sys/arch/m88k/m88k/trap.c b/sys/arch/m88k/m88k/trap.c
index 6eeec2a197c..bfcda591eb7 100644
--- a/sys/arch/m88k/m88k/trap.c
+++ b/sys/arch/m88k/m88k/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.24 2005/12/01 22:24:52 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.25 2005/12/03 14:30:06 miod Exp $ */
/*
* Copyright (c) 2004, Miodrag Vallat.
* Copyright (c) 1998 Steve Murphree, Jr.
@@ -122,13 +122,14 @@ static inline void
userret(struct proc *p, struct trapframe *frame, u_quad_t oticks)
{
int sig;
+ struct cpu_info *cpu = curcpu();
/* take pending signals */
while ((sig = CURSIG(p)) != 0)
postsig(sig);
p->p_priority = p->p_usrpri;
- if (want_resched) {
+ if (cpu->ci_want_resched) {
/*
* We're being preempted.
*/
@@ -146,7 +147,7 @@ userret(struct proc *p, struct trapframe *frame, u_quad_t oticks)
addupc_task(p, frame->tf_sxip & XIP_ADDR,
(int)(p->p_sticks - oticks) * psratio);
}
- curpriority = p->p_priority;
+ cpu->ci_schedstate.spc_curpriority = p->p_priority;
}
__dead void
@@ -260,9 +261,9 @@ m88100_trap(unsigned type, struct trapframe *frame)
/* This function pointer is set in machdep.c
It calls m188_ext_int or sbc_ext_int depending
on the value of brdtyp - smurph */
- intrdepth++;
+ curcpu()->ci_intrdepth++;
md_interrupt_func(T_INT, frame);
- intrdepth--;
+ curcpu()->ci_intrdepth--;
return;
case T_MISALGNFLT:
@@ -277,7 +278,7 @@ m88100_trap(unsigned type, struct trapframe *frame)
*/
#ifdef TRAPDEBUG
pbus_type = CMMU_PFSR_FAULT(frame->tf_ipfsr);
- printf("Kernel Instruction fault #%d (%s) v = 0x%x, frame 0x%x cpu %d\n",
+ printf("Kernel Instruction fault #%d (%s) v = 0x%x, frame 0x%x cpu %p\n",
pbus_type, pbus_exception_type[pbus_type],
fault_addr, frame, frame->tf_cpu);
#endif
@@ -312,7 +313,7 @@ m88100_trap(unsigned type, struct trapframe *frame)
pbus_type = CMMU_PFSR_FAULT(frame->tf_dpfsr);
#ifdef TRAPDEBUG
- printf("Kernel Data access fault #%d (%s) v = 0x%x, frame 0x%x cpu %d\n",
+ printf("Kernel Data access fault #%d (%s) v = 0x%x, frame 0x%x cpu %p\n",
pbus_type, pbus_exception_type[pbus_type],
fault_addr, frame, frame->tf_cpu);
#endif
@@ -362,7 +363,7 @@ user_fault:
if (type == T_INSTFLT + T_USER) {
pbus_type = CMMU_PFSR_FAULT(frame->tf_ipfsr);
#ifdef TRAPDEBUG
- printf("User Instruction fault #%d (%s) v = 0x%x, frame 0x%x cpu %d\n",
+ printf("User Instruction fault #%d (%s) v = 0x%x, frame 0x%x cpu %p\n",
pbus_type, pbus_exception_type[pbus_type],
fault_addr, frame, frame->tf_cpu);
#endif
@@ -370,7 +371,7 @@ user_fault:
fault_addr = frame->tf_dma0;
pbus_type = CMMU_PFSR_FAULT(frame->tf_dpfsr);
#ifdef TRAPDEBUG
- printf("User Data access fault #%d (%s) v = 0x%x, frame 0x%x cpu %d\n",
+ printf("User Data access fault #%d (%s) v = 0x%x, frame 0x%x cpu %p\n",
pbus_type, pbus_exception_type[pbus_type],
fault_addr, frame, frame->tf_cpu);
#endif
@@ -695,15 +696,15 @@ m88110_trap(unsigned type, struct trapframe *frame)
break;
case T_NON_MASK:
case T_NON_MASK+T_USER:
- intrdepth++;
+ curcpu()->ci_intrdepth++;
md_interrupt_func(T_NON_MASK, frame);
- intrdepth--;
+ curcpu()->ci_intrdepth--;
return;
case T_INT:
case T_INT+T_USER:
- intrdepth++;
+ curcpu()->ci_intrdepth++;
md_interrupt_func(T_INT, frame);
- intrdepth--;
+ curcpu()->ci_intrdepth--;
return;
case T_MISALGNFLT:
printf("kernel mode misaligned access exception @ 0x%08x\n",
@@ -1102,9 +1103,6 @@ m88100_syscall(register_t code, struct trapframe *tf)
int error;
register_t args[11], rval[2], *ap;
u_quad_t sticks;
-#ifdef DIAGNOSTIC
- extern struct pcb *curpcb;
-#endif
uvmexp.syscalls++;
@@ -1263,9 +1261,6 @@ m88110_syscall(register_t code, struct trapframe *tf)
int error;
register_t args[11], rval[2], *ap;
u_quad_t sticks;
-#ifdef DIAGNOSTIC
- extern struct pcb *curpcb;
-#endif
uvmexp.syscalls++;
diff --git a/sys/arch/m88k/m88k/vm_machdep.c b/sys/arch/m88k/m88k/vm_machdep.c
index 6baa75f7f4d..d1e761062bb 100644
--- a/sys/arch/m88k/m88k/vm_machdep.c
+++ b/sys/arch/m88k/m88k/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.7 2005/10/13 19:48:33 miod Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.8 2005/12/03 14:30:06 miod Exp $ */
/*
* Copyright (c) 1998 Steve Murphree, Jr.
@@ -88,7 +88,6 @@ cpu_fork(p1, p2, stack, stacksize, func, arg)
void (*func)(void *);
void *proc;
} *ksfp;
- extern struct pcb *curpcb;
extern void proc_trampoline(void);
/* Copy pcb from p1 to p2. */
@@ -202,26 +201,7 @@ cpu_coredump(p, vp, cred, chdr)
}
/*
- * Map an IO request into kernel virtual address space. Requests fall into
- * one of five catagories:
- *
- * B_PHYS|B_UAREA: User u-area swap.
- * Address is relative to start of u-area (p_addr).
- * B_PHYS|B_PAGET: User page table swap.
- * Address is a kernel VA in usrpt (Usrptmap).
- * B_PHYS|B_DIRTY: Dirty page push.
- * Address is a VA in proc2's address space.
- * B_PHYS|B_PGIN: Kernel pagein of user pages.
- * Address is VA in user's address space.
- * B_PHYS: User "raw" IO request.
- * Address is VA in user's address space.
- *
- * All requests are (re)mapped into kernel VA space via phys_map
- *
- * XXX we allocate KVA space by using kmem_alloc_wait which we know
- * allocates space without backing physical memory. This implementation
- * is a total crock, the multiple mappings of these physical pages should
- * be reflected in the higher-level VM structures to avoid problems.
+ * Map an IO request into kernel virtual address space via phys_map.
*/
void
vmapbuf(bp, len)
diff --git a/sys/arch/mvme88k/include/locore.h b/sys/arch/mvme88k/include/locore.h
index a9485069234..d73a4e53f2a 100644
--- a/sys/arch/mvme88k/include/locore.h
+++ b/sys/arch/mvme88k/include/locore.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.h,v 1.28 2005/09/13 19:12:21 miod Exp $ */
+/* $OpenBSD: locore.h,v 1.29 2005/12/03 14:30:06 miod Exp $ */
#ifndef _MACHINE_LOCORE_H_
#define _MACHINE_LOCORE_H_
@@ -12,17 +12,14 @@
unsigned read_processor_identification_register(void);
int badaddr(vaddr_t addr, int size);
#define badwordaddr(x) badaddr(x, 4)
-void set_cpu_number(unsigned number);
void doboot(void);
-/* locore_c_routines.c */
-
-unsigned getipl(void);
-
/* machdep.c */
+unsigned getipl(void);
int intr_findvec(int, int, int);
-void myetheraddr(u_char *cp);
+void myetheraddr(u_char *);
+void set_cpu_number(cpuid_t);
extern volatile u_int8_t *ivec[];
diff --git a/sys/arch/mvme88k/mvme88k/eh.S b/sys/arch/mvme88k/mvme88k/eh.S
index 0f0ebe8967f..dd0d2041331 100644
--- a/sys/arch/mvme88k/mvme88k/eh.S
+++ b/sys/arch/mvme88k/mvme88k/eh.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: eh.S,v 1.62 2004/08/05 21:34:11 miod Exp $ */
+/* $OpenBSD: eh.S,v 1.63 2005/12/03 14:30:06 miod Exp $ */
/*
* Mach Operating System
* Copyright (c) 1993-1991 Carnegie Mellon University
@@ -94,8 +94,9 @@ ASLOCAL(pfsr188)
or.u TMP, r0, hi16(_C_LABEL(cmmu_shift))
ld TMP, TMP, lo16(_C_LABEL(cmmu_shift))
cmp TMP2, TMP, 2
+ ldcr TMP, CPU
bb1.n lt, TMP2, _ASM_LABEL(pfsr188_straight)
- extu TMP, FLAGS, FLAG_CPU_FIELD_WIDTH<0> /* TMP = cpu# */
+ ld TMP, TMP, CI_CPUID /* TMP = cpu# */
bb1 eq, TMP2, _ASM_LABEL(pfsr188_double)
ASLOCAL(pfsr188_quad)
diff --git a/sys/arch/mvme88k/mvme88k/locore.S b/sys/arch/mvme88k/mvme88k/locore.S
index 28eb135208f..3fc6f43e4f2 100644
--- a/sys/arch/mvme88k/mvme88k/locore.S
+++ b/sys/arch/mvme88k/mvme88k/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.43 2005/10/12 19:32:19 miod Exp $ */
+/* $OpenBSD: locore.S,v 1.44 2005/12/03 14:30:06 miod Exp $ */
/*
* Copyright (c) 1998 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -197,12 +197,12 @@ GLOBAL(start_text)
* The manual says not to disable interrupts and freeze shadowing
* at the same time because interrupts are not actually disabled
* until after the next instruction. Well, if an interrupt
- * occurs now, we're in deep anyway, so I'm going to do
+ * occurs now, we're in deep trouble anyway, so I'm going to do
* the two together.
*
* Upon a reset (or poweron, I guess), the PSR indicates:
* supervisor mode
- * interrupts, shadowing, FPU, missaligned exception: all disabled
+ * interrupts, shadowing, FPU, misaligned exception: all disabled
*
* We'll just construct our own turning on what we want.
*
@@ -213,7 +213,6 @@ GLOBAL(start_text)
bb1 eq, r2, 1f /* if it's a 'mc88110, skip SSBR */
stcr r0, SSBR /* clear this for later */
1:
- stcr r0, SR0 /* clear "current thread" */
stcr r0, SR1 /* clear the CPU flags */
set r11, r0, 1<PSR_SUPERVISOR_MODE_BIT>
@@ -319,7 +318,6 @@ ASLOCAL(master_start)
*/
or.u r31, r0, hi16(_ASM_LABEL(intstack_end))
or r31, r31, lo16(_ASM_LABEL(intstack_end))
- clr r31, r31, 3<0> /* round down to 8-byte boundary */
#ifdef M88110
#ifdef M88100
@@ -349,8 +347,8 @@ ASLOCAL(master_start)
/*
* ...and we can switch to the u area stack now.
*/
- or.u r10, r0, hi16(_C_LABEL(curpcb))
- ld r31, r10,lo16(_C_LABEL(curpcb))
+ ldcr r10, CPU
+ ld r31, r10, CI_CURPCB
addu r31, r31, USIZE
/* call main() - no arguments although main() still defines one */
@@ -417,12 +415,6 @@ GLOBAL(spin_cpu)
* The processor loops (busy waits) for the given number of microseconds:
* Thus, delay(1000000) will delay for one second.
* (originally from Mach 2.5)
- *
- * REGISTER USAGE:
- * IN r1 - return address
- * IN r2 - number of microseconds
- * r3 - cpu speed in MHz
- * r4 - number of cycles to delay
*/
GLOBAL(m188_delay)
or.u r3, r0, hi16(_cpuspeed)
@@ -447,7 +439,7 @@ GLOBAL(kernel_sdt) /* SDT (segment descriptor table */
.align NBPG
GLOBAL(intstack)
- space INTSTACK_SIZE /* 16K, just to be safe */
+ space USIZE
ASGLOBAL(intstack_end)
ASGLOBAL(slavestack)
space NBPG /* 4K, small, interim stack */
@@ -464,7 +456,7 @@ ASGLOBAL(slavestack_end)
*/
.align NBPG
GLOBAL(idle_u)
- space UPAGES * NBPG
+ space USIZE
/*
* Process 0's u.
@@ -474,6 +466,8 @@ GLOBAL(idle_u)
.align NBPG
ASLOCAL(u0)
space UPAGES * NBPG
+GLOBAL(proc0paddr)
+ word _ASM_LABEL(u0) /* KVA of proc0 uarea */
GLOBAL(ret_addr)
word 0
@@ -489,21 +483,8 @@ ASLOCAL(master_processor_chosen)
/* XMEM spin lock -- controls access to master_processor_chosen */
ASLOCAL(inter_processor_lock)
word 0
+
#if defined(DDB) || NKSYMS > 0
GLOBAL(esym)
word 0
#endif /* DDB || NKSYMS > 0 */
-GLOBAL(proc0paddr)
- word _ASM_LABEL(u0) /* KVA of proc0 uarea */
-
-/*
- * curpcb points to the current pcb (and hence u. area).
- * Initially this is the special one.
- */
-/*
- * pcb is composed of kernel state + user state
- * I may have to change curpcb to u0 + PCB_USER based on what
- * other parts expect XXX nivas
- */
-GLOBAL(curpcb)
- word _ASM_LABEL(u0) /* curpcb = &u0 */
diff --git a/sys/arch/mvme88k/mvme88k/m188_machdep.c b/sys/arch/mvme88k/mvme88k/m188_machdep.c
index a64c3560b3a..5478fbe535c 100644
--- a/sys/arch/mvme88k/mvme88k/m188_machdep.c
+++ b/sys/arch/mvme88k/mvme88k/m188_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: m188_machdep.c,v 1.10 2005/10/13 19:48:36 miod Exp $ */
+/* $OpenBSD: m188_machdep.c,v 1.11 2005/12/03 14:30:06 miod Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -241,8 +241,10 @@ m188_setipl(u_int level)
curspl = m188_curspl[cpu];
mask = int_mask_val[level];
+#ifdef MULTIPROCESSOR
if (cpu != master_cpu)
mask &= SLAVE_MASK;
+#endif
*int_mask_reg[cpu] = mask;
m188_curspl[cpu] = level;
@@ -259,8 +261,10 @@ m188_raiseipl(u_int level)
curspl = m188_curspl[cpu];
if (curspl < level) {
mask = int_mask_val[level];
+#ifdef MULTIPROCESSOR
if (cpu != master_cpu)
mask &= SLAVE_MASK;
+#endif
*int_mask_reg[cpu] = mask;
m188_curspl[cpu] = level;
diff --git a/sys/arch/mvme88k/mvme88k/m88110.c b/sys/arch/mvme88k/mvme88k/m88110.c
index 884e6e97cde..e4d8726e9b4 100644
--- a/sys/arch/mvme88k/mvme88k/m88110.c
+++ b/sys/arch/mvme88k/mvme88k/m88110.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: m88110.c,v 1.28 2005/12/02 21:16:45 miod Exp $ */
+/* $OpenBSD: m88110.c,v 1.29 2005/12/03 14:30:06 miod Exp $ */
/*
* Copyright (c) 1998 Steve Murphree, Jr.
* All rights reserved.
@@ -189,7 +189,6 @@ m88110_setup_board_config(void)
{
/* we could print something here... */
max_cpus = 1;
- cpu_sets[0] = 1; /* This cpu installed... */
}
/*
diff --git a/sys/arch/mvme88k/mvme88k/m8820x.c b/sys/arch/mvme88k/mvme88k/m8820x.c
index 180f743b5da..8183d3cf4a0 100644
--- a/sys/arch/mvme88k/mvme88k/m8820x.c
+++ b/sys/arch/mvme88k/mvme88k/m8820x.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: m8820x.c,v 1.43 2005/12/02 21:16:45 miod Exp $ */
+/* $OpenBSD: m8820x.c,v 1.44 2005/12/03 14:30:06 miod Exp $ */
/*
* Copyright (c) 2004, Miodrag Vallat.
*
@@ -90,7 +90,6 @@ m8820x_setup_board_config()
u_int32_t whoami;
#endif
- master_cpu = 0; /* temp to get things going */
switch (brdtyp) {
#ifdef MVME187
case BRD_187:
@@ -162,7 +161,6 @@ m8820x_setup_board_config()
for (num = 0; num < max_cpus; num++) {
int type;
- cpu_sets[num] = 1; /* This cpu installed... */
type = CMMU_TYPE(m8820x_cmmu[num << cmmu_shift].
cmmu_regs[CMMU_IDR]);
diff --git a/sys/arch/mvme88k/mvme88k/machdep.c b/sys/arch/mvme88k/mvme88k/machdep.c
index 3cfc4e5798f..f02827d9703 100644
--- a/sys/arch/mvme88k/mvme88k/machdep.c
+++ b/sys/arch/mvme88k/mvme88k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.170 2005/11/28 22:21:16 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.171 2005/12/03 14:30:06 miod Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -141,7 +141,6 @@ volatile u_int8_t *ivec[8];
#endif
int ssir;
-int want_resched;
int physmem; /* available physical memory, in pages */
@@ -203,7 +202,6 @@ vaddr_t last_addr;
vaddr_t avail_start, avail_end;
vaddr_t virtual_avail, virtual_end;
-extern struct pcb *curpcb;
extern struct user *proc0paddr;
/*
@@ -1032,18 +1030,10 @@ mvme_bootstrap()
{
extern int kernelstart;
extern struct consdev *cn_tab;
-
struct mvmeprom_brdid brdid;
-
- /*
- * Must initialize p_addr before autoconfig or
- * the fault handler will get a NULL reference.
- * Do this early so that we can take a data or
- * instruction fault and survive it.
- */
- proc0.p_addr = proc0paddr;
- curproc = &proc0;
- curpcb = &proc0paddr->u_pcb;
+#ifndef MULTIPROCESSOR
+ u_int master_cpu;
+#endif
buginit();
bugbrdid(&brdid);
@@ -1111,6 +1101,16 @@ mvme_bootstrap()
set_cpu_number(master_cpu);
/*
+ * Now that set_cpu_number() set us with a valid cpu_info pointer,
+ * we need to initialize p_addr and curpcb before autoconf, for the
+ * fault handler to behave properly [except for badaddr() faults,
+ * which can be taken care of without a valid curcpu()].
+ */
+ proc0.p_addr = proc0paddr;
+ curproc = &proc0;
+ curpcb = &proc0paddr->u_pcb;
+
+ /*
* If we have more than one CPU, mention which one is the master.
* We will also want to spin up slave CPUs on the long run...
*/