Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/mips/mips Less magic numbers.



details:   https://anonhg.NetBSD.org/src/rev/d0e19285910e
branches:  trunk
changeset: 974001:d0e19285910e
user:      simonb <simonb%NetBSD.org@localhost>
date:      Mon Jul 20 03:26:07 2020 +0000

description:
Less magic numbers.

diffstat:

 sys/arch/mips/mips/cpu_subr.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (38 lines):

diff -r 2b97f42ff41e -r d0e19285910e sys/arch/mips/mips/cpu_subr.c
--- a/sys/arch/mips/mips/cpu_subr.c     Mon Jul 20 03:24:59 2020 +0000
+++ b/sys/arch/mips/mips/cpu_subr.c     Mon Jul 20 03:26:07 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu_subr.c,v 1.50 2020/07/19 09:30:08 simonb Exp $     */
+/*     $NetBSD: cpu_subr.c,v 1.51 2020/07/20 03:26:07 simonb Exp $     */
 
 /*-
  * Copyright (c) 2010, 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.50 2020/07/19 09:30:08 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.51 2020/07/20 03:26:07 simonb Exp $");
 
 #include "opt_cputype.h"
 #include "opt_ddb.h"
@@ -122,14 +122,16 @@
 cpu_info_alloc(struct pmap_tlb_info *ti, cpuid_t cpu_id, cpuid_t cpu_package_id,
        cpuid_t cpu_core_id, cpuid_t cpu_smt_id)
 {
+       const int exc_step = 1 << MIPS_EBASE_EXC_BASE_SHIFT;
 
        KASSERT(cpu_id < MAXCPUS);
 
 #ifdef MIPS64_OCTEON
-       vaddr_t exc_page = MIPS_UTLB_MISS_EXC_VEC + 0x1000*cpu_id;
-       __CTASSERT(sizeof(struct cpu_info) + sizeof(struct pmap_tlb_info) <= 0x1000 - 0x280);
+       vaddr_t exc_page = MIPS_UTLB_MISS_EXC_VEC + exc_step * cpu_id;
+       __CTASSERT(sizeof(struct cpu_info) + sizeof(struct pmap_tlb_info)
+           <= exc_step - 0x280);
 
-       struct cpu_info * const ci = ((struct cpu_info *)(exc_page + 0x1000)) - 1;
+       struct cpu_info * const ci = ((struct cpu_info *)(exc_page + exc_step)) - 1;
        memset((void *)exc_page, 0, PAGE_SIZE);
 
        if (ti == NULL) {



Home | Main Index | Thread Index | Old Index