perf-function-hooks.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. * perf-function-hooks.c
  14. * DESCRIPTION
  15. * Hooks for ksapi.ko
  16. */
  17. #include <linux/module.h>
  18. #include <linux/module.h>
  19. #include <linux/init.h>
  20. #include <linux/sched.h>
  21. #include <linux/sysrq.h>
  22. #include <linux/time.h>
  23. #include "linux/proc_fs.h"
  24. #include "linux/kernel_stat.h"
  25. #include "asm/uaccess.h"
  26. #include <linux/proc_fs.h>
  27. #include "cp15_registers.h"
  28. #include <asm/perftypes.h>
  29. #include "perf.h"
  30. /*
  31. * Function Pointers for when the module is installed...
  32. * Should we use a single "ready" variable for the testing
  33. * in the functions below, will be safer when module is removed
  34. * testing for a locked variable...
  35. */
  36. VPVF pp_interrupt_out_ptr;
  37. VPVF pp_interrupt_in_ptr;
  38. VPULF pp_process_remove_ptr;
  39. unsigned int pp_loaded;
  40. EXPORT_SYMBOL(pp_loaded);
  41. atomic_t pm_op_lock;
  42. EXPORT_SYMBOL(pm_op_lock);
  43. /*
  44. FUNCTION VARIOUS
  45. DESCRIPTION
  46. Hooks to callinto the module functions after they are loaded. The
  47. above pointers will be set and then these functions are ready to be
  48. called.
  49. DEPENDENCIES
  50. THe per preocess performance monitor needs to be loaded ...
  51. RETURN VALUE
  52. SIDE EFFECTS
  53. */
  54. void perf_mon_interrupt_out(void)
  55. {
  56. if (pp_loaded)
  57. (*pp_interrupt_out_ptr)();
  58. }
  59. EXPORT_SYMBOL(pp_interrupt_out_ptr);
  60. void perf_mon_interrupt_in(void)
  61. {
  62. if (pp_loaded)
  63. (*pp_interrupt_in_ptr)();
  64. }
  65. EXPORT_SYMBOL(pp_interrupt_in_ptr);
  66. void per_process_remove(unsigned long pid)
  67. {
  68. if (pp_loaded)
  69. (*pp_process_remove_ptr)(pid);
  70. }
  71. EXPORT_SYMBOL(pp_process_remove_ptr);