Module Name: src Committed By: matt Date: Sat Feb 27 08:00:02 UTC 2010
Modified Files: src/sys/arch/evbmips/malta [matt-nb5-mips64]: machdep.c src/sys/arch/evbmips/rmixl [matt-nb5-mips64]: machdep.c Log Message: For MULTIPROCESSOR kernels, enable exception fixups. To generate a diff of this commit: cvs rdiff -u -r1.28.10.4 -r1.28.10.5 src/sys/arch/evbmips/malta/machdep.c cvs rdiff -u -r1.1.2.19 -r1.1.2.20 src/sys/arch/evbmips/rmixl/machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/evbmips/malta/machdep.c diff -u src/sys/arch/evbmips/malta/machdep.c:1.28.10.4 src/sys/arch/evbmips/malta/machdep.c:1.28.10.5 --- src/sys/arch/evbmips/malta/machdep.c:1.28.10.4 Mon Feb 1 04:17:51 2010 +++ src/sys/arch/evbmips/malta/machdep.c Sat Feb 27 08:00:02 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.28.10.4 2010/02/01 04:17:51 matt Exp $ */ +/* $NetBSD: machdep.c,v 1.28.10.5 2010/02/27 08:00:02 matt Exp $ */ /* * Copyright 2001, 2002 Wasabi Systems, Inc. @@ -112,7 +112,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.28.10.4 2010/02/01 04:17:51 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.28.10.5 2010/02/27 08:00:02 matt Exp $"); #include "opt_ddb.h" #include "opt_execfmt.h" @@ -144,6 +144,8 @@ #include <machine/psl.h> #include <machine/yamon.h> +#include <mips/locore.h> + #include <evbmips/malta/autoconf.h> #include <evbmips/malta/maltareg.h> #include <evbmips/malta/maltavar.h> @@ -328,6 +330,13 @@ if (boothowto & RB_KDB) Debugger(); #endif + +#ifdef MULTIPROCESSOR + /* + * We can never running on more than one processor but we can dream. + */ + mips_fixup_exceptions(mips_fixup_zero_relative); +#endif } void Index: src/sys/arch/evbmips/rmixl/machdep.c diff -u src/sys/arch/evbmips/rmixl/machdep.c:1.1.2.19 src/sys/arch/evbmips/rmixl/machdep.c:1.1.2.20 --- src/sys/arch/evbmips/rmixl/machdep.c:1.1.2.19 Mon Feb 1 04:17:51 2010 +++ src/sys/arch/evbmips/rmixl/machdep.c Sat Feb 27 08:00:02 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.1.2.19 2010/02/01 04:17:51 matt Exp $ */ +/* $NetBSD: machdep.c,v 1.1.2.20 2010/02/27 08:00:02 matt Exp $ */ /* * Copyright 2001, 2002 Wasabi Systems, Inc. @@ -112,7 +112,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.1.2.19 2010/02/01 04:17:51 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.1.2.20 2010/02/27 08:00:02 matt Exp $"); #include "opt_ddb.h" #include "opt_com.h" @@ -248,6 +248,7 @@ #ifdef MULTIPROCESSOR +static bool rmixl_fixup_cop0_oscratch(int32_t, uint32_t [2]) void rmixl_get_wakeup_info(struct rmixl_config *); #ifdef MACHDEP_DEBUG static void rmixl_wakeup_info_print(volatile rmixlfw_cpu_wakeup_info_t *); @@ -443,7 +444,42 @@ if (boothowto & RB_KDB) Debugger(); #endif +#ifdef MULTIPROCESSOR + /* + * Fix up the exception vector to use COP0 OSSCRATCH0 + */ + __asm __volatile("mtc0 %0,$%1" + :: "r"(&cpu_info_store), "n"(MIPS_COP_0_OSSCRATCH)); + mips_fixup_exceptions(rmixl_fixup_cop0_oscratch); +#endif +} + +#ifdef MULTIPROCESSOR +static bool +rmixl_fixup_cop0_oscratch(int32_t load_addr, uint32_t new_insns[2]) +{ + size_t offset = load_addr - (intptr_t)&cpu_info_store; + + KASSERT(MIPS_KSEG0_P(load_addr)); + KASSERT(offset < sizeof(struct cpu_info)); + + /* + * Fixup this direct load cpu_info_store to actual get the current + * CPU's cpu_info from COP0 OSSCRATCH0 and then fix the load to be + * relative from the start of struct cpu_info. + */ + + /* [0] = mfc0 rX, $22 (OSScratch) */ + new_insns[0] = (020 << 26) + | (new_insns[0] & 0x001f0000) + | (MIPS_COP_0_OSSCRATCH << 11) | (0 << 0); + + /* [1] = l[dw] rX, offset(rX) */ + new_insns[1] = (new_insns[1] & 0xffff0000) | offset; + + return true; } +#endif /* MULTIPROCESSOR */ /* * ram_seg_resv - cut reserved regions out of segs, fragmenting as needed