per.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Copyright (c) 2010, The Linux Foundation. All rights reserved.
  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. per.c
  14. DESCRIPTION: Performance count interface for linux via proc in the T32
  15. command file style
  16. */
  17. #include <linux/module.h>
  18. #include <linux/init.h>
  19. #include <linux/sched.h>
  20. #include <linux/sysrq.h>
  21. #include <linux/time.h>
  22. #include "linux/proc_fs.h"
  23. #include "linux/kernel_stat.h"
  24. #include "asm/uaccess.h"
  25. #include "cp15_registers.h"
  26. #include "perf.h"
  27. #define PM_PER_ERR -1
  28. /*
  29. FUNCTION perf_if_proc_init
  30. DESCRIPTION Initialize the proc interface for thje performance data.
  31. */
  32. static __init int per_init(void)
  33. {
  34. if (atomic_read(&pm_op_lock) == 1) {
  35. printk(KERN_INFO "Can not load KSAPI, monitors are in use\n");
  36. return PM_PER_ERR;
  37. }
  38. atomic_set(&pm_op_lock, 1);
  39. per_process_perf_init();
  40. printk(KERN_INFO "ksapi init\n");
  41. return 0;
  42. }
  43. static void __exit per_exit(void)
  44. {
  45. per_process_perf_exit();
  46. printk(KERN_INFO "ksapi exit\n");
  47. atomic_set(&pm_op_lock, 0);
  48. }
  49. MODULE_LICENSE("GPL v2");
  50. module_init(per_init);
  51. module_exit(per_exit);