Import 2.3.9pre5
[davej-history.git] / arch / mips / lib / watch.S
blob351c734ff6c5353c0f8034915afd1f5da6a39ee0
1 /*
2  * Kernel debug stuff to use the Watch registers.
3  * Useful to find stack overflows, dangling pointers etc.
4  *
5  * This file is subject to the terms and conditions of the GNU General Public
6  * License.  See the file "COPYING" in the main directory of this archive
7  * for more details.
8  *
9  * Copyright (C) 1995, 1996 by Ralf Baechle
10  */
11 #include <asm/asm.h>
12 #include <asm/mipsregs.h>
13 #include <asm/regdef.h>
15                 .set    noreorder
17  * Parameter: a0 - logic address to watch
18  *                 Currently only KSEG0 addresses are allowed!
19  *            a1 - set bit #1 to trap on load references
20  *                     bit #0 to trap on store references
21  * Results  : none
22  */
23                 LEAF(__watch_set)
24                 li      t0,0x80000000
25                 subu    a0,t0
26                 ori     a0,7
27                 xori    a0,7
28                 or      a0,a1
29                 mtc0    a0,CP0_WATCHLO
30                 sw      a0,watch_savelo
32                 jr      ra
33                  mtc0   zero,CP0_WATCHHI
34                 END(__watch_set)
37  * Parameter: none
38  * Results  : none
39  */
40                 LEAF(__watch_clear)
41                 jr      ra
42                  mtc0   zero,CP0_WATCHLO
43                 END(__watch_clear)
46  * Parameter: none
47  * Results  : none
48  */
49                 LEAF(__watch_reenable)
50                 lw      t0,watch_savelo
52                 jr      ra
53                  mtc0   t0,CP0_WATCHLO
54                 END(__watch_reenable)
57  * Saved value of the c0_watchlo register for watch_reenable()
58  */
59                 .data
60 watch_savelo:   .word   0
61                 .text
64  * The stuff below are just some kernel debugging gadgets. It is only here
65  * because it had to be somewhere and will go away.
66  */
69  * Parameter: none
70  * Results  : none
71  */
72                 LEAF(get_sp)
73                 jr      ra
74                  move   v0,sp
75                 END(get_sp)
78  * Parameter: none
79  * Results  : none
80  */
81                 LEAF(get_ra)
82                 jr      ra
83                  move   v0,ra
84                 END(get_ra)
87  * Parameter: none
88  * Results  : none
89  */
90                 LEAF(get_status)
91                 jr      ra
92                  mfc0   v0,CP0_STATUS
93                 END(get_status)
96  * Parameter: none
97  * Results  : none
98  */
99                 NESTED(print_sp, ((5*SZREG)+ALSZ)&ALMASK, sp)
100                 .mask   0x80000000,4*SZREG
101                 PTR_SUBU        sp,((5*SZREG)+ALSZ)&ALMASK
102                 REG_S           ra,4*SZREG(sp)
103                 move            a1,sp
104                 PRINT("$sp == %08lx\n")
105                 REG_L           ra,4*SZREG(sp)
107                 jr              ra
108                  PTR_ADDU       sp,((5*SZREG)+ALSZ)&ALMASK
109                 END(print_sp)
112  * Parameter: none
113  * Results  : none
114  */
115                 NESTED(print_st, ((5*SZREG)+ALSZ)&ALMASK, sp)
116                 .mask   0x80000000,4*SZREG
117                 PTR_SUBU        sp,((5*SZREG)+ALSZ)&ALMASK
118                 REG_S           ra,4*SZREG(sp)
119                 mfc0            a1,CP0_STATUS
120                 PRINT("cp0_status == %08lx\n")
121                 REG_L           ra,4*SZREG(sp)
123                 jr              ra
124                  PTR_ADDU       sp,((5*SZREG)+ALSZ)&ALMASK
125                 END(print_st)