13 #include <asm/ptrace.h>
14 #include <asm/processor.h>
15 #include <asm/cputable.h>
20 static void ctrl_write(
unsigned int i,
unsigned int val)
23 unsigned long shift = 0,
mask = 0;
25 dbg(
"ctrl_write %d %x\n", i, val);
29 tmp =
mfspr(SPRN_MMCR0);
34 tmp =
mfspr(SPRN_MMCR0);
39 tmp =
mfspr(SPRN_MMCR1);
44 tmp =
mfspr(SPRN_MMCR1);
49 tmp =
mfspr(SPRN_MMCR1);
54 tmp =
mfspr(SPRN_MMCR1);
59 tmp =
mfspr(SPRN_MMCR1);
64 tmp =
mfspr(SPRN_MMCR1);
70 tmp = tmp & ~(
mask << shift);
76 mtspr(SPRN_MMCR0, tmp);
79 mtspr(SPRN_MMCR1, tmp);
82 dbg(
"ctrl_write mmcr0 %lx mmcr1 %lx\n",
mfspr(SPRN_MMCR0),
88 static int num_counters;
96 num_counters = num_ctrs;
98 for (i = 0; i < num_counters; ++
i)
99 reset_value[i] = 0x80000000UL - ctr[i].
count;
111 mtspr(SPRN_MMCR0, mmcr0);
114 mtspr(SPRN_MMCR1, 0);
117 mtspr(SPRN_MMCRA, 0);
119 mmcr0 |= MMCR0_FCM1|MMCR0_PMXE|MMCR0_FCECE;
121 mmcr0 |= MMCR0_PMC1CE|MMCR0_PMCjCE;
122 mtspr(SPRN_MMCR0, mmcr0);
138 mtmsrd(mfmsr() | MSR_PMM);
140 for (i = 0; i < num_counters; ++
i) {
142 classic_ctr_write(i, reset_value[i]);
143 ctrl_write(i, ctr[i].
event);
145 classic_ctr_write(i, 0);
149 mmcr0 =
mfspr(SPRN_MMCR0);
157 mtspr(SPRN_MMCR0, mmcr0);
163 static void rs64_stop(
void)
168 mmcr0 =
mfspr(SPRN_MMCR0);
170 mtspr(SPRN_MMCR0, mmcr0);
177 static void rs64_handle_interrupt(
struct pt_regs *
regs,
184 unsigned long pc =
mfspr(SPRN_SIAR);
189 mtmsrd(mfmsr() | MSR_PMM);
191 for (i = 0; i < num_counters; ++
i) {
192 val = classic_ctr_read(i);
196 classic_ctr_write(i, reset_value[i]);
198 classic_ctr_write(i, 0);
203 mmcr0 =
mfspr(SPRN_MMCR0);
214 mtspr(SPRN_MMCR0, mmcr0);
218 .reg_setup = rs64_reg_setup,
219 .cpu_setup = rs64_cpu_setup,
222 .handle_interrupt = rs64_handle_interrupt,