/* ioctl routine All routines effect the processor that they are executed on. Thus you must be running on the processor that you wish to change.  */
static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
/* ioctl routine All routines effect the processor that they are executed on. Thus you must be running on the processor that you wish to change.  */
static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	long error_start;
	uint32_t raddr[4];
	int error = 0;
	switch (cmd) {
	    case PA_PERF_ON:
			perf_start_counters();
			break;
	    case PA_PERF_OFF:
			error_start = perf_stop_counters(raddr);
			if (error_start != 0) {
				printk(KERN_ERR "perf_off: perf_stop_counters = %ld\n", error_start);
				error = -EFAULT;
				break;
			}
			if (copy_to_user((void __user *)arg, raddr, 
					sizeof (raddr)) != 0) {
				error =  -EFAULT;
				break;
			}
			break;
	    case PA_PERF_VERSION:
			error = put_user(PERF_VERSION, (int *)arg);
			break;
	    default:
  	 		error = -ENOTTY;
	}
	return error;
}