summaryrefslogtreecommitdiff
path: root/sys/arch/mips64/include/mips_cpu.h
blob: 9e3522b38f621220255f9b216fa1da11719738d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/*	$OpenBSD: mips_cpu.h,v 1.10 2021/05/01 16:11:11 visa Exp $	*/

/*-
 * Copyright (c) 1992, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * This code is derived from software contributed to Berkeley by
 * Ralph Campbell and Rick Macklem.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	Copyright (C) 1989 Digital Equipment Corporation.
 *	Permission to use, copy, modify, and distribute this software and
 *	its documentation for any purpose and without fee is hereby granted,
 *	provided that the above copyright notice appears in all copies.
 *	Digital Equipment Corporation makes no representations about the
 *	suitability of this software for any purpose.  It is provided "as is"
 *	without express or implied warranty.
 *
 *	from: @(#)cpu.h	8.4 (Berkeley) 1/4/94
 */

#ifndef _MIPS64_CPUREGS_H_
#define	_MIPS64_CPUREGS_H_

#if defined(_KERNEL) || defined(_STANDALONE)

/*
 * Status register.
 */

#define	SR_COP_USABILITY	0x30000000	/* CP0 and CP1 only */
#define	SR_COP_0_BIT		0x10000000
#define	SR_COP_1_BIT		0x20000000
#define	SR_COP_2_BIT		0x40000000
#define	SR_RP			0x08000000
#define	SR_FR_32		0x04000000
#define	SR_RE			0x02000000
#define	SR_DSD			0x01000000	/* Only on R12000 */
#define	SR_BOOT_EXC_VEC		0x00400000
#define	SR_TLB_SHUTDOWN		0x00200000
#define	SR_SOFT_RESET		0x00100000
#define	SR_DIAG_CH		0x00040000
#define	SR_DIAG_CE		0x00020000
#define	SR_DIAG_DE		0x00010000
#define	SR_KX			0x00000080
#define	SR_SX			0x00000040
#define	SR_UX			0x00000020
#define	SR_ERL			0x00000004
#define	SR_EXL			0x00000002
#define	SR_INT_ENAB		0x00000001

#define	SOFT_INT_MASK_0		0x00000100
#define	SOFT_INT_MASK_1		0x00000200
#define	SR_INT_MASK_0		0x00000400
#define	SR_INT_MASK_1		0x00000800
#define	SR_INT_MASK_2		0x00001000
#define	SR_INT_MASK_3		0x00002000
#define	SR_INT_MASK_4		0x00004000
#define	SR_INT_MASK_5		0x00008000

#define	SR_XX			0x80000000
#define	SR_KSU_MASK		0x00000018
#define	SR_KSU_SUPER		0x00000008
#define	SR_KSU_KERNEL		0x00000000
#define	SR_INT_MASK		0x0000ff00
/* SR_KSU_USER is in <mips64/cpu.h> for CLKF_USERMODE() */
#ifndef SR_KSU_USER
#define	SR_KSU_USER		0x00000010
#endif

#define	SOFT_INT_MASK		(SOFT_INT_MASK_0 | SOFT_INT_MASK_1)

/*
 * Cause register.
 */

#define	CR_BR_DELAY		0x80000000
#define	CR_EXC_CODE		0x0000007c
#define	CR_EXC_CODE_SHIFT	2
#define	CR_COP_ERR		0x30000000
#define	CR_COP1_ERR		0x10000000
#define	CR_COP2_ERR		0x20000000
#define	CR_COP3_ERR		0x20000000
#define	CR_INT_SOFT0		0x00000100
#define	CR_INT_SOFT1		0x00000200
#define	CR_INT_0		0x00000400
#define	CR_INT_1		0x00000800
#define	CR_INT_2		0x00001000
#define	CR_INT_3		0x00002000
#define	CR_INT_4		0x00004000
#define	CR_INT_5		0x00008000

#define	CR_INT_MASK		0x003fff00

/*
 * Config register.
 */

#define	CFGR_CCA_MASK		0x00000007
#define	CFGR_CU			0x00000008
#define	CFGR_ICE		0x0000000200000000
#define	CFGR_SMM		0x0000000400000000

/*
 * Location of exception vectors.
 */

#define	RESET_EXC_VEC		(CKSEG1_BASE + 0x1fc00000)
#define	TLB_MISS_EXC_VEC	(CKSEG1_BASE + 0x00000000)
#define	XTLB_MISS_EXC_VEC	(CKSEG1_BASE + 0x00000080)
#define	CACHE_ERR_EXC_VEC	(CKSEG1_BASE + 0x00000100)
#define	GEN_EXC_VEC		(CKSEG1_BASE + 0x00000180)

/*
 * Coprocessor 0 registers
 */

/* Common subset */
#define	COP_0_COUNT		$9
#define	COP_0_TLB_HI		$10
#define	COP_0_STATUS_REG	$12
#define	COP_0_CAUSE_REG		$13
#define	COP_0_EXC_PC		$14
#define	COP_0_PRID		$15
#define	COP_0_CONFIG		$16

/* MIPS64 release 2 */
#define	COP_0_USERLOCAL		$4, 2
#define	COP_0_TLB_PG_GRAIN	$5, 1
#define	COP_0_EBASE		$15, 1

/* R4000/5000/10000 */
#define	COP_0_TLB_INDEX		$0
#define	COP_0_TLB_RANDOM	$1
#define	COP_0_TLB_LO0		$2
#define	COP_0_TLB_LO1		$3
#define	COP_0_TLB_CONTEXT	$4
#define	COP_0_TLB_PG_MASK	$5
#define	COP_0_TLB_WIRED		$6
#define	COP_0_BAD_VADDR		$8
#define	COP_0_COMPARE		$11
#define	COP_0_LLADDR		$17
#define	COP_0_WATCH_LO		$18
#define	COP_0_WATCH_HI		$19
#define	COP_0_TLB_XCONTEXT	$20
#define	COP_0_ECC		$26
#define	COP_0_CACHE_ERR		$27
#define	COP_0_TAG_LO		$28
#define	COP_0_TAG_HI		$29
#define	COP_0_ERROR_PC		$30

/* Loongson-2 specific */
#define	COP_0_DIAG		$22

/* Octeon specific */
#define COP_0_CVMCTL		$9, 7
#define COP_0_CVMMEMCTL		$11, 7

/*
 * COP_0_COUNT speed divider.
 */
#if defined(CPU_OCTEON)
#define	CP0_CYCLE_DIVIDER	1
#else
#define	CP0_CYCLE_DIVIDER	2
#endif

/*
 * The floating point version and status registers.
 */
#define	FPC_ID			$0
#define	FPC_CSR			$31

/*
 * Config1 register
 */
#define	CONFIG1_M		0x80000000u
#define	CONFIG1_MMUSize1	0x7e000000u
#define	CONFIG1_MMUSize1_SHIFT	25
#define	CONFIG1_IS		0x01c00000u
#define	CONFIG1_IS_SHIFT	22
#define	CONFIG1_IL		0x00380000u
#define	CONFIG1_IL_SHIFT	19
#define	CONFIG1_IA		0x00070000u
#define	CONFIG1_IA_SHIFT	16
#define	CONFIG1_DS		0x0000e000u
#define	CONFIG1_DS_SHIFT	13
#define	CONFIG1_DL		0x00001c00u
#define	CONFIG1_DL_SHIFT	10
#define	CONFIG1_DA		0x00000380u
#define	CONFIG1_DA_SHIFT	7
#define	CONFIG1_C2		0x00000040u
#define	CONFIG1_MD		0x00000020u
#define	CONFIG1_PC		0x00000010u
#define	CONFIG1_WR		0x00000008u
#define	CONFIG1_CA		0x00000004u
#define	CONFIG1_EP		0x00000002u
#define	CONFIG1_FP		0x00000001u

/*
 * Config3 register
 */
#define	CONFIG3_M		0x80000000
#define	CONFIG3_BPG		0x40000000
#define	CONFIG3_CMGCR		0x20000000
#define	CONFIG3_IPLW		0x00600000
#define	CONFIG3_MMAR		0x001c0000
#define	CONFIG3_MCU		0x00020000
#define	CONFIG3_ISAOnExc	0x00010000
#define	CONFIG3_ISA		0x0000c000
#define	CONFIG3_ULRI		0x00002000
#define	CONFIG3_RXI		0x00001000
#define	CONFIG3_DSP2P		0x00000800
#define	CONFIG3_DSPP		0x00000400
#define	CONFIG3_CTXTC		0x00000200
#define	CONFIG3_ITL		0x00000100
#define	CONFIG3_LPA		0x00000080
#define	CONFIG3_VEIC		0x00000040
#define	CONFIG3_VInt		0x00000020
#define	CONFIG3_SP		0x00000010
#define	CONFIG3_CDMM		0x00000008
#define	CONFIG3_MT		0x00000004
#define	CONFIG3_SM		0x00000002
#define	CONFIG3_TL		0x00000001

/*
 * Config4 register
 */
#define	CONFIG4_M		0x80000000u
#define	CONFIG4_IE		0x60000000u
#define	CONFIG4_AE		0x10000000u
#define	CONFIG4_VTLBSizeExt	0x0f000000u	/* when MMUExtDef=3 */
#define	CONFIG4_KScrExist	0x00ff0000u
#define	CONFIG4_MMUExtDef	0x0000c000u
#define	CONFIG4_MMUExtDef_SHIFT	14
#define	CONFIG4_FTLBPageSize	0x00001f00u	/* when MMUExtDef=2 or 3 */
#define	CONFIG4_FTLBWays	0x000000f0u	/* when MMUExtDef=2 or 3 */
#define	CONFIG4_FTLBSets	0x0000000fu	/* when MMUExtDef=2 or 3 */
#define	CONFIG4_MMUSizeExt	0x000000ffu	/* when MMUExtDef=1 */

/*
 * PageGrain register
 */
#define	PGRAIN_RIE		0x80000000
#define	PGRAIN_XIE		0x40000000
#define	PGRAIN_ELPA		0x20000000
#define	PGRAIN_ESP		0x10000000
#define	PGRAIN_IEC		0x08000000

/*
 * HWREna register
 */
#define	HWRENA_ULR		0x20000000u
#define	HWRENA_CC		0x00000004u

#endif	/* _KERNEL || _STANDALONE */

#endif /* !_MIPS64_CPUREGS_H_ */