Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame^] | 1 | /* Copyright (c) 2010, Code Aurora Forum. 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 | /* |
| 14 | * perf-function-hooks.c |
| 15 | * DESCRIPTION |
| 16 | * Hooks for ksapi.ko |
| 17 | */ |
| 18 | |
| 19 | #include <linux/module.h> |
| 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 <linux/proc_fs.h> |
| 29 | #include "cp15_registers.h" |
| 30 | #include <asm/perftypes.h> |
| 31 | #include "perf.h" |
| 32 | |
| 33 | /* |
| 34 | * Function Pointers for when the module is installed... |
| 35 | * Should we use a single "ready" variable for the testing |
| 36 | * in the functions below, will be safer when module is removed |
| 37 | * testing for a locked variable... |
| 38 | */ |
| 39 | VPVF pp_interrupt_out_ptr; |
| 40 | VPVF pp_interrupt_in_ptr; |
| 41 | VPULF pp_process_remove_ptr; |
| 42 | unsigned int pp_loaded; |
| 43 | EXPORT_SYMBOL(pp_loaded); |
| 44 | atomic_t pm_op_lock; |
| 45 | EXPORT_SYMBOL(pm_op_lock); |
| 46 | |
| 47 | /* |
| 48 | FUNCTION VARIOUS |
| 49 | |
| 50 | DESCRIPTION |
| 51 | Hooks to callinto the module functions after they are loaded. The |
| 52 | above pointers will be set and then these functions are ready to be |
| 53 | called. |
| 54 | |
| 55 | DEPENDENCIES |
| 56 | THe per preocess performance monitor needs to be loaded ... |
| 57 | |
| 58 | RETURN VALUE |
| 59 | |
| 60 | SIDE EFFECTS |
| 61 | */ |
| 62 | void perf_mon_interrupt_out(void) |
| 63 | { |
| 64 | if (pp_loaded) |
| 65 | (*pp_interrupt_out_ptr)(); |
| 66 | } |
| 67 | EXPORT_SYMBOL(pp_interrupt_out_ptr); |
| 68 | |
| 69 | void perf_mon_interrupt_in(void) |
| 70 | { |
| 71 | if (pp_loaded) |
| 72 | (*pp_interrupt_in_ptr)(); |
| 73 | } |
| 74 | EXPORT_SYMBOL(pp_interrupt_in_ptr); |
| 75 | |
| 76 | void per_process_remove(unsigned long pid) |
| 77 | { |
| 78 | if (pp_loaded) |
| 79 | (*pp_process_remove_ptr)(pid); |
| 80 | } |
| 81 | EXPORT_SYMBOL(pp_process_remove_ptr); |