oprofile_impl.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. #ifdef __powerpc64__
  18. unsigned long valid;
  19. #endif
  20. unsigned long enabled;
  21. unsigned long event;
  22. unsigned long count;
  23. /* Classic doesn't support per-counter user/kernel selection */
  24. unsigned long kernel;
  25. unsigned long user;
  26. unsigned long unit_mask;
  27. };
  28. /* System-wide configuration as set via oprofilefs. */
  29. struct op_system_config {
  30. #ifdef CONFIG_PPC64
  31. unsigned long mmcr0;
  32. unsigned long mmcr1;
  33. unsigned long mmcra;
  34. #endif
  35. unsigned long enable_kernel;
  36. unsigned long enable_user;
  37. #ifdef CONFIG_PPC64
  38. unsigned long backtrace_spinlocks;
  39. #endif
  40. };
  41. /* Per-arch configuration */
  42. struct op_powerpc_model {
  43. void (*reg_setup) (struct op_counter_config *,
  44. struct op_system_config *,
  45. int num_counters);
  46. void (*cpu_setup) (void *);
  47. void (*start) (struct op_counter_config *);
  48. void (*stop) (void);
  49. void (*handle_interrupt) (struct pt_regs *,
  50. struct op_counter_config *);
  51. int num_counters;
  52. };
  53. #ifdef CONFIG_FSL_BOOKE
  54. extern struct op_powerpc_model op_model_fsl_booke;
  55. #else /* Otherwise, it's classic */
  56. #ifdef CONFIG_PPC64
  57. extern struct op_powerpc_model op_model_rs64;
  58. extern struct op_powerpc_model op_model_power4;
  59. #else /* Otherwise, CONFIG_PPC32 */
  60. extern struct op_powerpc_model op_model_7450;
  61. #endif
  62. /* All the classic PPC parts use these */
  63. static inline unsigned int 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 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. #endif /* !CONFIG_FSL_BOOKE */
  124. #endif /* __KERNEL__ */
  125. #endif /* _ASM_POWERPC_OPROFILE_IMPL_H */