tweak cpu_arch. Eliminate all direct checks of it (making them

use the macro CPUISMIPS3 -- which is badly misnamed), and set it
from #defines named CPU_ARCH_N (where N is 1..5, 32, 64).
This commit is contained in:
cgd 2000-10-05 00:52:59 +00:00
parent a22da181d6
commit 3f1d3c3066
5 changed files with 42 additions and 36 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.h,v 1.44 2000/08/25 01:04:08 thorpej Exp $ */
/* $NetBSD: cpu.h,v 1.45 2000/10/05 00:52:59 cgd Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -86,7 +86,17 @@
#else /* run-time test */
extern int cpu_arch;
#define CPUISMIPS3 (cpu_arch >= 3)
#define CPU_ARCH_MIPS1 (1 << 0)
#define CPU_ARCH_MIPS2 (1 << 1)
#define CPU_ARCH_MIPS3 (1 << 2)
#define CPU_ARCH_MIPS4 (1 << 3)
#define CPU_ARCH_MIPS5 (1 << 4)
#define CPU_ARCH_MIPS32 (1 << 5)
#define CPU_ARCH_MIPS64 (1 << 6)
/* This test is ... rather bogus */
#define CPUISMIPS3 ((cpu_arch & (CPU_ARCH_MIPS3 | CPU_ARCH_MIPS4)) != 0)
#endif /* run-time test */
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.h,v 1.46 2000/10/04 22:44:01 cgd Exp $ */
/* $NetBSD: locore.h,v 1.47 2000/10/05 00:52:59 cgd Exp $ */
/*
* Copyright 1996 The Board of Trustees of The Leland Stanford
@ -218,7 +218,6 @@ typedef int mips_prid_t;
extern mips_prid_t cpu_id;
extern mips_prid_t fpu_id;
extern int cpu_arch;
extern int mips_num_tlb_entries;
extern u_int mips_L1DCacheSize;
extern u_int mips_L1ICacheSize;

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_interface.c,v 1.32 2000/08/10 08:01:24 jeffs Exp $ */
/* $NetBSD: db_interface.c,v 1.33 2000/10/05 00:53:00 cgd Exp $ */
/*
* Mach Operating System
@ -310,11 +310,11 @@ db_write_bytes(addr, size, data)
kdbpoke_1(p, *(char*)data);
}
#ifdef MIPS1
if (cpu_arch == 1)
if (!CPUISMIPS3)
mips1_FlushICache((vaddr_t) addr, size);
#endif
#ifdef MIPS3
if (cpu_arch >= 3) {
if (CPUISMIPS3) {
MachHitFlushDCache((vaddr_t) addr, size);
MachFlushICache((vaddr_t) addr, size);
}
@ -330,7 +330,7 @@ db_tlbdump_cmd(addr, have_addr, count, modif)
char *modif;
{
#ifdef MIPS1
if (cpu_arch == 1) {
if (!CPUISMIPS3) {
struct mips1_tlb {
u_int32_t tlb_hi;
u_int32_t tlb_lo;
@ -352,7 +352,7 @@ db_tlbdump_cmd(addr, have_addr, count, modif)
}
#endif
#ifdef MIPS3
if (cpu_arch >= 3) {
if (CPUISMIPS3) {
struct tlb tlb;
int i;

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.S,v 1.116 2000/10/04 22:44:02 cgd Exp $ */
/* $NetBSD: locore.S,v 1.117 2000/10/05 00:53:00 cgd Exp $ */
/*
* Copyright (c) 1992, 1993
@ -1354,13 +1354,10 @@ _C_LABEL(esym):
.globl _C_LABEL(cpu_id)
.globl _C_LABEL(fpu_id)
.globl _C_LABEL(cpu_arch)
_C_LABEL(cpu_id):
.word 0
_C_LABEL(fpu_id):
.word 0
_C_LABEL(cpu_arch):
.word 0
.globl _C_LABEL(mips_L1DCacheSize)
.globl _C_LABEL(mips_L1ICacheSize)

View File

@ -1,4 +1,4 @@
/* $NetBSD: mips_machdep.c,v 1.104 2000/10/04 21:41:47 cgd Exp $ */
/* $NetBSD: mips_machdep.c,v 1.105 2000/10/05 00:53:01 cgd Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -52,7 +52,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.104 2000/10/04 21:41:47 cgd Exp $");
__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.105 2000/10/05 00:53:01 cgd Exp $");
#include "opt_compat_netbsd.h"
#include "opt_compat_ultrix.h"
@ -103,6 +103,7 @@ long *mips_locoresw[3];
extern long *mips1_locoresw[]; /* locore_mips1.S */
extern long *mips3_locoresw[]; /* locore_mips3.S */
int cpu_arch;
int cpu_mhz;
int mips_num_tlb_entries;
@ -351,14 +352,14 @@ mips_vector_init()
#ifdef MIPS1
case MIPS_R2000:
case MIPS_R3000:
cpu_arch = 1;
cpu_arch = CPU_ARCH_MIPS1;
mips_num_tlb_entries = MIPS1_TLB_NUM_TLB_ENTRIES;
mips_L1ICacheSize = mips1_icsize();
mips_L1DCacheSize = mips1_dcsize();
break;
#ifdef ENABLE_MIPS_TX3900
case MIPS_TX3900:
cpu_arch = 1;
cpu_arch = CPU_ARCH_MIPS1;
switch (MIPS_PRID_REV_MAJ(cpu_id)) {
default:
panic("not supported revision");
@ -383,29 +384,29 @@ mips_vector_init()
#ifdef MIPS3
case MIPS_R4000:
cpu_arch = 3;
cpu_arch = CPU_ARCH_MIPS3;
mips_num_tlb_entries = MIPS3_TLB_NUM_TLB_ENTRIES;
mips3_L1TwoWayCache = 0;
break;
case MIPS_R4100:
cpu_arch = 3;
cpu_arch = CPU_ARCH_MIPS3;
mips_num_tlb_entries = 32;
mips3_L1TwoWayCache = 0;
break;
case MIPS_R4300:
cpu_arch = 3;
cpu_arch = CPU_ARCH_MIPS3;
mips_num_tlb_entries = MIPS_R4300_TLB_NUM_TLB_ENTRIES;
mips3_L1TwoWayCache = 0;
break;
case MIPS_R4600:
cpu_arch = 3;
cpu_arch = CPU_ARCH_MIPS3;
mips_num_tlb_entries = MIPS3_TLB_NUM_TLB_ENTRIES;
mips3_L1TwoWayCache = 1;
/* disable interrupt while cacheflush to workaround the bug */
break;
#ifdef ENABLE_MIPS_R4700 /* ID conflict */
case MIPS_R4700:
cpu_arch = 3;
cpu_arch = CPU_ARCH_MIPS3;
mips_num_tlb_entries = MIPS3_TLB_NUM_TLB_ENTRIES;
mips3_L1TwoWayCache = 1;
break;
@ -414,14 +415,14 @@ mips_vector_init()
case MIPS_R5000:
#endif
case MIPS_RM5200:
cpu_arch = 4;
cpu_arch = CPU_ARCH_MIPS4;
mips_num_tlb_entries = MIPS3_TLB_NUM_TLB_ENTRIES;
mips3_L1TwoWayCache = 1;
break;
case MIPS_R10000:
case MIPS_R12000:
cpu_arch = 4;
cpu_arch = CPU_ARCH_MIPS4;
mips_num_tlb_entries = 64;
mips3_L1TwoWayCache = 1;
break;
@ -436,7 +437,7 @@ mips_vector_init()
* note that the Config register has a non-standard base
* for IC and DC (2^9 instead of 2^12).
*/
cpu_arch = 3;
cpu_arch = CPU_ARCH_MIPS3;
mips_num_tlb_entries = 16; /* each entry maps 2 pages */
mips3_L1TwoWayCache = 1; /* note: line size is 16bytes */
mips3_csizebase = 0x200; /* non-standard base in Config */
@ -449,17 +450,15 @@ mips_vector_init()
cpu_reboot(RB_HALT, NULL);
}
switch (cpu_arch) {
#ifdef MIPS1
case 1:
if (!CPUISMIPS3) {
mips1_TBIA(mips_num_tlb_entries);
mips1_vector_init();
memcpy(mips_locoresw, mips1_locoresw, sizeof(mips_locoresw));
break;
} else
#endif
#ifdef MIPS3
case 3:
case 4:
if (CPUISMIPS3) {
mips3_SetWIRED(0);
mips3_TBIA(mips_num_tlb_entries);
mips3_SetWIRED(MIPS3_TLB_WIRED_UPAGES);
@ -470,10 +469,11 @@ mips_vector_init()
}
mips3_vector_init(mips3_csizebase);
memcpy(mips_locoresw, mips3_locoresw, sizeof(mips_locoresw));
break;
} else
#endif
default:
printf("MIPS ISA %d: not supported\n", cpu_arch);
{
printf("cpu_arch 0x%x: not supported\n", cpu_arch);
cpu_reboot(RB_HALT, NULL);
}
}
@ -594,7 +594,7 @@ cpu_identify()
printf("cpu0: ");
#ifdef MIPS1
if (cpu_arch == 1) {
if (!CPUISMIPS3) {
#ifdef ENABLE_MIPS_TX3900
printf("%dKB/%dB Instruction %s, %dKB/%dB Data 2-way set associative, %d TLB entries",
mips_L1ICacheSize / 1024, mips_L1ICacheLSize,
@ -608,7 +608,7 @@ cpu_identify()
}
#endif
#ifdef MIPS3
if (cpu_arch >= 3) {
if (CPUISMIPS3) {
printf("L1 cache: %dKB/%dB instruction, %dKB/%dB data",
mips_L1ICacheSize / 1024, mips_L1ICacheLSize,
mips_L1DCacheSize / 1024, mips_L1DCacheLSize);
@ -648,7 +648,7 @@ cpu_identify()
* but printf() doesn't work in it.
*/
#if !defined(MIPS3_L2CACHE_ABSENT)
if (cpu_arch >= 3 && !mips_L2CachePresent) {
if (CPUISMIPS3 && !mips_L2CachePresent) {
printf("This kernel doesn't work without L2 cache.\n"
"Please add \"options MIPS3_L2CACHE_ABSENT\" "
"to the kernel config file.\n");