diff options
author | David Daney <ddaney@avtrex.com> | 2008-09-23 03:05:54 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2008-10-11 11:18:56 -0400 |
commit | 6aa3524c182c01b8b8b7c21c4da20c742a9b4d86 (patch) | |
tree | 245fc4e9f26ad9e7a95e83087bfcc79528d1352e /arch/mips/include | |
parent | 8192c9ea9ac44213d1266ecb64615519443979b3 (diff) |
MIPS: Add HARDWARE_WATCHPOINTS definitions and support code.
This is the main support code for the patch. Here we just add the
code, the following patches hook it up.
Signed-off-by: David Daney <ddaney@avtrex.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
create mode 100644 arch/mips/include/asm/watch.h
create mode 100644 arch/mips/kernel/watch.c
Diffstat (limited to 'arch/mips/include')
-rw-r--r-- | arch/mips/include/asm/cpu-info.h | 6 | ||||
-rw-r--r-- | arch/mips/include/asm/processor.h | 20 | ||||
-rw-r--r-- | arch/mips/include/asm/thread_info.h | 2 | ||||
-rw-r--r-- | arch/mips/include/asm/watch.h | 32 |
4 files changed, 60 insertions, 0 deletions
diff --git a/arch/mips/include/asm/cpu-info.h b/arch/mips/include/asm/cpu-info.h index 2de73dbb2e9e..744cd8fb107f 100644 --- a/arch/mips/include/asm/cpu-info.h +++ b/arch/mips/include/asm/cpu-info.h | |||
@@ -12,6 +12,8 @@ | |||
12 | #ifndef __ASM_CPU_INFO_H | 12 | #ifndef __ASM_CPU_INFO_H |
13 | #define __ASM_CPU_INFO_H | 13 | #define __ASM_CPU_INFO_H |
14 | 14 | ||
15 | #include <linux/types.h> | ||
16 | |||
15 | #include <asm/cache.h> | 17 | #include <asm/cache.h> |
16 | 18 | ||
17 | /* | 19 | /* |
@@ -69,6 +71,10 @@ struct cpuinfo_mips { | |||
69 | int tc_id; /* Thread Context number */ | 71 | int tc_id; /* Thread Context number */ |
70 | #endif | 72 | #endif |
71 | void *data; /* Additional data */ | 73 | void *data; /* Additional data */ |
74 | unsigned int watch_reg_count; /* Number that exist */ | ||
75 | unsigned int watch_reg_use_cnt; /* Usable by ptrace */ | ||
76 | #define NUM_WATCH_REGS 4 | ||
77 | u16 watch_reg_masks[NUM_WATCH_REGS]; | ||
72 | } __attribute__((aligned(SMP_CACHE_BYTES))); | 78 | } __attribute__((aligned(SMP_CACHE_BYTES))); |
73 | 79 | ||
74 | extern struct cpuinfo_mips cpu_data[]; | 80 | extern struct cpuinfo_mips cpu_data[]; |
diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h index a1e4453469f9..18ee58e39445 100644 --- a/arch/mips/include/asm/processor.h +++ b/arch/mips/include/asm/processor.h | |||
@@ -105,6 +105,19 @@ struct mips_dsp_state { | |||
105 | {0,} \ | 105 | {0,} \ |
106 | } | 106 | } |
107 | 107 | ||
108 | struct mips3264_watch_reg_state { | ||
109 | /* The width of watchlo is 32 in a 32 bit kernel and 64 in a | ||
110 | 64 bit kernel. We use unsigned long as it has the same | ||
111 | property. */ | ||
112 | unsigned long watchlo[NUM_WATCH_REGS]; | ||
113 | /* Only the mask and IRW bits from watchhi. */ | ||
114 | u16 watchhi[NUM_WATCH_REGS]; | ||
115 | }; | ||
116 | |||
117 | union mips_watch_reg_state { | ||
118 | struct mips3264_watch_reg_state mips3264; | ||
119 | }; | ||
120 | |||
108 | typedef struct { | 121 | typedef struct { |
109 | unsigned long seg; | 122 | unsigned long seg; |
110 | } mm_segment_t; | 123 | } mm_segment_t; |
@@ -137,6 +150,9 @@ struct thread_struct { | |||
137 | /* Saved state of the DSP ASE, if available. */ | 150 | /* Saved state of the DSP ASE, if available. */ |
138 | struct mips_dsp_state dsp; | 151 | struct mips_dsp_state dsp; |
139 | 152 | ||
153 | /* Saved watch register state, if available. */ | ||
154 | union mips_watch_reg_state watch; | ||
155 | |||
140 | /* Other stuff associated with the thread. */ | 156 | /* Other stuff associated with the thread. */ |
141 | unsigned long cp0_badvaddr; /* Last user fault */ | 157 | unsigned long cp0_badvaddr; /* Last user fault */ |
142 | unsigned long cp0_baduaddr; /* Last kernel fault accessing USEG */ | 158 | unsigned long cp0_baduaddr; /* Last kernel fault accessing USEG */ |
@@ -193,6 +209,10 @@ struct thread_struct { | |||
193 | .dspcontrol = 0, \ | 209 | .dspcontrol = 0, \ |
194 | }, \ | 210 | }, \ |
195 | /* \ | 211 | /* \ |
212 | * saved watch register stuff \ | ||
213 | */ \ | ||
214 | .watch = {{{0,},},}, \ | ||
215 | /* \ | ||
196 | * Other stuff associated with the process \ | 216 | * Other stuff associated with the process \ |
197 | */ \ | 217 | */ \ |
198 | .cp0_badvaddr = 0, \ | 218 | .cp0_badvaddr = 0, \ |
diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h index bb3060699df2..3f76de73c943 100644 --- a/arch/mips/include/asm/thread_info.h +++ b/arch/mips/include/asm/thread_info.h | |||
@@ -124,6 +124,7 @@ register struct thread_info *__current_thread_info __asm__("$28"); | |||
124 | #define TIF_32BIT_REGS 22 /* also implies 16/32 fprs */ | 124 | #define TIF_32BIT_REGS 22 /* also implies 16/32 fprs */ |
125 | #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */ | 125 | #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */ |
126 | #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */ | 126 | #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */ |
127 | #define TIF_LOAD_WATCH 25 /* If set, load watch registers */ | ||
127 | #define TIF_SYSCALL_TRACE 31 /* syscall trace active */ | 128 | #define TIF_SYSCALL_TRACE 31 /* syscall trace active */ |
128 | 129 | ||
129 | #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) | 130 | #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) |
@@ -140,6 +141,7 @@ register struct thread_info *__current_thread_info __asm__("$28"); | |||
140 | #define _TIF_32BIT_REGS (1<<TIF_32BIT_REGS) | 141 | #define _TIF_32BIT_REGS (1<<TIF_32BIT_REGS) |
141 | #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR) | 142 | #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR) |
142 | #define _TIF_FPUBOUND (1<<TIF_FPUBOUND) | 143 | #define _TIF_FPUBOUND (1<<TIF_FPUBOUND) |
144 | #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH) | ||
143 | 145 | ||
144 | /* work to do on interrupt/exception return */ | 146 | /* work to do on interrupt/exception return */ |
145 | #define _TIF_WORK_MASK (0x0000ffef & ~_TIF_SECCOMP) | 147 | #define _TIF_WORK_MASK (0x0000ffef & ~_TIF_SECCOMP) |
diff --git a/arch/mips/include/asm/watch.h b/arch/mips/include/asm/watch.h new file mode 100644 index 000000000000..20126ec79359 --- /dev/null +++ b/arch/mips/include/asm/watch.h | |||
@@ -0,0 +1,32 @@ | |||
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) 2008 David Daney | ||
7 | */ | ||
8 | #ifndef _ASM_WATCH_H | ||
9 | #define _ASM_WATCH_H | ||
10 | |||
11 | #include <linux/bitops.h> | ||
12 | |||
13 | #include <asm/mipsregs.h> | ||
14 | |||
15 | void mips_install_watch_registers(void); | ||
16 | void mips_read_watch_registers(void); | ||
17 | void mips_clear_watch_registers(void); | ||
18 | void mips_probe_watch_registers(struct cpuinfo_mips *c); | ||
19 | |||
20 | #ifdef CONFIG_HARDWARE_WATCHPOINTS | ||
21 | #define __restore_watch() do { \ | ||
22 | if (unlikely(test_bit(TIF_LOAD_WATCH, \ | ||
23 | ¤t_thread_info()->flags))) { \ | ||
24 | mips_install_watch_registers(); \ | ||
25 | } \ | ||
26 | } while (0) | ||
27 | |||
28 | #else | ||
29 | #define __restore_watch() do {} while (0) | ||
30 | #endif | ||
31 | |||
32 | #endif /* _ASM_WATCH_H */ | ||