Duy Truong | 790f06d | 2013-02-13 16:38:12 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2010, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | /* |
| 14 | per.c |
| 15 | |
| 16 | DESCRIPTION: Performance count interface for linux via proc in the T32 |
| 17 | command file style |
| 18 | */ |
| 19 | |
| 20 | #include <linux/module.h> |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/sched.h> |
| 23 | #include <linux/sysrq.h> |
| 24 | #include <linux/time.h> |
| 25 | #include "linux/proc_fs.h" |
| 26 | #include "linux/kernel_stat.h" |
| 27 | #include "asm/uaccess.h" |
| 28 | #include "cp15_registers.h" |
| 29 | #include "perf.h" |
| 30 | |
| 31 | #define PM_PER_ERR -1 |
| 32 | /* |
| 33 | FUNCTION perf_if_proc_init |
| 34 | |
| 35 | DESCRIPTION Initialize the proc interface for thje performance data. |
| 36 | */ |
| 37 | static __init int per_init(void) |
| 38 | { |
| 39 | |
| 40 | if (atomic_read(&pm_op_lock) == 1) { |
| 41 | printk(KERN_INFO "Can not load KSAPI, monitors are in use\n"); |
| 42 | return PM_PER_ERR; |
| 43 | } |
| 44 | atomic_set(&pm_op_lock, 1); |
| 45 | per_process_perf_init(); |
| 46 | printk(KERN_INFO "ksapi init\n"); |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | static void __exit per_exit(void) |
| 51 | { |
| 52 | per_process_perf_exit(); |
| 53 | printk(KERN_INFO "ksapi exit\n"); |
| 54 | atomic_set(&pm_op_lock, 0); |
| 55 | } |
| 56 | |
| 57 | MODULE_LICENSE("GPL v2"); |
| 58 | module_init(per_init); |
| 59 | module_exit(per_exit); |