oprofile_impl.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. #define OP_MAX_COUNTER 8
  14. /* Per-counter configuration as set via oprofilefs. */
  15. struct op_counter_config {
  16. #ifdef __powerpc64__
  17. unsigned long valid;
  18. #endif
  19. unsigned long enabled;
  20. unsigned long event;
  21. unsigned long count;
  22. /* Classic doesn't support per-counter user/kernel selection */
  23. unsigned long kernel;
  24. unsigned long user;
  25. unsigned long unit_mask;
  26. };
  27. /* System-wide configuration as set via oprofilefs. */
  28. struct op_system_config {
  29. #ifdef CONFIG_PPC64
  30. unsigned long mmcr0;
  31. unsigned long mmcr1;
  32. unsigned long mmcra;
  33. #endif
  34. unsigned long enable_kernel;
  35. unsigned long enable_user;
  36. #ifdef CONFIG_PPC64
  37. unsigned long backtrace_spinlocks;
  38. #endif
  39. };
  40. /* Per-arch configuration */
  41. struct op_powerpc_model {
  42. void (*reg_setup) (struct op_counter_config *,
  43. struct op_system_config *,
  44. int num_counters);
  45. void (*cpu_setup) (void *);
  46. void (*start) (struct op_counter_config *);
  47. void (*stop) (void);
  48. void (*handle_interrupt) (struct pt_regs *,
  49. struct op_counter_config *);
  50. int num_counters;
  51. };
  52. #ifdef CONFIG_FSL_BOOKE
  53. extern struct op_powerpc_model op_model_fsl_booke;
  54. #else /* Otherwise, it's classic */
  55. #ifdef CONFIG_PPC64
  56. extern struct op_powerpc_model op_model_rs64;
  57. extern struct op_powerpc_model op_model_power4;
  58. #else /* Otherwise, CONFIG_PPC32 */
  59. extern struct op_powerpc_model op_model_7450;
  60. #endif
  61. /* All the classic PPC parts use these */
  62. static inline unsigned int ctr_read(unsigned int i)
  63. {
  64. switch(i) {
  65. case 0:
  66. return mfspr(SPRN_PMC1);
  67. case 1:
  68. return mfspr(SPRN_PMC2);
  69. case 2:
  70. return mfspr(SPRN_PMC3);
  71. case 3:
  72. return mfspr(SPRN_PMC4);
  73. case 4:
  74. return mfspr(SPRN_PMC5);
  75. case 5:
  76. return mfspr(SPRN_PMC6);
  77. /* No PPC32 chip has more than 6 so far */
  78. #ifdef CONFIG_PPC64
  79. case 6:
  80. return mfspr(SPRN_PMC7);
  81. case 7:
  82. return mfspr(SPRN_PMC8);
  83. #endif
  84. default:
  85. return 0;
  86. }
  87. }
  88. static inline void ctr_write(unsigned int i, unsigned int val)
  89. {
  90. switch(i) {
  91. case 0:
  92. mtspr(SPRN_PMC1, val);
  93. break;
  94. case 1:
  95. mtspr(SPRN_PMC2, val);
  96. break;
  97. case 2:
  98. mtspr(SPRN_PMC3, val);
  99. break;
  100. case 3:
  101. mtspr(SPRN_PMC4, val);
  102. break;
  103. case 4:
  104. mtspr(SPRN_PMC5, val);
  105. break;
  106. case 5:
  107. mtspr(SPRN_PMC6, val);
  108. break;
  109. /* No PPC32 chip has more than 6, yet */
  110. #ifdef CONFIG_PPC64
  111. case 6:
  112. mtspr(SPRN_PMC7, val);
  113. break;
  114. case 7:
  115. mtspr(SPRN_PMC8, val);
  116. break;
  117. #endif
  118. default:
  119. break;
  120. }
  121. }
  122. #endif /* !CONFIG_FSL_BOOKE */
  123. #endif /* _ASM_POWERPC_OPROFILE_IMPL_H */