1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License.  See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1999 Ralf Baechle
7 * Copyright (C) 1999 Silicon Graphics, Inc.
8 */
9#include <linux/init.h>
10#include <asm/mipsregs.h>
11#include <asm/page.h>
12#include <asm/regdef.h>
13#include <asm/stackframe.h>
14#include <asm/war.h>
15
16	.macro	__BUILD_cli
17	CLI
18	.endm
19
20	.macro	__BUILD_sti
21	STI
22	.endm
23
24	.macro	__BUILD_kmode
25	KMODE
26	.endm
27
28	.macro	tlb_handler name interruptible writebit
29	NESTED(__\name, PT_SIZE, sp)
30	SAVE_ALL
31	dmfc0	a2, CP0_BADVADDR
32	__BUILD_\interruptible
33	li	a1, \writebit
34	sd	a2, PT_BVADDR(sp)
35	move	a0, sp
36	jal	do_page_fault
37	j	ret_from_exception
38	END(__\name)
39	.endm
40
41	.macro	tlb_handler_m3 name interruptible writebit
42	NESTED(__\name, PT_SIZE, sp)
43	dmfc0	k0, CP0_BADVADDR
44	dmfc0	k1, CP0_ENTRYHI
45	xor	k0, k1
46	dsrl	k0, k0, PAGE_SHIFT + 1
47	bnez	k0, 1f
48	SAVE_ALL
49	dmfc0	a2, CP0_BADVADDR
50	__BUILD_\interruptible
51	li	a1, \writebit
52	sd	a2, PT_BVADDR(sp)
53	move	a0, sp
54	jal	do_page_fault
551:
56	j	ret_from_exception
57	END(__\name)
58	.endm
59
60	tlb_handler	xtlb_mod kmode 1
61#if BCM1250_M3_WAR
62	tlb_handler_m3	xtlb_tlbl kmode 0
63#else
64	tlb_handler	xtlb_tlbl kmode 0
65#endif
66	tlb_handler	xtlb_tlbs kmode 1
67