cpu.h revision 178172
1178172Simp/* $OpenBSD: cpu.h,v 1.4 1998/09/15 10:50:12 pefo Exp $ */ 2178172Simp 3178172Simp/*- 4178172Simp * Copyright (c) 1992, 1993 5178172Simp * The Regents of the University of California. All rights reserved. 6178172Simp * 7178172Simp * This code is derived from software contributed to Berkeley by 8178172Simp * Ralph Campbell and Rick Macklem. 9178172Simp * 10178172Simp * Redistribution and use in source and binary forms, with or without 11178172Simp * modification, are permitted provided that the following conditions 12178172Simp * are met: 13178172Simp * 1. Redistributions of source code must retain the above copyright 14178172Simp * notice, this list of conditions and the following disclaimer. 15178172Simp * 2. Redistributions in binary form must reproduce the above copyright 16178172Simp * notice, this list of conditions and the following disclaimer in the 17178172Simp * documentation and/or other materials provided with the distribution. 18178172Simp * 4. Neither the name of the University nor the names of its contributors 19178172Simp * may be used to endorse or promote products derived from this software 20178172Simp * without specific prior written permission. 21178172Simp * 22178172Simp * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23178172Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24178172Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25178172Simp * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26178172Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27178172Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28178172Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29178172Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30178172Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31178172Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32178172Simp * SUCH DAMAGE. 33178172Simp * 34178172Simp * Copyright (C) 1989 Digital Equipment Corporation. 35178172Simp * Permission to use, copy, modify, and distribute this software and 36178172Simp * its documentation for any purpose and without fee is hereby granted, 37178172Simp * provided that the above copyright notice appears in all copies. 38178172Simp * Digital Equipment Corporation makes no representations about the 39178172Simp * suitability of this software for any purpose. It is provided "as is" 40178172Simp * without express or implied warranty. 41178172Simp * 42178172Simp * from: @(#)cpu.h 8.4 (Berkeley) 1/4/94 43178172Simp * JNPR: cpu.h,v 1.9.2.2 2007/09/10 08:23:46 girish 44178172Simp * $FreeBSD: head/sys/mips/include/cpu.h 178172 2008-04-13 07:27:37Z imp $ 45178172Simp */ 46178172Simp 47178172Simp#ifndef _MACHINE_CPU_H_ 48178172Simp#define _MACHINE_CPU_H_ 49178172Simp 50178172Simp#include <machine/psl.h> 51178172Simp#include <machine/endian.h> 52178172Simp 53178172Simp#define MIPS_CACHED_MEMORY_ADDR 0x80000000 54178172Simp#define MIPS_UNCACHED_MEMORY_ADDR 0xa0000000 55178172Simp#define MIPS_MAX_MEM_ADDR 0xbe000000 56178172Simp#define MIPS_RESERVED_ADDR 0xbfc80000 57178172Simp 58178172Simp#define MIPS_KSEG0_LARGEST_PHYS 0x20000000 59178172Simp#define MIPS_CACHED_TO_PHYS(x) ((unsigned)(x) & 0x1fffffff) 60178172Simp#define MIPS_PHYS_TO_CACHED(x) ((unsigned)(x) | MIPS_CACHED_MEMORY_ADDR) 61178172Simp#define MIPS_UNCACHED_TO_PHYS(x) ((unsigned)(x) & 0x1fffffff) 62178172Simp#define MIPS_PHYS_TO_UNCACHED(x) ((unsigned)(x) | MIPS_UNCACHED_MEMORY_ADDR) 63178172Simp 64178172Simp#define MIPS_PHYS_MASK (0x1fffffff) 65178172Simp#define MIPS_PA_2_K1VA(x) (MIPS_KSEG1_START | ((x) & MIPS_PHYS_MASK)) 66178172Simp 67178172Simp#define MIPS_VA_TO_CINDEX(x) ((unsigned)(x) & 0xffffff | MIPS_CACHED_MEMORY_ADDR) 68178172Simp#define MIPS_CACHED_TO_UNCACHED(x) (MIPS_PHYS_TO_UNCACHED(MIPS_CACHED_TO_PHYS(x))) 69178172Simp 70178172Simp#define MIPS_PHYS_TO_KSEG0(x) ((unsigned)(x) | MIPS_KSEG0_START) 71178172Simp#define MIPS_PHYS_TO_KSEG1(x) ((unsigned)(x) | MIPS_KSEG1_START) 72178172Simp#define MIPS_KSEG0_TO_PHYS(x) ((unsigned)(x) & MIPS_PHYS_MASK) 73178172Simp#define MIPS_KSEG1_TO_PHYS(x) ((unsigned)(x) & MIPS_PHYS_MASK) 74178172Simp 75178172Simp/* 76178172Simp * Status register. 77178172Simp */ 78178172Simp#define SR_COP_USABILITY 0xf0000000 79178172Simp#define SR_COP_0_BIT 0x10000000 80178172Simp#define SR_COP_1_BIT 0x20000000 81178172Simp#define SR_COP_2_BIT 0x40000000 82178172Simp#define SR_RP 0x08000000 83178172Simp#define SR_FR_32 0x04000000 84178172Simp#define SR_RE 0x02000000 85178172Simp#define SR_PX 0x00800000 86178172Simp#define SR_BOOT_EXC_VEC 0x00400000 87178172Simp#define SR_TLB_SHUTDOWN 0x00200000 88178172Simp#define SR_SOFT_RESET 0x00100000 89178172Simp#define SR_DIAG_CH 0x00040000 90178172Simp#define SR_DIAG_CE 0x00020000 91178172Simp#define SR_DIAG_DE 0x00010000 92178172Simp#define SR_KX 0x00000080 93178172Simp#define SR_SX 0x00000040 94178172Simp#define SR_UX 0x00000020 95178172Simp#define SR_KSU_MASK 0x00000018 96178172Simp#define SR_KSU_USER 0x00000010 97178172Simp#define SR_KSU_SUPER 0x00000008 98178172Simp#define SR_KSU_KERNEL 0x00000000 99178172Simp#define SR_ERL 0x00000004 100178172Simp#define SR_EXL 0x00000002 101178172Simp#define SR_INT_ENAB 0x00000001 102178172Simp 103178172Simp#define SR_INT_MASK 0x0000ff00 104178172Simp#define SOFT_INT_MASK_0 0x00000100 105178172Simp#define SOFT_INT_MASK_1 0x00000200 106178172Simp#define SR_INT_MASK_0 0x00000400 107178172Simp#define SR_INT_MASK_1 0x00000800 108178172Simp#define SR_INT_MASK_2 0x00001000 109178172Simp#define SR_INT_MASK_3 0x00002000 110178172Simp#define SR_INT_MASK_4 0x00004000 111178172Simp#define SR_INT_MASK_5 0x00008000 112178172Simp#define ALL_INT_MASK SR_INT_MASK 113178172Simp#define SOFT_INT_MASK (SOFT_INT_MASK_0 | SOFT_INT_MASK_1) 114178172Simp#define HW_INT_MASK (ALL_INT_MASK & ~SOFT_INT_MASK) 115178172Simp 116178172Simp 117178172Simp/* 118178172Simp * The bits in the cause register. 119178172Simp * 120178172Simp * CR_BR_DELAY Exception happened in branch delay slot. 121178172Simp * CR_COP_ERR Coprocessor error. 122178172Simp * CR_IP Interrupt pending bits defined below. 123178172Simp * CR_EXC_CODE The exception type (see exception codes below). 124178172Simp */ 125178172Simp#define CR_BR_DELAY 0x80000000 126178172Simp#define CR_COP_ERR 0x30000000 127178172Simp#define CR_EXC_CODE 0x0000007c 128178172Simp#define CR_EXC_CODE_SHIFT 2 129178172Simp#define CR_IPEND 0x0000ff00 130178172Simp 131178172Simp/* 132178172Simp * Cause Register Format: 133178172Simp * 134178172Simp * 31 30 29 28 27 26 25 24 23 8 7 6 2 1 0 135178172Simp * ---------------------------------------------------------------------- 136178172Simp * | BD | 0| CE | 0| W2| W1| IV| IP15 - IP0 | 0| Exc Code | 0| 137178172Simp * |______________________________________________________________________ 138178172Simp */ 139178172Simp 140178172Simp#define CR_INT_SOFT0 0x00000100 141178172Simp#define CR_INT_SOFT1 0x00000200 142178172Simp#define CR_INT_0 0x00000400 143178172Simp#define CR_INT_1 0x00000800 144178172Simp#define CR_INT_2 0x00001000 145178172Simp#define CR_INT_3 0x00002000 146178172Simp#define CR_INT_4 0x00004000 147178172Simp#define CR_INT_5 0x00008000 148178172Simp 149178172Simp#define CR_INT_UART CR_INT_1 150178172Simp#define CR_INT_IPI CR_INT_2 151178172Simp#define CR_INT_CLOCK CR_INT_5 152178172Simp 153178172Simp/* 154178172Simp * The bits in the CONFIG register 155178172Simp */ 156178172Simp#define CFG_K0_UNCACHED 2 157178172Simp#define CFG_K0_CACHED 3 158178172Simp 159178172Simp/* 160178172Simp * The bits in the context register. 161178172Simp */ 162178172Simp#define CNTXT_PTE_BASE 0xff800000 163178172Simp#define CNTXT_BAD_VPN2 0x007ffff0 164178172Simp 165178172Simp/* 166178172Simp * Location of exception vectors. 167178172Simp */ 168178172Simp#define RESET_EXC_VEC 0xbfc00000 169178172Simp#define TLB_MISS_EXC_VEC 0x80000000 170178172Simp#define XTLB_MISS_EXC_VEC 0x80000080 171178172Simp#define CACHE_ERR_EXC_VEC 0x80000100 172178172Simp#define GEN_EXC_VEC 0x80000180 173178172Simp 174178172Simp/* 175178172Simp * Coprocessor 0 registers: 176178172Simp */ 177178172Simp#define COP_0_TLB_INDEX $0 178178172Simp#define COP_0_TLB_RANDOM $1 179178172Simp#define COP_0_TLB_LO0 $2 180178172Simp#define COP_0_TLB_LO1 $3 181178172Simp#define COP_0_TLB_CONTEXT $4 182178172Simp#define COP_0_TLB_PG_MASK $5 183178172Simp#define COP_0_TLB_WIRED $6 184178172Simp#define COP_0_INFO $7 185178172Simp#define COP_0_BAD_VADDR $8 186178172Simp#define COP_0_COUNT $9 187178172Simp#define COP_0_TLB_HI $10 188178172Simp#define COP_0_COMPARE $11 189178172Simp#define COP_0_STATUS_REG $12 190178172Simp#define COP_0_CAUSE_REG $13 191178172Simp#define COP_0_EXC_PC $14 192178172Simp#define COP_0_PRID $15 193178172Simp#define COP_0_CONFIG $16 194178172Simp#define COP_0_LLADDR $17 195178172Simp#define COP_0_WATCH_LO $18 196178172Simp#define COP_0_WATCH_HI $19 197178172Simp#define COP_0_TLB_XCONTEXT $20 198178172Simp#define COP_0_ECC $26 199178172Simp#define COP_0_CACHE_ERR $27 200178172Simp#define COP_0_TAG_LO $28 201178172Simp#define COP_0_TAG_HI $29 202178172Simp#define COP_0_ERROR_PC $30 203178172Simp 204178172Simp/* 205178172Simp * Coprocessor 0 Set 1 206178172Simp */ 207178172Simp#define C0P_1_IPLLO $18 208178172Simp#define C0P_1_IPLHI $19 209178172Simp#define C0P_1_INTCTL $20 210178172Simp#define C0P_1_DERRADDR0 $26 211178172Simp#define C0P_1_DERRADDR1 $27 212178172Simp 213178172Simp/* 214178172Simp * Values for the code field in a break instruction. 215178172Simp */ 216178172Simp#define BREAK_INSTR 0x0000000d 217178172Simp#define BREAK_VAL_MASK 0x03ffffc0 218178172Simp#define BREAK_VAL_SHIFT 16 219178172Simp#define BREAK_KDB_VAL 512 220178172Simp#define BREAK_SSTEP_VAL 513 221178172Simp#define BREAK_BRKPT_VAL 514 222178172Simp#define BREAK_SOVER_VAL 515 223178172Simp#define BREAK_DDB_VAL 516 224178172Simp#define BREAK_KDB (BREAK_INSTR | (BREAK_KDB_VAL << BREAK_VAL_SHIFT)) 225178172Simp#define BREAK_SSTEP (BREAK_INSTR | (BREAK_SSTEP_VAL << BREAK_VAL_SHIFT)) 226178172Simp#define BREAK_BRKPT (BREAK_INSTR | (BREAK_BRKPT_VAL << BREAK_VAL_SHIFT)) 227178172Simp#define BREAK_SOVER (BREAK_INSTR | (BREAK_SOVER_VAL << BREAK_VAL_SHIFT)) 228178172Simp#define BREAK_DDB (BREAK_INSTR | (BREAK_DDB_VAL << BREAK_VAL_SHIFT)) 229178172Simp 230178172Simp/* 231178172Simp * Mininum and maximum cache sizes. 232178172Simp */ 233178172Simp#define MIN_CACHE_SIZE (16 * 1024) 234178172Simp#define MAX_CACHE_SIZE (256 * 1024) 235178172Simp 236178172Simp/* 237178172Simp * The floating point version and status registers. 238178172Simp */ 239178172Simp#define FPC_ID $0 240178172Simp#define FPC_CSR $31 241178172Simp 242178172Simp/* 243178172Simp * The floating point coprocessor status register bits. 244178172Simp */ 245178172Simp#define FPC_ROUNDING_BITS 0x00000003 246178172Simp#define FPC_ROUND_RN 0x00000000 247178172Simp#define FPC_ROUND_RZ 0x00000001 248178172Simp#define FPC_ROUND_RP 0x00000002 249178172Simp#define FPC_ROUND_RM 0x00000003 250178172Simp#define FPC_STICKY_BITS 0x0000007c 251178172Simp#define FPC_STICKY_INEXACT 0x00000004 252178172Simp#define FPC_STICKY_UNDERFLOW 0x00000008 253178172Simp#define FPC_STICKY_OVERFLOW 0x00000010 254178172Simp#define FPC_STICKY_DIV0 0x00000020 255178172Simp#define FPC_STICKY_INVALID 0x00000040 256178172Simp#define FPC_ENABLE_BITS 0x00000f80 257178172Simp#define FPC_ENABLE_INEXACT 0x00000080 258178172Simp#define FPC_ENABLE_UNDERFLOW 0x00000100 259178172Simp#define FPC_ENABLE_OVERFLOW 0x00000200 260178172Simp#define FPC_ENABLE_DIV0 0x00000400 261178172Simp#define FPC_ENABLE_INVALID 0x00000800 262178172Simp#define FPC_EXCEPTION_BITS 0x0003f000 263178172Simp#define FPC_EXCEPTION_INEXACT 0x00001000 264178172Simp#define FPC_EXCEPTION_UNDERFLOW 0x00002000 265178172Simp#define FPC_EXCEPTION_OVERFLOW 0x00004000 266178172Simp#define FPC_EXCEPTION_DIV0 0x00008000 267178172Simp#define FPC_EXCEPTION_INVALID 0x00010000 268178172Simp#define FPC_EXCEPTION_UNIMPL 0x00020000 269178172Simp#define FPC_COND_BIT 0x00800000 270178172Simp#define FPC_FLUSH_BIT 0x01000000 271178172Simp#define FPC_MBZ_BITS 0xfe7c0000 272178172Simp 273178172Simp/* 274178172Simp * Constants to determine if have a floating point instruction. 275178172Simp */ 276178172Simp#define OPCODE_SHIFT 26 277178172Simp#define OPCODE_C1 0x11 278178172Simp 279178172Simp/* 280178172Simp * The low part of the TLB entry. 281178172Simp */ 282178172Simp#define VMTLB_PF_NUM 0x3fffffc0 283178172Simp#define VMTLB_ATTR_MASK 0x00000038 284178172Simp#define VMTLB_MOD_BIT 0x00000004 285178172Simp#define VMTLB_VALID_BIT 0x00000002 286178172Simp#define VMTLB_GLOBAL_BIT 0x00000001 287178172Simp 288178172Simp#define VMTLB_PHYS_PAGE_SHIFT 6 289178172Simp 290178172Simp/* 291178172Simp * The high part of the TLB entry. 292178172Simp */ 293178172Simp#define VMTLB_VIRT_PAGE_NUM 0xffffe000 294178172Simp#define VMTLB_PID 0x000000ff 295178172Simp#define VMTLB_PID_R9K 0x00000fff 296178172Simp#define VMTLB_PID_SHIFT 0 297178172Simp#define VMTLB_VIRT_PAGE_SHIFT 12 298178172Simp#define VMTLB_VIRT_PAGE_SHIFT_R9K 13 299178172Simp 300178172Simp/* 301178172Simp * The first TLB entry that write random hits. 302178172Simp */ 303178172Simp#define VMWIRED_ENTRIES 1 304178172Simp 305178172Simp/* 306178172Simp * The number of process id entries. 307178172Simp */ 308178172Simp#define VMNUM_PIDS 256 309178172Simp 310178172Simp/* 311178172Simp * TLB probe return codes. 312178172Simp */ 313178172Simp#define VMTLB_NOT_FOUND 0 314178172Simp#define VMTLB_FOUND 1 315178172Simp#define VMTLB_FOUND_WITH_PATCH 2 316178172Simp#define VMTLB_PROBE_ERROR 3 317178172Simp 318178172Simp/* 319178172Simp * Exported definitions unique to mips cpu support. 320178172Simp */ 321178172Simp 322178172Simp/* 323178172Simp * definitions of cpu-dependent requirements 324178172Simp * referenced in generic code 325178172Simp */ 326178172Simp#define COPY_SIGCODE /* copy sigcode above user stack in exec */ 327178172Simp 328178172Simp#define cpu_swapout(p) panic("cpu_swapout: can't get here"); 329178172Simp 330178172Simp#ifndef _LOCORE 331178172Simp#include <machine/frame.h> 332178172Simp/* 333178172Simp * Arguments to hardclock and gatherstats encapsulate the previous 334178172Simp * machine state in an opaque clockframe. 335178172Simp */ 336178172Simp#define clockframe trapframe /* Use normal trap frame */ 337178172Simp 338178172Simp#define CLKF_USERMODE(framep) ((framep)->sr & SR_KSU_USER) 339178172Simp#define CLKF_BASEPRI(framep) ((framep)->cpl == 0) 340178172Simp#define CLKF_PC(framep) ((framep)->pc) 341178172Simp#define CLKF_INTR(framep) (0) 342178172Simp#define MIPS_CLKF_INTR() (intr_nesting_level >= 1) 343178172Simp#define TRAPF_USERMODE(framep) (((framep)->sr & SR_KSU_USER) != 0) 344178172Simp#define TRAPF_PC(framep) ((framep)->pc) 345178172Simp#define cpu_getstack(td) ((td)->td_frame->sp) 346178172Simp 347178172Simp/* 348178172Simp * CPU identification, from PRID register. 349178172Simp */ 350178172Simpunion cpuprid { 351178172Simp int cpuprid; 352178172Simp struct { 353178172Simp#if BYTE_ORDER == BIG_ENDIAN 354178172Simp u_int pad1:8; /* reserved */ 355178172Simp u_int cp_vendor:8; /* company identifier */ 356178172Simp u_int cp_imp:8; /* implementation identifier */ 357178172Simp u_int cp_majrev:4; /* major revision identifier */ 358178172Simp u_int cp_minrev:4; /* minor revision identifier */ 359178172Simp#else 360178172Simp u_int cp_minrev:4; /* minor revision identifier */ 361178172Simp u_int cp_majrev:4; /* major revision identifier */ 362178172Simp u_int cp_imp:8; /* implementation identifier */ 363178172Simp u_int cp_vendor:8; /* company identifier */ 364178172Simp u_int pad1:8; /* reserved */ 365178172Simp#endif 366178172Simp } cpu; 367178172Simp}; 368178172Simp 369178172Simp#endif /* !_LOCORE */ 370178172Simp 371178172Simp/* 372178172Simp * CTL_MACHDEP definitions. 373178172Simp */ 374178172Simp#define CPU_CONSDEV 1 /* dev_t: console terminal device */ 375178172Simp#define CPU_ADJKERNTZ 2 /* int: timezone offset (seconds) */ 376178172Simp#define CPU_DISRTCSET 3 /* int: disable resettodr() call */ 377178172Simp#define CPU_BOOTINFO 4 /* struct: bootinfo */ 378178172Simp#define CPU_WALLCLOCK 5 /* int: indicates wall CMOS clock */ 379178172Simp#define CPU_MAXID 6 /* number of valid machdep ids */ 380178172Simp 381178172Simp#define CTL_MACHDEP_NAMES { \ 382178172Simp { 0, 0 }, \ 383178172Simp { "console_device", CTLTYPE_STRUCT }, \ 384178172Simp { "adjkerntz", CTLTYPE_INT }, \ 385178172Simp { "disable_rtc_set", CTLTYPE_INT }, \ 386178172Simp { "bootinfo", CTLTYPE_STRUCT }, \ 387178172Simp { "wall_cmos_clock", CTLTYPE_INT }, \ 388178172Simp} 389178172Simp 390178172Simp/* 391178172Simp * MIPS CPU types (cp_imp). 392178172Simp */ 393178172Simp#define MIPS_R2000 0x01 /* MIPS R2000 CPU ISA I */ 394178172Simp#define MIPS_R3000 0x02 /* MIPS R3000 CPU ISA I */ 395178172Simp#define MIPS_R6000 0x03 /* MIPS R6000 CPU ISA II */ 396178172Simp#define MIPS_R4000 0x04 /* MIPS R4000/4400 CPU ISA III */ 397178172Simp#define MIPS_R3LSI 0x05 /* LSI Logic R3000 derivate ISA I */ 398178172Simp#define MIPS_R6000A 0x06 /* MIPS R6000A CPU ISA II */ 399178172Simp#define MIPS_R3IDT 0x07 /* IDT R3000 derivate ISA I */ 400178172Simp#define MIPS_R10000 0x09 /* MIPS R10000/T5 CPU ISA IV */ 401178172Simp#define MIPS_R4200 0x0a /* MIPS R4200 CPU (ICE) ISA III */ 402178172Simp#define MIPS_R4300 0x0b /* NEC VR4300 CPU ISA III */ 403178172Simp#define MIPS_R4100 0x0c /* NEC VR41xx CPU MIPS-16 ISA III */ 404178172Simp#define MIPS_R8000 0x10 /* MIPS R8000 Blackbird/TFP ISA IV */ 405178172Simp#define MIPS_R4600 0x20 /* QED R4600 Orion ISA III */ 406178172Simp#define MIPS_R4700 0x21 /* QED R4700 Orion ISA III */ 407178172Simp#define MIPS_R3TOSH 0x22 /* Toshiba R3000 based CPU ISA I */ 408178172Simp#define MIPS_R5000 0x23 /* MIPS R5000 CPU ISA IV */ 409178172Simp#define MIPS_RM7000 0x27 /* QED RM7000 CPU ISA IV */ 410178172Simp#define MIPS_RM52X0 0x28 /* QED RM52X0 CPU ISA IV */ 411178172Simp#define MIPS_VR5400 0x54 /* NEC Vr5400 CPU ISA IV+ */ 412178172Simp#define MIPS_RM9000 0x34 /* E9000 CPU */ 413178172Simp 414178172Simp/* 415178172Simp * MIPS FPU types 416178172Simp */ 417178172Simp#define MIPS_SOFT 0x00 /* Software emulation ISA I */ 418178172Simp#define MIPS_R2360 0x01 /* MIPS R2360 FPC ISA I */ 419178172Simp#define MIPS_R2010 0x02 /* MIPS R2010 FPC ISA I */ 420178172Simp#define MIPS_R3010 0x03 /* MIPS R3010 FPC ISA I */ 421178172Simp#define MIPS_R6010 0x04 /* MIPS R6010 FPC ISA II */ 422178172Simp#define MIPS_R4010 0x05 /* MIPS R4000/R4400 FPC ISA II */ 423178172Simp#define MIPS_R31LSI 0x06 /* LSI Logic derivate ISA I */ 424178172Simp#define MIPS_R10010 0x09 /* MIPS R10000/T5 FPU ISA IV */ 425178172Simp#define MIPS_R4210 0x0a /* MIPS R4200 FPC (ICE) ISA III */ 426178172Simp#define MIPS_UNKF1 0x0b /* unnanounced product cpu ISA III */ 427178172Simp#define MIPS_R8000 0x10 /* MIPS R8000 Blackbird/TFP ISA IV */ 428178172Simp#define MIPS_R4600 0x20 /* QED R4600 Orion ISA III */ 429178172Simp#define MIPS_R3SONY 0x21 /* Sony R3000 based FPU ISA I */ 430178172Simp#define MIPS_R3TOSH 0x22 /* Toshiba R3000 based FPU ISA I */ 431178172Simp#define MIPS_R5010 0x23 /* MIPS R5000 based FPU ISA IV */ 432178172Simp#define MIPS_RM7000 0x27 /* QED RM7000 FPU ISA IV */ 433178172Simp#define MIPS_RM5230 0x28 /* QED RM52X0 based FPU ISA IV */ 434178172Simp#define MIPS_RM52XX 0x28 /* QED RM52X0 based FPU ISA IV */ 435178172Simp#define MIPS_VR5400 0x54 /* NEC Vr5400 FPU ISA IV+ */ 436178172Simp 437178172Simp#ifndef _LOCORE 438178172Simpextern union cpuprid cpu_id; 439178172Simp 440178172Simp#define mips_proc_type() ((cpu_id.cpu.cp_vendor << 8) | cpu_id.cpu.cp_imp) 441178172Simp#define mips_set_proc_type(type) (cpu_id.cpu.cp_vendor = (type) >> 8, \ 442178172Simp cpu_id.cpu.cp_imp = ((type) & 0x00ff)) 443178172Simp#endif /* !_LOCORE */ 444178172Simp 445178172Simp#if defined(_KERNEL) && !defined(_LOCORE) 446178172Simpextern union cpuprid fpu_id; 447178172Simp 448178172Simpstruct tlb; 449178172Simpstruct user; 450178172Simp 451178172Simpu_int32_t mips_cp0_config1_read(void); 452178172Simpint Mips_ConfigCache(void); 453178172Simpvoid Mips_SetWIRED(int); 454178172Simpvoid Mips_SetPID(int); 455178172Simpu_int Mips_GetCOUNT(void); 456178172Simpvoid Mips_SetCOMPARE(u_int); 457178172Simpu_int Mips_GetCOMPARE(void); 458178172Simp 459178172Simpvoid Mips_SyncCache(void); 460178172Simpvoid Mips_SyncDCache(vm_offset_t, int); 461178172Simpvoid Mips_HitSyncDCache(vm_offset_t, int); 462178172Simpvoid Mips_HitSyncSCache(vm_offset_t, int); 463178172Simpvoid Mips_IOSyncDCache(vm_offset_t, int, int); 464178172Simpvoid Mips_HitInvalidateDCache(vm_offset_t, int); 465178172Simpvoid Mips_SyncICache(vm_offset_t, int); 466178172Simpvoid Mips_InvalidateICache(vm_offset_t, int); 467178172Simp 468178172Simpvoid Mips_TLBFlush(int); 469178172Simpvoid Mips_TLBFlushAddr(vm_offset_t); 470178172Simpvoid Mips_TLBWriteIndexed(int, struct tlb *); 471178172Simpvoid Mips_TLBUpdate(vm_offset_t, unsigned); 472178172Simpvoid Mips_TLBRead(int, struct tlb *); 473178172Simpvoid mips_TBIAP(int); 474178172Simpvoid wbflush(void); 475178172Simp 476178172Simpextern u_int32_t cpu_counter_interval; /* Number of counter ticks/tick */ 477178172Simpextern u_int32_t cpu_counter_last; /* Last compare value loaded */ 478178172Simpextern int num_tlbentries; 479178172Simpextern char btext[]; 480178172Simpextern char etext[]; 481178172Simpextern int intr_nesting_level; 482178172Simp 483178172Simp#define func_0args_asmmacro(func, in) \ 484178172Simp __asm __volatile ( "jalr %0" \ 485178172Simp : "=r" (in) /* outputs */ \ 486178172Simp : "r" (func) /* inputs */ \ 487178172Simp : "$31", "$4"); 488178172Simp 489178172Simp#define func_1args_asmmacro(func, arg0) \ 490178172Simp __asm __volatile ("move $4, %1;" \ 491178172Simp "jalr %0" \ 492178172Simp : /* outputs */ \ 493178172Simp : "r" (func), "r" (arg0) /* inputs */ \ 494178172Simp : "$31", "$4"); 495178172Simp 496178172Simp#define func_2args_asmmacro(func, arg0, arg1) \ 497178172Simp __asm __volatile ("move $4, %1;" \ 498178172Simp "move $5, %2;" \ 499178172Simp "jalr %0" \ 500178172Simp : /* outputs */ \ 501178172Simp : "r" (func), "r" (arg0), "r" (arg1) /* inputs */ \ 502178172Simp : "$31", "$4", "$5"); 503178172Simp 504178172Simp#define func_3args_asmmacro(func, arg0, arg1, arg2) \ 505178172Simp __asm __volatile ( "move $4, %1;" \ 506178172Simp "move $5, %2;" \ 507178172Simp "move $6, %3;" \ 508178172Simp "jalr %0" \ 509178172Simp : /* outputs */ \ 510178172Simp : "r" (func), "r" (arg0), "r" (arg1), "r" (arg2) /* inputs */ \ 511178172Simp : "$31", "$4", "$5", "$6"); 512178172Simp 513178172Simp#define MachSetPID Mips_SetPID 514178172Simp#define MachTLBUpdate Mips_TLBUpdate 515178172Simp#define mips_TBIS Mips_TLBFlushAddr 516178172Simp#define MIPS_TBIAP() mips_TBIAP(num_tlbentries) 517178172Simp#define MachSetWIRED(index) Mips_SetWIRED(index) 518178172Simp#define MachTLBFlush(count) Mips_TLBFlush(count) 519178172Simp#define MachTLBGetPID(pid) (pid = Mips_TLBGetPID()) 520178172Simp#define MachTLBRead(tlbno, tlbp) Mips_TLBRead(tlbno, tlbp) 521178172Simp#define MachFPTrap(sr, cause, pc) MipsFPTrap(sr, cause, pc) 522178172Simp 523178172Simp/* 524178172Simp * Enable realtime clock (always enabled). 525178172Simp */ 526178172Simp#define enablertclock() 527178172Simp 528178172Simp/* 529178172Simp * Are we in an interrupt handler? required by JunOS 530178172Simp */ 531178172Simp#define IN_INT_HANDLER() \ 532178172Simp (curthread->td_intr_nesting_level != 0 || \ 533178172Simp (curthread->td_pflags & TDP_ITHREAD)) 534178172Simp 535178172Simp/* 536178172Simp * Low level access routines to CPU registers 537178172Simp */ 538178172Simp 539178172Simpvoid setsoftintr0(void); 540178172Simpvoid clearsoftintr0(void); 541178172Simpvoid setsoftintr1(void); 542178172Simpvoid clearsoftintr1(void); 543178172Simp 544178172Simp 545178172Simpu_int32_t mips_cp0_status_read(void); 546178172Simpvoid mips_cp0_status_write(u_int32_t); 547178172Simp 548178172Simpint disableintr(void); 549178172Simpvoid restoreintr(int); 550178172Simpint enableintr(void); 551178172Simpint Mips_TLBGetPID(void); 552178172Simp 553178172Simpvoid swi_vm(void *); 554178172Simpvoid cpu_halt(void); 555178172Simpvoid cpu_reset(void); 556178172Simp 557178172Simpu_int32_t set_intr_mask(u_int32_t); 558178172Simpu_int32_t get_intr_mask(void); 559178172Simpu_int32_t get_cyclecount(void); 560178172Simp 561178172Simp#define cpu_spinwait() /* nothing */ 562178172Simp 563178172Simp#endif /* _KERNEL */ 564178172Simp#endif /* !_MACHINE_CPU_H_ */ 565