diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2005-12-11 21:45:32 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2005-12-11 21:45:32 +0000 |
commit | f86bad4efd003c634555545a0f70a36406d90a16 (patch) | |
tree | 2fa8278055f297b53abf744c3ba0196fb34a59a3 /sys/arch/m88k | |
parent | 4aa16b6373f64a797a481dbfe9079dbe74597f4f (diff) |
Work in progress SMP code; mvme88k boards can spin up secondary CPUs,
kernel boots single user. Still a lot of polishing and bugfixing to do.
Diffstat (limited to 'sys/arch/m88k')
-rw-r--r-- | sys/arch/m88k/include/cmmu.h | 6 | ||||
-rw-r--r-- | sys/arch/m88k/include/cpu.h | 7 | ||||
-rw-r--r-- | sys/arch/m88k/include/pmap.h | 3 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/db_interface.c | 57 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/eh_common.S | 11 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/m8820x_machdep.c | 21 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/pmap.c | 39 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/process.S | 54 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/trap.c | 6 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/vm_machdep.c | 5 |
10 files changed, 140 insertions, 69 deletions
diff --git a/sys/arch/m88k/include/cmmu.h b/sys/arch/m88k/include/cmmu.h index c23a2f24b38..4a09689093a 100644 --- a/sys/arch/m88k/include/cmmu.h +++ b/sys/arch/m88k/include/cmmu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cmmu.h,v 1.15 2005/12/04 15:00:25 miod Exp $ */ +/* $OpenBSD: cmmu.h,v 1.16 2005/12/11 21:45:28 miod Exp $ */ /* * Mach Operating System * Copyright (c) 1993-1992 Carnegie Mellon University @@ -67,6 +67,9 @@ struct cmmu_p { void (*flush_data_cache)(cpuid_t, paddr_t, psize_t); int (*dma_cachectl)(pmap_t, vaddr_t, vsize_t, int); int (*dma_cachectl_pa)(paddr_t, psize_t, int); +#ifdef MULTIPROCESSOR + void (*initialize_cpu)(cpuid_t); +#endif }; extern struct cmmu_p *cmmu; @@ -84,6 +87,7 @@ extern struct cmmu_p *cmmu; #define cmmu_flush_data_cache(a, b, c) (cmmu->flush_data_cache)(a, b, c) #define dma_cachectl(a, b, c, d) (cmmu->dma_cachectl)(a, b, c, d) #define dma_cachectl_pa(a, b, c) (cmmu->dma_cachectl_pa)(a, b, c) +#define cmmu_initialize_cpu(a) (cmmu->initialize_cpu)(a) /* * dma_cachectl() modes diff --git a/sys/arch/m88k/include/cpu.h b/sys/arch/m88k/include/cpu.h index 161c7179dd5..bf975efb6ab 100644 --- a/sys/arch/m88k/include/cpu.h +++ b/sys/arch/m88k/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.11 2005/12/11 21:36:06 miod Exp $ */ +/* $OpenBSD: cpu.h,v 1.12 2005/12/11 21:45:28 miod Exp $ */ /* * Copyright (c) 1996 Nivas Madhur * Copyright (c) 1992, 1993 @@ -95,7 +95,10 @@ struct cpu_info { u_long ci_spin_locks; /* spin locks counter */ - /* XXX ddb state? */ + volatile int ci_ddb_state; /* ddb status */ +#define CI_DDB_RUNNING 0 +#define CI_DDB_ENTERDDB 1 +#define CI_DDB_INDDB 2 }; extern cpuid_t master_cpu; diff --git a/sys/arch/m88k/include/pmap.h b/sys/arch/m88k/include/pmap.h index e37a19c4c10..4585c8f66a3 100644 --- a/sys/arch/m88k/include/pmap.h +++ b/sys/arch/m88k/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.8 2005/12/03 19:06:08 miod Exp $ */ +/* $OpenBSD: pmap.h,v 1.9 2005/12/11 21:45:28 miod Exp $ */ /* * Mach Operating System * Copyright (c) 1991 Carnegie Mellon University @@ -63,6 +63,7 @@ extern caddr_t vmmap; #define pmap_clear_reference(pg) pmap_unsetbit(pg, PG_U) void pmap_bootstrap(vaddr_t); +void pmap_bootstrap_cpu(cpuid_t); void pmap_cache_ctrl(pmap_t, vaddr_t, vaddr_t, u_int); void pmap_proc_iflush(struct proc *, vaddr_t, vsize_t); #define pmap_unuse_final(p) /* nothing */ diff --git a/sys/arch/m88k/m88k/db_interface.c b/sys/arch/m88k/m88k/db_interface.c index cc856fd0def..b5f78a06d4e 100644 --- a/sys/arch/m88k/m88k/db_interface.c +++ b/sys/arch/m88k/m88k/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.3 2005/12/04 12:20:19 miod Exp $ */ +/* $OpenBSD: db_interface.c,v 1.4 2005/12/11 21:45:30 miod Exp $ */ /* * Mach Operating System * Copyright (c) 1993-1991 Carnegie Mellon University @@ -75,6 +75,13 @@ void m88k_db_cmmucfg(db_expr_t, int, db_expr_t, char *); db_regs_t ddb_regs; +#ifdef MULTIPROCESSOR +#include <sys/mplock.h> +struct __mp_lock ddb_mp_lock; + +void m88k_db_cpu_cmd(db_expr_t, int, db_expr_t, char *); +#endif + /* * If you really feel like understanding the following procedure and * macros, see pages 6-22 to 6-30 (Section 6.7.3) of @@ -399,6 +406,12 @@ m88k_db_trap(type, frame) } } +#ifdef MULTIPROCESSOR + curcpu()->ci_ddb_state = CI_DDB_ENTERDDB; + __mp_lock(&ddb_mp_lock); + curcpu()->ci_ddb_state = CI_DDB_INDDB; +#endif + ddb_regs = frame->tf_regs; cnpollc(TRUE); @@ -406,6 +419,11 @@ m88k_db_trap(type, frame) cnpollc(FALSE); frame->tf_regs = ddb_regs; + +#ifdef MULTIPROCESSOR + curcpu()->ci_ddb_state = CI_DDB_RUNNING; + __mp_release_all(&ddb_mp_lock); +#endif } extern const char *trap_type[]; @@ -598,11 +616,45 @@ m88k_db_frame_search(addr, have_addr, count, modif) db_printf("(Walked back until 0x%x)\n",addr); } +#ifdef MULTIPROCESSOR + +void +m88k_db_cpu_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) +{ + cpuid_t cpu; + struct cpu_info *ci; + + CPU_INFO_FOREACH(cpu, ci) { + db_printf("%c%4d: ", (cpu == cpu_number()) ? '*' : ' ', + CPU_INFO_UNIT(ci)); + switch (ci->ci_ddb_state) { + case CI_DDB_RUNNING: + db_printf("running\n"); + break; + case CI_DDB_ENTERDDB: + db_printf("entering ddb\n"); + break; + case CI_DDB_INDDB: + db_printf("ddb\n"); + break; + default: + db_printf("? (%d)\n", + ci->ci_ddb_state); + break; + } + } +} + +#endif /* MULTIPROCESSOR */ + /************************/ /* COMMAND TABLE / INIT */ /************************/ struct db_command db_machine_cmds[] = { +#ifdef MULTIPROCESSOR + { "cpu", m88k_db_cpu_cmd, 0, NULL }, +#endif { "frame", m88k_db_print_frame, 0, NULL }, { "regs", m88k_db_registers, 0, NULL }, { "searchframe",m88k_db_frame_search, 0, NULL }, @@ -617,4 +669,7 @@ void db_machine_init() { db_machine_commands_install(db_machine_cmds); +#ifdef MULTIPROCESSOR + __mp_lock_init(&ddb_mp_lock); +#endif } diff --git a/sys/arch/m88k/m88k/eh_common.S b/sys/arch/m88k/m88k/eh_common.S index ab1290617ad..868707dae99 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.15 2005/12/03 18:20:50 miod Exp $ */ +/* $OpenBSD: eh_common.S,v 1.16 2005/12/11 21:45:30 miod Exp $ */ /* * Mach Operating System * Copyright (c) 1993-1991 Carnegie Mellon University @@ -222,9 +222,9 @@ * in a rather precarious state and so special cautions must * be taken. */ -#define FLAG_IGNORE_DATA_EXCEPTION 5 -#define FLAG_ENABLING_FPU 7 -#define FLAG_FROM_KERNEL 8 +#define FLAG_IGNORE_DATA_EXCEPTION 0 +#define FLAG_ENABLING_FPU 1 +#define FLAG_FROM_KERNEL 2 /* REGister OFFset into the E.F. (exception frame) */ #define REG_OFF(reg_num) ((reg_num) * 4) /* (num * sizeof(register_t)) */ @@ -1591,6 +1591,9 @@ ASLOCAL(m88100_fpu_enable) */ ENTRY(proc_trampoline) +#ifdef MULTIPROCESSOR + bsr _C_LABEL(proc_trampoline_mp) +#endif ld r1, r31, 0 /* load func */ ld r2, r31, 4 /* load proc pointer */ jsr.n r1 diff --git a/sys/arch/m88k/m88k/m8820x_machdep.c b/sys/arch/m88k/m88k/m8820x_machdep.c index 34310fe0f26..8d25d48b9d7 100644 --- a/sys/arch/m88k/m88k/m8820x_machdep.c +++ b/sys/arch/m88k/m88k/m8820x_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m8820x_machdep.c,v 1.17 2005/12/10 22:31:38 miod Exp $ */ +/* $OpenBSD: m8820x_machdep.c,v 1.18 2005/12/11 21:45:30 miod Exp $ */ /* * Copyright (c) 2004, Miodrag Vallat. * @@ -121,7 +121,10 @@ struct cmmu_p cmmu8820x = { m8820x_flush_inst_cache, m8820x_flush_data_cache, m8820x_dma_cachectl, - m8820x_dma_cachectl_pa + m8820x_dma_cachectl_pa, +#ifdef MULTIPROCESSOR + m8820x_initialize_cpu, +#endif }; /* @@ -247,16 +250,10 @@ m8820x_cpu_configuration_print(int main) int proctype = (pid & PID_ARN) >> ARN_SHIFT; int procvers = (pid & PID_VN) >> VN_SHIFT; int mmu, cnt, cpu = cpu_number(); - static __cpu_simple_lock_t print_lock; #ifdef M88200_HAS_SPLIT_ADDRESS int aline, abit, amask; #endif - if (main) - __cpu_simple_lock_init(&print_lock); - - __cpu_simple_lock(&print_lock); - printf("cpu%d: ", cpu); switch (proctype) { default: @@ -266,8 +263,8 @@ m8820x_cpu_configuration_print(int main) case ARN_88100: printf("M88100 rev 0x%x", procvers); #ifdef MULTIPROCESSOR - if (max_cpus > 1) - printf(", %s", master ? "master" : "slave"); + if (main == 0) + printf(", secondary"); #endif printf(", %d CMMU", 1 << cmmu_shift); @@ -329,8 +326,6 @@ m8820x_cpu_configuration_print(int main) } } #endif - - __cpu_simple_unlock(&print_lock); } /* @@ -390,8 +385,10 @@ m8820x_initialize_cpu(cpuid_t cpu) */ sctr = cmmu->cmmu_regs[CMMU_SCTR] & ~(CMMU_SCTR_PE | CMMU_SCTR_SE | CMMU_SCTR_PR); +#ifdef MULTIPROCESSOR if (max_cpus > 1) sctr |= CMMU_SCTR_SE; +#endif cmmu->cmmu_regs[CMMU_SCTR] = sctr; cmmu->cmmu_regs[CMMU_SAPR] = cmmu->cmmu_regs[CMMU_UAPR] = apr; diff --git a/sys/arch/m88k/m88k/pmap.c b/sys/arch/m88k/m88k/pmap.c index d549eafbc37..2c987e1bc3f 100644 --- a/sys/arch/m88k/m88k/pmap.c +++ b/sys/arch/m88k/m88k/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.20 2005/12/03 19:06:11 miod Exp $ */ +/* $OpenBSD: pmap.c,v 1.21 2005/12/11 21:45:30 miod Exp $ */ /* * Copyright (c) 2001-2004, Miodrag Vallat * Copyright (c) 1998-2001 Steve Murphree, Jr. @@ -55,6 +55,7 @@ #include <machine/asm_macro.h> #include <machine/cmmu.h> +#include <machine/cpu.h> #include <machine/lock.h> #include <machine/pmap_table.h> @@ -157,14 +158,14 @@ vaddr_t kmapva = 0; */ static void flush_atc_entry(long, vaddr_t, boolean_t); pt_entry_t *pmap_expand_kmap(vaddr_t, vm_prot_t, int); -void pmap_remove_pte(pmap_t, vaddr_t, pt_entry_t *); -void pmap_remove_range(pmap_t, vaddr_t, vaddr_t); -void pmap_expand(pmap_t, vaddr_t); -void pmap_release(pmap_t); -vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, vm_prot_t, u_int); +void pmap_remove_pte(pmap_t, vaddr_t, pt_entry_t *); +void pmap_remove_range(pmap_t, vaddr_t, vaddr_t); +void pmap_expand(pmap_t, vaddr_t); +void pmap_release(pmap_t); +vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, vm_prot_t, u_int); pt_entry_t *pmap_pte(pmap_t, vaddr_t); -void pmap_remove_all(struct vm_page *); -void pmap_changebit(struct vm_page *, int, int); +void pmap_remove_all(struct vm_page *); +void pmap_changebit(struct vm_page *, int, int); boolean_t pmap_unsetbit(struct vm_page *, int); boolean_t pmap_testbit(struct vm_page *, int); @@ -739,6 +740,25 @@ pmap_bootstrap(vaddr_t load_start) #endif /* MULTIPROCESSOR */ } +#ifdef MULTIPROCESSOR +void +pmap_bootstrap_cpu(cpuid_t cpu) +{ + if (cpu != master_cpu) { + cmmu_initialize_cpu(cpu); + } else { + 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", cpu); +#endif + SETBIT_CPUSET(cpu, &kernel_pmap->pm_cpus); +} +#endif + /* * Routine: PMAP_INIT * @@ -1021,7 +1041,6 @@ pmap_destroy(pmap_t pmap) void pmap_reference(pmap_t pmap) { - PMAP_LOCK(pmap); pmap->pm_count++; PMAP_UNLOCK(pmap); @@ -1270,7 +1289,6 @@ pmap_remove(pmap_t pmap, vaddr_t s, vaddr_t e) * pv lists * * Calls: - * __cpu_simple_lock * pmap_pte * pool_put * @@ -2211,7 +2229,6 @@ next: * pv lists * * Calls: - * simple_lock, simple_unlock * pmap_pte * * If the attribute list for the given page has the bit, this routine diff --git a/sys/arch/m88k/m88k/process.S b/sys/arch/m88k/m88k/process.S index 62eb1540fff..7773baf15d2 100644 --- a/sys/arch/m88k/m88k/process.S +++ b/sys/arch/m88k/m88k/process.S @@ -1,4 +1,4 @@ -/* $OpenBSD: process.S,v 1.12 2005/12/07 07:39:35 miod Exp $ */ +/* $OpenBSD: process.S,v 1.13 2005/12/11 21:45:30 miod Exp $ */ /* * Copyright (c) 1996 Nivas Madhur * All rights reserved. @@ -121,16 +121,7 @@ ENTRY(cpu_switch) bsr.n _C_LABEL(pmap_deactivate) st r0, r11, CI_CURPROC /* curproc = NULL */ -#ifdef MULTIPROCESSOR -ASGLOBAL(cpu_switch_search) -#else ASLOCAL(cpu_switch_search) -#endif - -#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) - bsr _C_LABEL(sched_unlock_idle) -#endif - /* * This is the start of the idle loop. Find the highest-priority * queue that isn't empty, then take the first proc from that queue. @@ -139,47 +130,49 @@ ASLOCAL(cpu_switch_search) ld r7, r7, lo16(_C_LABEL(whichqs)) bcnd ne0, r7, _ASM_LABEL(cpu_switch_found) -ASLOCAL(cpu_switch_idle) +#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) + bsr _C_LABEL(sched_unlock_idle) +#endif + +#ifdef MULTIPROCESSOR +ASGLOBAL(cpu_switch_idle) +#endif /* * There were no runnable processes. Enable all interrupts and * busy-wait for this to change. - * Note that, besides doing spl0(), this will actually enable + * Note that, besides doing setipl(IPL_NONE), this will actually enable * interrupts in the psr. Bootstrap of secondary processors * relies upon this. */ - bsr.n _C_LABEL(setipl) - or r2, r0, IPL_NONE - ldcr r2, PSR - bb0.n PSR_INTERRUPT_DISABLE_BIT, r2, 2f - or.u r7, r0, hi16(_C_LABEL(whichqs)) + bb0 PSR_INTERRUPT_DISABLE_BIT, r2, 2f clr r2, r2, 1<PSR_INTERRUPT_DISABLE_BIT> stcr r2, PSR FLUSH_PIPELINE 2: + bsr.n _C_LABEL(setipl) + or r2, r0, IPL_NONE + + or.u r7, r0, hi16(_C_LABEL(whichqs)) ld r7, r7, lo16(_C_LABEL(whichqs)) - bcnd eq0, r7, _ASM_LABEL(cpu_switch_idle) + bcnd eq0, r7, 2b /* XXX run fancy things here, such as page zeroing... */ -ASLOCAL(cpu_switch_found) - bsr.n _C_LABEL(setipl) /* disable interrupts */ - or r2, r0, IPL_HIGH - #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) bsr _C_LABEL(sched_lock_idle) #endif +ASLOCAL(cpu_switch_found) + bsr.n _C_LABEL(setipl) /* disable interrupts */ + or r2, r0, IPL_HIGH + /* * An interrupt could have occured between the last whichqs check * and the call to setipl(). Check again that whichqs is nonzero. */ or.u r7, r0, hi16(_C_LABEL(whichqs)) /* reload whichqs */ ld r7, r7, lo16(_C_LABEL(whichqs)) -#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) bcnd eq0, r7, _ASM_LABEL(cpu_switch_search) -#else - bcnd eq0, r7, _ASM_LABEL(cpu_switch_idle) -#endif /* XXX use ff1, like powerpc... needs *runqueue() adjustments */ xor r6, r6, r6 /* set r6 to 0 */ @@ -240,10 +233,6 @@ ASLOCAL(cpu_switch_found) bsr.n _C_LABEL(pmap_activate) or r2, r0, r9 -#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) - bsr _C_LABEL(sched_unlock_idle) -#endif - ldcr r10, CPU ld r10, r10, CI_CURPCB @@ -273,8 +262,11 @@ ASLOCAL(cpu_switch_found) ld r1, r14, PCB_PC ld r30, r14, PCB_R30 /* restore frame pointer & stack */ ld r31, r14, PCB_SP - +#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG) + br.n _C_LABEL(sched_unlock_idle) +#else jmp.n r1 +#endif ld r14, r14, PCB_R14 /* diff --git a/sys/arch/m88k/m88k/trap.c b/sys/arch/m88k/m88k/trap.c index 206ef090931..52ffff4ef31 100644 --- a/sys/arch/m88k/m88k/trap.c +++ b/sys/arch/m88k/m88k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.28 2005/12/11 21:30:30 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.29 2005/12/11 21:45:30 miod Exp $ */ /* * Copyright (c) 2004, Miodrag Vallat. * Copyright (c) 1998 Steve Murphree, Jr. @@ -1109,9 +1109,9 @@ __dead void error_fatal(struct trapframe *frame) { if (frame->tf_vector == 0) - printf("\nReset Exception\n"); + printf("\nCPU %d Reset Exception\n", cpu_number()); else - printf("\nError Exception\n"); + printf("\nCPU %d Error Exception\n", cpu_number()); #ifdef DDB regdump((struct trapframe*)frame); diff --git a/sys/arch/m88k/m88k/vm_machdep.c b/sys/arch/m88k/m88k/vm_machdep.c index 53f5f181f5d..901b047e8ac 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.9 2005/12/08 07:02:36 miod Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.10 2005/12/11 21:45:30 miod Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. @@ -146,10 +146,9 @@ cpu_fork(p1, p2, stack, stacksize, func, arg) void cpu_exit(struct proc *p) { - pmap_deactivate(p); - splhigh(); + pmap_deactivate(p); uvmexp.swtch++; switch_exit(p); /* NOTREACHED */ |