diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2004-01-20 14:35:55 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2004-01-20 14:35:55 +0000 |
commit | d8e696c02252fe27c4c139380a71f1f2a63a575e (patch) | |
tree | 167c0dcba0cc70c27d5544752cfe07e168636aa9 /sys/arch | |
parent | af5bc809252be419668c4758eaeb42a766d10c8d (diff) |
Use shifts and logical arithmetic, rather than multiplications and integer
arithmetic, when computing cmmu numbers.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/mvme88k/include/cmmu.h | 3 | ||||
-rw-r--r-- | sys/arch/mvme88k/mvme88k/cmmu.c | 3 | ||||
-rw-r--r-- | sys/arch/mvme88k/mvme88k/m8820x.c | 36 |
3 files changed, 21 insertions, 21 deletions
diff --git a/sys/arch/mvme88k/include/cmmu.h b/sys/arch/mvme88k/include/cmmu.h index 98a33c7b44b..9b3ff2bfee6 100644 --- a/sys/arch/mvme88k/include/cmmu.h +++ b/sys/arch/mvme88k/include/cmmu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cmmu.h,v 1.17 2004/01/09 00:23:04 miod Exp $ */ +/* $OpenBSD: cmmu.h,v 1.18 2004/01/20 14:35:52 miod Exp $ */ /* * Mach Operating System * Copyright (c) 1993-1992 Carnegie Mellon University @@ -35,7 +35,6 @@ * Prototypes and stuff for cmmu.c. */ extern unsigned cpu_sets[MAX_CPUS]; -extern int cpu_cmmu_ratio; extern unsigned master_cpu; extern int max_cpus, max_cmmus; diff --git a/sys/arch/mvme88k/mvme88k/cmmu.c b/sys/arch/mvme88k/mvme88k/cmmu.c index 6c9abd24c91..6a2f26cef66 100644 --- a/sys/arch/mvme88k/mvme88k/cmmu.c +++ b/sys/arch/mvme88k/mvme88k/cmmu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmmu.c,v 1.26 2004/01/17 22:35:41 miod Exp $ */ +/* $OpenBSD: cmmu.c,v 1.27 2004/01/20 14:35:54 miod Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -74,6 +74,5 @@ struct simplelock cmmu_cpu_lock; unsigned cpu_sets[MAX_CPUS]; unsigned master_cpu = 0; int max_cpus, max_cmmus; -int cpu_cmmu_ratio; struct cmmu_p *cmmu; diff --git a/sys/arch/mvme88k/mvme88k/m8820x.c b/sys/arch/mvme88k/mvme88k/m8820x.c index c0fc70fb3f5..bd9e55301bf 100644 --- a/sys/arch/mvme88k/mvme88k/m8820x.c +++ b/sys/arch/mvme88k/mvme88k/m8820x.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m8820x.c,v 1.30 2004/01/19 16:57:06 miod Exp $ */ +/* $OpenBSD: m8820x.c,v 1.31 2004/01/20 14:35:54 miod Exp $ */ /* * Copyright (c) 2004, Miodrag Vallat. * @@ -272,6 +272,8 @@ struct cmmu_strategy { { CMMU_SPLIT_ADDRESS, CMMU_SPLIT_ADDRESS} /* CPU 3 */ }; +unsigned int cmmu_shift; + #ifdef MVME188 /* * The following list describes the different MVME188 configurations @@ -379,7 +381,7 @@ m8820x_setup_board_config() #endif /* MVME188 */ } - cpu_cmmu_ratio = max_cmmus / max_cpus; + cmmu_shift = ff1(max_cmmus / max_cpus); #ifdef MVME188 if (bd_config[vme188_config].ncpus > 0) { @@ -425,23 +427,23 @@ m8820x_setup_board_config() for (num = 0; num < max_cpus; num++) { int i, type; - for (i = 0; i < cpu_cmmu_ratio; i++) { + for (i = 0; i < (1 << cmmu_shift); i++) { dprintf(("cmmu_init: testing CMMU %d for CPU %d\n", - num * cpu_cmmu_ratio + i, num)); + (num << cmmu_shift) | i, num)); #ifdef DIAGNOSTIC - if (m8820x_cmmu[num * cpu_cmmu_ratio + i].cmmu_alive == CMMU_DEAD) { + if (m8820x_cmmu[(num << cmmu_shift) | i].cmmu_alive == CMMU_DEAD) { printf("CMMU %d attached to CPU %d is not working\n", - num * cpu_cmmu_ratio + i, num); + (num << cmmu_shift) | i, num); continue; /* will probably die quickly */ } #endif } cpu_sets[num] = 1; /* This cpu installed... */ - type = CMMU_TYPE(m8820x_cmmu[num * cpu_cmmu_ratio]. + type = CMMU_TYPE(m8820x_cmmu[num << cmmu_shift]. cmmu_regs[CMMU_IDR]); printf("CPU%d is attached with %d MC%x CMMUs\n", - num, cpu_cmmu_ratio, type == M88204_ID ? 0x88204 : 0x88200); + num, 1 << cmmu_shift, type == M88204_ID ? 0x88204 : 0x88200); } for (num = 0; num < max_cpus; num++) { @@ -525,7 +527,7 @@ m8820x_setup_board_config() /* * We don't set up anything for the hardwired configurations. */ - if (cpu_cmmu_ratio == 2) { + if (cmmu_shift == 1) { m8820x_cmmu[cmmu_num].cmmu_addr = 0; m8820x_cmmu[cmmu_num].cmmu_addr_mask = 0; m8820x_cmmu[cmmu_num].cmmu_addr_match = 1; @@ -574,7 +576,7 @@ m8820x_setup_board_config() * For MVME188 single processors, we've got to look at A14. * This bit splits the CMMUs independent of the enabled strategy */ - if (cpu_cmmu_ratio >= 4) { /* XXX only handles 1P128!!! */ + if (cmmu_shift >= 2) { m8820x_cmmu[cmmu_num].cmmu_addr |= ((cmmu_num & 0x4) ^ 0x4) << 12; m8820x_cmmu[cmmu_num].cmmu_addr_mask |= CMMU_A14_MASK; @@ -666,8 +668,8 @@ m8820x_cmmu_set(reg, val, flags, num, mode, access, addr) * We scan all CMMUs to find the matching ones and store the * values there. */ - for (mmu = num * cpu_cmmu_ratio; - mmu < (num + 1) * cpu_cmmu_ratio; mmu++) { + for (mmu = num << cmmu_shift; + mmu < (num + 1) << cmmu_shift; mmu++) { if (((flags & MODE_VAL)) && (m8820x_cmmu[mmu].cmmu_type != mode)) continue; @@ -698,8 +700,8 @@ m8820x_cmmu_wait(int cpu) /* * We scan all related CMMUs and read their status register. */ - for (mmu = cpu * cpu_cmmu_ratio; - mmu < (cpu + 1) * cpu_cmmu_ratio; mmu++) { + for (mmu = cpu << cmmu_shift; + mmu < (cpu + 1) << cmmu_shift; mmu++) { #ifdef DEBUG if (m8820x_cmmu[mmu].cmmu_regs[CMMU_SSR] & CMMU_SSR_BE) { panic("cache flush failed!"); @@ -758,15 +760,15 @@ m8820x_cpu_configuration_print(master) printf(", %s", master ? "master" : "slave"); #endif #endif - printf(", %d CMMU", cpu_cmmu_ratio); + printf(", %d CMMU", 1 << cmmu_shift); - for (mmu = cpu * cpu_cmmu_ratio; mmu < (cpu + 1) * cpu_cmmu_ratio; + for (mmu = cpu << cmmu_shift; mmu < (cpu + 1) << cmmu_shift; mmu++) { int idr = m8820x_cmmu[mmu].cmmu_regs[CMMU_IDR]; int mmuid = CMMU_TYPE(idr); int access = m8820x_cmmu[mmu].cmmu_access; - if ((mmu - cpu * cpu_cmmu_ratio) % 2 == 0) + if (mmu % 2 == 0) printf("\ncpu%d: ", cpu); else printf(", "); |