static int proc_write_perf(struct file *file, const char *buffer, unsigned long count, void *data) { int len; int nparsed; int index; char mybuf[TXTBUFSZ]; int which[4]; unsigned long control[4]; long long ctrdata[4]; if(count >= TXTBUFSZ) len = TXTBUFSZ-1; else len = count; memset(mybuf,0,TXTBUFSZ); if(copy_from_user(mybuf, buffer, len)) return -EFAULT; nparsed = sscanf(mybuf, "%d %lx %Ld %d %lx %Ld %d %lx %Ld %d %lx %Ld", &which[0], &control[0], &ctrdata[0], &which[1], &control[1], &ctrdata[1], &which[2], &control[2], &ctrdata[2], &which[3], &control[3], &ctrdata[3]); for(index = 0; nparsed >= 3; index++) { switch (which[index]) { case 0: write_c0_perfctrl0(control[index]); if(ctrdata[index] != -1) { extencount[0] = (unsigned long long)ctrdata[index]; write_c0_perfcntr0((unsigned long)0); } break; case 1: write_c0_perfctrl1(control[index]); if(ctrdata[index] != -1) { extencount[1] = (unsigned long long)ctrdata[index]; write_c0_perfcntr1((unsigned long)0); } break; case 2: write_c0_perfctrl2(control[index]); if(ctrdata[index] != -1) { extencount[2] = (unsigned long long)ctrdata[index]; write_c0_perfcntr2((unsigned long)0); } break; case 3: write_c0_perfctrl3(control[index]); if(ctrdata[index] != -1) { extencount[3] = (unsigned long long)ctrdata[index]; write_c0_perfcntr3((unsigned long)0); } break; } nparsed -= 3; } return (len); }
void start_cntrs(unsigned int event0, unsigned int event1) { write_c0_perfcntr0(0x00000000); write_c0_perfcntr1(0x00000000); /* * go... */ write_c0_perfctrl0(0x80000000 | M_PERFCTL_EVENT(event0) | 0xf); write_c0_perfctrl1(0x00000000 | M_PERFCTL_EVENT(event1) | 0xf); }
void stop_cntrs(void) { write_c0_perfctrl0(0); write_c0_perfctrl1(0); }