oprofile_impl.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM
  3. *
  4. * Based on alpha version.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #ifndef _ASM_POWERPC_OPROFILE_IMPL_H
  12. #define _ASM_POWERPC_OPROFILE_IMPL_H
  13. #ifdef __KERNEL__
  14. #define OP_MAX_COUNTER 8
  15. /* Per-counter configuration as set via oprofilefs. */
  16. struct op_counter_config {
  17. unsigned long enabled;
  18. unsigned long event;
  19. unsigned long count;
  20. /* Classic doesn't support per-counter user/kernel selection */
  21. unsigned long kernel;
  22. unsigned long user;
  23. unsigned long unit_mask;
  24. };
  25. /* System-wide configuration as set via oprofilefs. */
  26. struct op_system_config {
  27. #ifdef CONFIG_PPC64
  28. unsigned long mmcr0;
  29. unsigned long mmcr1;
  30. unsigned long mmcra;
  31. #ifdef CONFIG_OPROFILE_CELL
  32. /* Register for oprofile user tool to check cell kernel profiling
  33. * support.
  34. */
  35. unsigned long cell_support;
  36. #endif
  37. #endif
  38. unsigned long enable_kernel;
  39. unsigned long enable_user;
  40. };
  41. /* Per-arch configuration */
  42. struct op_powerpc_model {
  43. int (*reg_setup) (struct op_counter_config *,
  44. struct op_system_config *,
  45. int num_counters);
  46. int (*cpu_setup) (struct op_counter_config *);
  47. int (*start) (struct op_counter_config *);
  48. int (*global_start) (struct op_counter_config *);
  49. void (*stop) (void);
  50. void (*global_stop) (void);
  51. int (*sync_start)(void);
  52. int (*sync_stop)(void);
  53. void (*handle_interrupt) (struct pt_regs *,
  54. struct op_counter_config *);
  55. int num_counters;
  56. };
  57. extern struct op_powerpc_model op_model_fsl_emb;
  58. extern struct op_powerpc_model op_model_power4;
  59. extern struct op_powerpc_model op_model_7450;
  60. extern struct op_powerpc_model op_model_cell;
  61. extern struct op_powerpc_model op_model_pa6t;
  62. /* All the classic PPC parts use these */
  63. static inline unsigned int classic_ctr_read(unsigned int i)
  64. {
  65. switch(i) {
  66. case 0:
  67. return mfspr(SPRN_PMC1);
  68. case 1:
  69. return mfspr(SPRN_PMC2);
  70. case 2:
  71. return mfspr(SPRN_PMC3);
  72. case 3:
  73. return mfspr(SPRN_PMC4);
  74. case 4:
  75. return mfspr(SPRN_PMC5);
  76. case 5:
  77. return mfspr(SPRN_PMC6);
  78. /* No PPC32 chip has more than 6 so far */
  79. #ifdef CONFIG_PPC64
  80. case 6:
  81. return mfspr(SPRN_PMC7);
  82. case 7:
  83. return mfspr(SPRN_PMC8);
  84. #endif
  85. default:
  86. return 0;
  87. }
  88. }
  89. static inline void classic_ctr_write(unsigned int i, unsigned int val)
  90. {
  91. switch(i) {
  92. case 0:
  93. mtspr(SPRN_PMC1, val);
  94. break;
  95. case 1:
  96. mtspr(SPRN_PMC2, val);
  97. break;
  98. case 2:
  99. mtspr(SPRN_PMC3, val);
  100. break;
  101. case 3:
  102. mtspr(SPRN_PMC4, val);
  103. break;
  104. case 4:
  105. mtspr(SPRN_PMC5, val);
  106. break;
  107. case 5:
  108. mtspr(SPRN_PMC6, val);
  109. break;
  110. /* No PPC32 chip has more than 6, yet */
  111. #ifdef CONFIG_PPC64
  112. case 6:
  113. mtspr(SPRN_PMC7, val);
  114. break;
  115. case 7:
  116. mtspr(SPRN_PMC8, val);
  117. break;
  118. #endif
  119. default:
  120. break;
  121. }
  122. }
  123. extern void op_powerpc_backtrace(struct pt_regs * const regs, unsigned int depth);
  124. #endif /* __KERNEL__ */
  125. #endif /* _ASM_POWERPC_OPROFILE_IMPL_H */