cpu.h revision 206717
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 206717 2010-04-17 01:17:31Z jmallett $ 45178172Simp */ 46178172Simp 47178172Simp#ifndef _MACHINE_CPU_H_ 48178172Simp#define _MACHINE_CPU_H_ 49178172Simp 50178172Simp#include <machine/endian.h> 51178172Simp 52178172Simp#define MIPS_KSEG0_LARGEST_PHYS 0x20000000 53178172Simp#define MIPS_PHYS_MASK (0x1fffffff) 54178172Simp 55202031Simp#define MIPS_PHYS_TO_KSEG0(x) ((uintptr_t)(x) | MIPS_KSEG0_START) 56202031Simp#define MIPS_PHYS_TO_KSEG1(x) ((uintptr_t)(x) | MIPS_KSEG1_START) 57202031Simp#define MIPS_KSEG0_TO_PHYS(x) ((uintptr_t)(x) & MIPS_PHYS_MASK) 58202031Simp#define MIPS_KSEG1_TO_PHYS(x) ((uintptr_t)(x) & MIPS_PHYS_MASK) 59178172Simp 60202031Simp#define MIPS_IS_KSEG0_ADDR(x) \ 61202031Simp (((vm_offset_t)(x) >= MIPS_KSEG0_START) && \ 62202031Simp ((vm_offset_t)(x) <= MIPS_KSEG0_END)) 63202031Simp#define MIPS_IS_KSEG1_ADDR(x) \ 64202031Simp (((vm_offset_t)(x) >= MIPS_KSEG1_START) && \ 65202031Simp ((vm_offset_t)(x) <= MIPS_KSEG1_END)) 66202031Simp#define MIPS_IS_VALID_PTR(x) (MIPS_IS_KSEG0_ADDR(x) || \ 67202031Simp MIPS_IS_KSEG1_ADDR(x)) 68202031Simp 69178172Simp/* 70178172Simp * Status register. 71178172Simp */ 72178172Simp#define SR_COP_USABILITY 0xf0000000 73178172Simp#define SR_COP_0_BIT 0x10000000 74178172Simp#define SR_COP_1_BIT 0x20000000 75178172Simp#define SR_COP_2_BIT 0x40000000 76178172Simp#define SR_RP 0x08000000 77178172Simp#define SR_FR_32 0x04000000 78178172Simp#define SR_RE 0x02000000 79178172Simp#define SR_PX 0x00800000 80178172Simp#define SR_BOOT_EXC_VEC 0x00400000 81178172Simp#define SR_TLB_SHUTDOWN 0x00200000 82178172Simp#define SR_SOFT_RESET 0x00100000 83178172Simp#define SR_DIAG_CH 0x00040000 84178172Simp#define SR_DIAG_CE 0x00020000 85178172Simp#define SR_DIAG_DE 0x00010000 86178172Simp#define SR_KX 0x00000080 87178172Simp#define SR_SX 0x00000040 88178172Simp#define SR_UX 0x00000020 89178172Simp#define SR_KSU_MASK 0x00000018 90178172Simp#define SR_KSU_USER 0x00000010 91178172Simp#define SR_KSU_SUPER 0x00000008 92178172Simp#define SR_KSU_KERNEL 0x00000000 93178172Simp#define SR_ERL 0x00000004 94178172Simp#define SR_EXL 0x00000002 95178172Simp#define SR_INT_ENAB 0x00000001 96178172Simp 97178172Simp#define SR_INT_MASK 0x0000ff00 98178172Simp#define SOFT_INT_MASK_0 0x00000100 99178172Simp#define SOFT_INT_MASK_1 0x00000200 100178172Simp#define SR_INT_MASK_0 0x00000400 101178172Simp#define SR_INT_MASK_1 0x00000800 102178172Simp#define SR_INT_MASK_2 0x00001000 103178172Simp#define SR_INT_MASK_3 0x00002000 104178172Simp#define SR_INT_MASK_4 0x00004000 105178172Simp#define SR_INT_MASK_5 0x00008000 106178172Simp#define ALL_INT_MASK SR_INT_MASK 107178172Simp#define SOFT_INT_MASK (SOFT_INT_MASK_0 | SOFT_INT_MASK_1) 108178172Simp#define HW_INT_MASK (ALL_INT_MASK & ~SOFT_INT_MASK) 109178172Simp 110203697Sneel#define soft_int_mask(softintr) (1 << ((softintr) + 8)) 111203697Sneel#define hard_int_mask(hardintr) (1 << ((hardintr) + 10)) 112178172Simp 113178172Simp/* 114178172Simp * The bits in the cause register. 115178172Simp * 116178172Simp * CR_BR_DELAY Exception happened in branch delay slot. 117178172Simp * CR_COP_ERR Coprocessor error. 118178172Simp * CR_IP Interrupt pending bits defined below. 119178172Simp * CR_EXC_CODE The exception type (see exception codes below). 120178172Simp */ 121178172Simp#define CR_BR_DELAY 0x80000000 122178172Simp#define CR_COP_ERR 0x30000000 123178172Simp#define CR_EXC_CODE 0x0000007c 124178172Simp#define CR_EXC_CODE_SHIFT 2 125178172Simp#define CR_IPEND 0x0000ff00 126178172Simp 127178172Simp/* 128178172Simp * Cause Register Format: 129178172Simp * 130178172Simp * 31 30 29 28 27 26 25 24 23 8 7 6 2 1 0 131178172Simp * ---------------------------------------------------------------------- 132178172Simp * | BD | 0| CE | 0| W2| W1| IV| IP15 - IP0 | 0| Exc Code | 0| 133178172Simp * |______________________________________________________________________ 134178172Simp */ 135178172Simp 136178172Simp#define CR_INT_SOFT0 0x00000100 137178172Simp#define CR_INT_SOFT1 0x00000200 138178172Simp#define CR_INT_0 0x00000400 139178172Simp#define CR_INT_1 0x00000800 140178172Simp#define CR_INT_2 0x00001000 141178172Simp#define CR_INT_3 0x00002000 142178172Simp#define CR_INT_4 0x00004000 143178172Simp#define CR_INT_5 0x00008000 144178172Simp 145178172Simp#define CR_INT_UART CR_INT_1 146178172Simp#define CR_INT_IPI CR_INT_2 147178172Simp#define CR_INT_CLOCK CR_INT_5 148178172Simp 149178172Simp/* 150178172Simp * The bits in the CONFIG register 151178172Simp */ 152178172Simp#define CFG_K0_UNCACHED 2 153178172Simp#define CFG_K0_CACHED 3 154202864Sneel#define CFG_K0_MASK 0x7 155178172Simp 156178172Simp/* 157178172Simp * The bits in the context register. 158178172Simp */ 159178172Simp#define CNTXT_PTE_BASE 0xff800000 160178172Simp#define CNTXT_BAD_VPN2 0x007ffff0 161178172Simp 162178172Simp/* 163178172Simp * Location of exception vectors. 164178172Simp */ 165178172Simp#define RESET_EXC_VEC 0xbfc00000 166178172Simp#define TLB_MISS_EXC_VEC 0x80000000 167178172Simp#define XTLB_MISS_EXC_VEC 0x80000080 168178172Simp#define CACHE_ERR_EXC_VEC 0x80000100 169178172Simp#define GEN_EXC_VEC 0x80000180 170178172Simp 171178172Simp/* 172178172Simp * Coprocessor 0 registers: 173178172Simp */ 174178172Simp#define COP_0_TLB_INDEX $0 175178172Simp#define COP_0_TLB_RANDOM $1 176178172Simp#define COP_0_TLB_LO0 $2 177178172Simp#define COP_0_TLB_LO1 $3 178178172Simp#define COP_0_TLB_CONTEXT $4 179178172Simp#define COP_0_TLB_PG_MASK $5 180178172Simp#define COP_0_TLB_WIRED $6 181178172Simp#define COP_0_INFO $7 182178172Simp#define COP_0_BAD_VADDR $8 183178172Simp#define COP_0_COUNT $9 184178172Simp#define COP_0_TLB_HI $10 185178172Simp#define COP_0_COMPARE $11 186178172Simp#define COP_0_STATUS_REG $12 187178172Simp#define COP_0_CAUSE_REG $13 188178172Simp#define COP_0_EXC_PC $14 189178172Simp#define COP_0_PRID $15 190178172Simp#define COP_0_CONFIG $16 191178172Simp#define COP_0_LLADDR $17 192178172Simp#define COP_0_WATCH_LO $18 193178172Simp#define COP_0_WATCH_HI $19 194178172Simp#define COP_0_TLB_XCONTEXT $20 195178172Simp#define COP_0_ECC $26 196178172Simp#define COP_0_CACHE_ERR $27 197178172Simp#define COP_0_TAG_LO $28 198178172Simp#define COP_0_TAG_HI $29 199178172Simp#define COP_0_ERROR_PC $30 200178172Simp 201178172Simp/* 202178172Simp * Coprocessor 0 Set 1 203178172Simp */ 204178172Simp#define C0P_1_IPLLO $18 205178172Simp#define C0P_1_IPLHI $19 206178172Simp#define C0P_1_INTCTL $20 207178172Simp#define C0P_1_DERRADDR0 $26 208178172Simp#define C0P_1_DERRADDR1 $27 209178172Simp 210178172Simp/* 211178172Simp * Values for the code field in a break instruction. 212178172Simp */ 213178172Simp#define BREAK_INSTR 0x0000000d 214178172Simp#define BREAK_VAL_MASK 0x03ffffc0 215178172Simp#define BREAK_VAL_SHIFT 16 216178172Simp#define BREAK_KDB_VAL 512 217178172Simp#define BREAK_SSTEP_VAL 513 218178172Simp#define BREAK_BRKPT_VAL 514 219178172Simp#define BREAK_SOVER_VAL 515 220178172Simp#define BREAK_DDB_VAL 516 221178172Simp#define BREAK_KDB (BREAK_INSTR | (BREAK_KDB_VAL << BREAK_VAL_SHIFT)) 222178172Simp#define BREAK_SSTEP (BREAK_INSTR | (BREAK_SSTEP_VAL << BREAK_VAL_SHIFT)) 223178172Simp#define BREAK_BRKPT (BREAK_INSTR | (BREAK_BRKPT_VAL << BREAK_VAL_SHIFT)) 224178172Simp#define BREAK_SOVER (BREAK_INSTR | (BREAK_SOVER_VAL << BREAK_VAL_SHIFT)) 225178172Simp#define BREAK_DDB (BREAK_INSTR | (BREAK_DDB_VAL << BREAK_VAL_SHIFT)) 226178172Simp 227178172Simp/* 228178172Simp * Mininum and maximum cache sizes. 229178172Simp */ 230178172Simp#define MIN_CACHE_SIZE (16 * 1024) 231178172Simp#define MAX_CACHE_SIZE (256 * 1024) 232178172Simp 233178172Simp/* 234178172Simp * The floating point version and status registers. 235178172Simp */ 236178172Simp#define FPC_ID $0 237178172Simp#define FPC_CSR $31 238178172Simp 239178172Simp/* 240178172Simp * The floating point coprocessor status register bits. 241178172Simp */ 242178172Simp#define FPC_ROUNDING_BITS 0x00000003 243178172Simp#define FPC_ROUND_RN 0x00000000 244178172Simp#define FPC_ROUND_RZ 0x00000001 245178172Simp#define FPC_ROUND_RP 0x00000002 246178172Simp#define FPC_ROUND_RM 0x00000003 247178172Simp#define FPC_STICKY_BITS 0x0000007c 248178172Simp#define FPC_STICKY_INEXACT 0x00000004 249178172Simp#define FPC_STICKY_UNDERFLOW 0x00000008 250178172Simp#define FPC_STICKY_OVERFLOW 0x00000010 251178172Simp#define FPC_STICKY_DIV0 0x00000020 252178172Simp#define FPC_STICKY_INVALID 0x00000040 253178172Simp#define FPC_ENABLE_BITS 0x00000f80 254178172Simp#define FPC_ENABLE_INEXACT 0x00000080 255178172Simp#define FPC_ENABLE_UNDERFLOW 0x00000100 256178172Simp#define FPC_ENABLE_OVERFLOW 0x00000200 257178172Simp#define FPC_ENABLE_DIV0 0x00000400 258178172Simp#define FPC_ENABLE_INVALID 0x00000800 259178172Simp#define FPC_EXCEPTION_BITS 0x0003f000 260178172Simp#define FPC_EXCEPTION_INEXACT 0x00001000 261178172Simp#define FPC_EXCEPTION_UNDERFLOW 0x00002000 262178172Simp#define FPC_EXCEPTION_OVERFLOW 0x00004000 263178172Simp#define FPC_EXCEPTION_DIV0 0x00008000 264178172Simp#define FPC_EXCEPTION_INVALID 0x00010000 265178172Simp#define FPC_EXCEPTION_UNIMPL 0x00020000 266178172Simp#define FPC_COND_BIT 0x00800000 267178172Simp#define FPC_FLUSH_BIT 0x01000000 268178172Simp#define FPC_MBZ_BITS 0xfe7c0000 269178172Simp 270178172Simp/* 271178172Simp * Constants to determine if have a floating point instruction. 272178172Simp */ 273178172Simp#define OPCODE_SHIFT 26 274178172Simp#define OPCODE_C1 0x11 275178172Simp 276178172Simp/* 277178172Simp * The low part of the TLB entry. 278178172Simp */ 279178172Simp#define VMTLB_PF_NUM 0x3fffffc0 280178172Simp#define VMTLB_ATTR_MASK 0x00000038 281178172Simp#define VMTLB_MOD_BIT 0x00000004 282178172Simp#define VMTLB_VALID_BIT 0x00000002 283178172Simp#define VMTLB_GLOBAL_BIT 0x00000001 284178172Simp 285178172Simp#define VMTLB_PHYS_PAGE_SHIFT 6 286178172Simp 287178172Simp/* 288178172Simp * The high part of the TLB entry. 289178172Simp */ 290178172Simp#define VMTLB_VIRT_PAGE_NUM 0xffffe000 291178172Simp#define VMTLB_PID 0x000000ff 292178172Simp#define VMTLB_PID_R9K 0x00000fff 293178172Simp#define VMTLB_PID_SHIFT 0 294178172Simp#define VMTLB_VIRT_PAGE_SHIFT 12 295178172Simp#define VMTLB_VIRT_PAGE_SHIFT_R9K 13 296178172Simp 297178172Simp/* 298178172Simp * The first TLB entry that write random hits. 299203180Sneel * TLB entry 0 maps the kernel stack of the currently running thread 300203180Sneel * TLB entry 1 maps the pcpu area of processor (only for SMP builds) 301178172Simp */ 302203180Sneel#define KSTACK_TLB_ENTRY 0 303203180Sneel#ifdef SMP 304203180Sneel#define PCPU_TLB_ENTRY 1 305203180Sneel#define VMWIRED_ENTRIES 2 306203180Sneel#else 307178172Simp#define VMWIRED_ENTRIES 1 308203180Sneel#endif /* SMP */ 309178172Simp 310178172Simp/* 311178172Simp * The number of process id entries. 312178172Simp */ 313178172Simp#define VMNUM_PIDS 256 314178172Simp 315178172Simp/* 316178172Simp * TLB probe return codes. 317178172Simp */ 318178172Simp#define VMTLB_NOT_FOUND 0 319178172Simp#define VMTLB_FOUND 1 320178172Simp#define VMTLB_FOUND_WITH_PATCH 2 321178172Simp#define VMTLB_PROBE_ERROR 3 322178172Simp 323178172Simp/* 324178172Simp * Exported definitions unique to mips cpu support. 325178172Simp */ 326178172Simp 327178172Simp/* 328178172Simp * definitions of cpu-dependent requirements 329178172Simp * referenced in generic code 330178172Simp */ 331178172Simp#define COPY_SIGCODE /* copy sigcode above user stack in exec */ 332178172Simp 333178172Simp#define cpu_swapout(p) panic("cpu_swapout: can't get here"); 334178172Simp 335178172Simp#ifndef _LOCORE 336206717Sjmallett#include <machine/cpufunc.h> 337178172Simp#include <machine/frame.h> 338178172Simp/* 339178172Simp * Arguments to hardclock and gatherstats encapsulate the previous 340178172Simp * machine state in an opaque clockframe. 341178172Simp */ 342178172Simp#define clockframe trapframe /* Use normal trap frame */ 343178172Simp 344178172Simp#define CLKF_USERMODE(framep) ((framep)->sr & SR_KSU_USER) 345178172Simp#define CLKF_PC(framep) ((framep)->pc) 346178172Simp#define CLKF_INTR(framep) (0) 347178172Simp#define MIPS_CLKF_INTR() (intr_nesting_level >= 1) 348178172Simp#define TRAPF_USERMODE(framep) (((framep)->sr & SR_KSU_USER) != 0) 349178172Simp#define TRAPF_PC(framep) ((framep)->pc) 350178172Simp#define cpu_getstack(td) ((td)->td_frame->sp) 351178172Simp 352178172Simp/* 353206717Sjmallett * A machine-independent interface to the CPU's counter. 354206717Sjmallett */ 355206717Sjmallett#define get_cyclecount() mips_rd_count() 356206717Sjmallett 357206717Sjmallett/* 358178172Simp * CPU identification, from PRID register. 359178172Simp */ 360178172Simpunion cpuprid { 361178172Simp int cpuprid; 362178172Simp struct { 363178172Simp#if BYTE_ORDER == BIG_ENDIAN 364178172Simp u_int pad1:8; /* reserved */ 365178172Simp u_int cp_vendor:8; /* company identifier */ 366178172Simp u_int cp_imp:8; /* implementation identifier */ 367178172Simp u_int cp_majrev:4; /* major revision identifier */ 368178172Simp u_int cp_minrev:4; /* minor revision identifier */ 369178172Simp#else 370178172Simp u_int cp_minrev:4; /* minor revision identifier */ 371178172Simp u_int cp_majrev:4; /* major revision identifier */ 372178172Simp u_int cp_imp:8; /* implementation identifier */ 373178172Simp u_int cp_vendor:8; /* company identifier */ 374178172Simp u_int pad1:8; /* reserved */ 375178172Simp#endif 376178172Simp } cpu; 377178172Simp}; 378178172Simp 379178172Simp#endif /* !_LOCORE */ 380178172Simp 381178172Simp/* 382178172Simp * CTL_MACHDEP definitions. 383178172Simp */ 384178172Simp#define CPU_CONSDEV 1 /* dev_t: console terminal device */ 385178172Simp#define CPU_ADJKERNTZ 2 /* int: timezone offset (seconds) */ 386178172Simp#define CPU_DISRTCSET 3 /* int: disable resettodr() call */ 387178172Simp#define CPU_BOOTINFO 4 /* struct: bootinfo */ 388178172Simp#define CPU_WALLCLOCK 5 /* int: indicates wall CMOS clock */ 389178172Simp#define CPU_MAXID 6 /* number of valid machdep ids */ 390178172Simp 391178172Simp#define CTL_MACHDEP_NAMES { \ 392178172Simp { 0, 0 }, \ 393178172Simp { "console_device", CTLTYPE_STRUCT }, \ 394178172Simp { "adjkerntz", CTLTYPE_INT }, \ 395178172Simp { "disable_rtc_set", CTLTYPE_INT }, \ 396178172Simp { "bootinfo", CTLTYPE_STRUCT }, \ 397178172Simp { "wall_cmos_clock", CTLTYPE_INT }, \ 398178172Simp} 399178172Simp 400178172Simp/* 401178172Simp * MIPS CPU types (cp_imp). 402178172Simp */ 403178172Simp#define MIPS_R2000 0x01 /* MIPS R2000 CPU ISA I */ 404178172Simp#define MIPS_R3000 0x02 /* MIPS R3000 CPU ISA I */ 405178172Simp#define MIPS_R6000 0x03 /* MIPS R6000 CPU ISA II */ 406178172Simp#define MIPS_R4000 0x04 /* MIPS R4000/4400 CPU ISA III */ 407178172Simp#define MIPS_R3LSI 0x05 /* LSI Logic R3000 derivate ISA I */ 408178172Simp#define MIPS_R6000A 0x06 /* MIPS R6000A CPU ISA II */ 409178172Simp#define MIPS_R3IDT 0x07 /* IDT R3000 derivate ISA I */ 410178172Simp#define MIPS_R10000 0x09 /* MIPS R10000/T5 CPU ISA IV */ 411178172Simp#define MIPS_R4200 0x0a /* MIPS R4200 CPU (ICE) ISA III */ 412178172Simp#define MIPS_R4300 0x0b /* NEC VR4300 CPU ISA III */ 413178172Simp#define MIPS_R4100 0x0c /* NEC VR41xx CPU MIPS-16 ISA III */ 414178172Simp#define MIPS_R8000 0x10 /* MIPS R8000 Blackbird/TFP ISA IV */ 415178172Simp#define MIPS_R4600 0x20 /* QED R4600 Orion ISA III */ 416178172Simp#define MIPS_R4700 0x21 /* QED R4700 Orion ISA III */ 417178172Simp#define MIPS_R3TOSH 0x22 /* Toshiba R3000 based CPU ISA I */ 418178172Simp#define MIPS_R5000 0x23 /* MIPS R5000 CPU ISA IV */ 419178172Simp#define MIPS_RM7000 0x27 /* QED RM7000 CPU ISA IV */ 420178172Simp#define MIPS_RM52X0 0x28 /* QED RM52X0 CPU ISA IV */ 421178172Simp#define MIPS_VR5400 0x54 /* NEC Vr5400 CPU ISA IV+ */ 422178172Simp#define MIPS_RM9000 0x34 /* E9000 CPU */ 423178172Simp 424178172Simp/* 425178172Simp * MIPS FPU types 426178172Simp */ 427178172Simp#define MIPS_SOFT 0x00 /* Software emulation ISA I */ 428178172Simp#define MIPS_R2360 0x01 /* MIPS R2360 FPC ISA I */ 429178172Simp#define MIPS_R2010 0x02 /* MIPS R2010 FPC ISA I */ 430178172Simp#define MIPS_R3010 0x03 /* MIPS R3010 FPC ISA I */ 431178172Simp#define MIPS_R6010 0x04 /* MIPS R6010 FPC ISA II */ 432178172Simp#define MIPS_R4010 0x05 /* MIPS R4000/R4400 FPC ISA II */ 433178172Simp#define MIPS_R31LSI 0x06 /* LSI Logic derivate ISA I */ 434178172Simp#define MIPS_R10010 0x09 /* MIPS R10000/T5 FPU ISA IV */ 435178172Simp#define MIPS_R4210 0x0a /* MIPS R4200 FPC (ICE) ISA III */ 436178172Simp#define MIPS_UNKF1 0x0b /* unnanounced product cpu ISA III */ 437178172Simp#define MIPS_R8000 0x10 /* MIPS R8000 Blackbird/TFP ISA IV */ 438178172Simp#define MIPS_R4600 0x20 /* QED R4600 Orion ISA III */ 439178172Simp#define MIPS_R3SONY 0x21 /* Sony R3000 based FPU ISA I */ 440178172Simp#define MIPS_R3TOSH 0x22 /* Toshiba R3000 based FPU ISA I */ 441178172Simp#define MIPS_R5010 0x23 /* MIPS R5000 based FPU ISA IV */ 442178172Simp#define MIPS_RM7000 0x27 /* QED RM7000 FPU ISA IV */ 443178172Simp#define MIPS_RM5230 0x28 /* QED RM52X0 based FPU ISA IV */ 444178172Simp#define MIPS_RM52XX 0x28 /* QED RM52X0 based FPU ISA IV */ 445178172Simp#define MIPS_VR5400 0x54 /* NEC Vr5400 FPU ISA IV+ */ 446178172Simp 447178172Simp#ifndef _LOCORE 448178172Simpextern union cpuprid cpu_id; 449178172Simp 450178172Simp#define mips_proc_type() ((cpu_id.cpu.cp_vendor << 8) | cpu_id.cpu.cp_imp) 451178172Simp#define mips_set_proc_type(type) (cpu_id.cpu.cp_vendor = (type) >> 8, \ 452178172Simp cpu_id.cpu.cp_imp = ((type) & 0x00ff)) 453178172Simp#endif /* !_LOCORE */ 454178172Simp 455178172Simp#if defined(_KERNEL) && !defined(_LOCORE) 456178172Simpextern union cpuprid fpu_id; 457178172Simp 458178172Simpstruct tlb; 459178172Simpstruct user; 460178172Simp 461178172Simpu_int32_t mips_cp0_config1_read(void); 462178172Simpint Mips_ConfigCache(void); 463178172Simpvoid Mips_SetWIRED(int); 464178172Simpvoid Mips_SetPID(int); 465178172Simpu_int Mips_GetCOUNT(void); 466178172Simpvoid Mips_SetCOMPARE(u_int); 467178172Simpu_int Mips_GetCOMPARE(void); 468178172Simp 469178172Simpvoid Mips_SyncCache(void); 470178172Simpvoid Mips_SyncDCache(vm_offset_t, int); 471178172Simpvoid Mips_HitSyncDCache(vm_offset_t, int); 472178172Simpvoid Mips_HitSyncSCache(vm_offset_t, int); 473178172Simpvoid Mips_IOSyncDCache(vm_offset_t, int, int); 474178172Simpvoid Mips_HitInvalidateDCache(vm_offset_t, int); 475178172Simpvoid Mips_SyncICache(vm_offset_t, int); 476178172Simpvoid Mips_InvalidateICache(vm_offset_t, int); 477178172Simp 478178172Simpvoid Mips_TLBFlush(int); 479178172Simpvoid Mips_TLBFlushAddr(vm_offset_t); 480178172Simpvoid Mips_TLBWriteIndexed(int, struct tlb *); 481178172Simpvoid Mips_TLBUpdate(vm_offset_t, unsigned); 482178172Simpvoid Mips_TLBRead(int, struct tlb *); 483178172Simpvoid mips_TBIAP(int); 484178172Simpvoid wbflush(void); 485178172Simp 486178172Simpextern u_int32_t cpu_counter_interval; /* Number of counter ticks/tick */ 487178172Simpextern u_int32_t cpu_counter_last; /* Last compare value loaded */ 488178172Simpextern int num_tlbentries; 489178172Simpextern char btext[]; 490178172Simpextern char etext[]; 491178172Simpextern int intr_nesting_level; 492178172Simp 493178172Simp#define func_0args_asmmacro(func, in) \ 494178172Simp __asm __volatile ( "jalr %0" \ 495178172Simp : "=r" (in) /* outputs */ \ 496178172Simp : "r" (func) /* inputs */ \ 497178172Simp : "$31", "$4"); 498178172Simp 499178172Simp#define func_1args_asmmacro(func, arg0) \ 500178172Simp __asm __volatile ("move $4, %1;" \ 501178172Simp "jalr %0" \ 502178172Simp : /* outputs */ \ 503178172Simp : "r" (func), "r" (arg0) /* inputs */ \ 504178172Simp : "$31", "$4"); 505178172Simp 506178172Simp#define func_2args_asmmacro(func, arg0, arg1) \ 507178172Simp __asm __volatile ("move $4, %1;" \ 508178172Simp "move $5, %2;" \ 509178172Simp "jalr %0" \ 510178172Simp : /* outputs */ \ 511178172Simp : "r" (func), "r" (arg0), "r" (arg1) /* inputs */ \ 512178172Simp : "$31", "$4", "$5"); 513178172Simp 514178172Simp#define func_3args_asmmacro(func, arg0, arg1, arg2) \ 515178172Simp __asm __volatile ( "move $4, %1;" \ 516178172Simp "move $5, %2;" \ 517178172Simp "move $6, %3;" \ 518178172Simp "jalr %0" \ 519178172Simp : /* outputs */ \ 520178172Simp : "r" (func), "r" (arg0), "r" (arg1), "r" (arg2) /* inputs */ \ 521178172Simp : "$31", "$4", "$5", "$6"); 522178172Simp 523178172Simp#define MachSetPID Mips_SetPID 524178172Simp#define MachTLBUpdate Mips_TLBUpdate 525178172Simp#define mips_TBIS Mips_TLBFlushAddr 526178172Simp#define MIPS_TBIAP() mips_TBIAP(num_tlbentries) 527178172Simp#define MachSetWIRED(index) Mips_SetWIRED(index) 528178172Simp#define MachTLBFlush(count) Mips_TLBFlush(count) 529178172Simp#define MachTLBGetPID(pid) (pid = Mips_TLBGetPID()) 530178172Simp#define MachTLBRead(tlbno, tlbp) Mips_TLBRead(tlbno, tlbp) 531178172Simp#define MachFPTrap(sr, cause, pc) MipsFPTrap(sr, cause, pc) 532178172Simp 533178172Simp/* 534178172Simp * Enable realtime clock (always enabled). 535178172Simp */ 536178172Simp#define enablertclock() 537178172Simp 538178172Simp/* 539178172Simp * Are we in an interrupt handler? required by JunOS 540178172Simp */ 541178172Simp#define IN_INT_HANDLER() \ 542178172Simp (curthread->td_intr_nesting_level != 0 || \ 543178172Simp (curthread->td_pflags & TDP_ITHREAD)) 544178172Simp 545178172Simp/* 546178172Simp * Low level access routines to CPU registers 547178172Simp */ 548178172Simp 549178172Simpint Mips_TLBGetPID(void); 550178172Simp 551178172Simpvoid swi_vm(void *); 552178172Simpvoid cpu_halt(void); 553178172Simpvoid cpu_reset(void); 554178172Simp 555178172Simpu_int32_t set_intr_mask(u_int32_t); 556178172Simpu_int32_t get_intr_mask(void); 557178172Simp 558178172Simp#define cpu_spinwait() /* nothing */ 559178172Simp 560178172Simp#endif /* _KERNEL */ 561178172Simp#endif /* !_MACHINE_CPU_H_ */ 562