/* Configure the cpu with a given data image. First turn off the counters, then download the image, then turn the counters back on.  */
static int perf_config(uint32_t *image_ptr)
/* Configure the cpu with a given data image. First turn off the counters, then download the image, then turn the counters back on.  */
static int perf_config(uint32_t *image_ptr)
{
	long error;
	uint32_t raddr[4];
	error = perf_stop_counters(raddr);
	if (error != 0) {
		printk("perf_config: perf_stop_counters = %ld\n", error);
		return -EINVAL; 
	}
printk("Preparing to write image\n");
	error = perf_write_image((uint64_t *)image_ptr);
	if (error != 0) {
		printk("perf_config: DOWNLOAD = %ld\n", error);
		return -EINVAL; 
	}
printk("Preparing to start counters\n");
	perf_start_counters();
	return sizeof(uint32_t);
}