oprofile_impl.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. unsigned long kernel;
  23. #ifdef __powerpc64__
  24. /* We dont support per counter user/kernel selection */
  25. #endif
  26. unsigned long user;
  27. unsigned long unit_mask;
  28. };
  29. /* System-wide configuration as set via oprofilefs. */
  30. struct op_system_config {
  31. #ifdef __powerpc64__
  32. unsigned long mmcr0;
  33. unsigned long mmcr1;
  34. unsigned long mmcra;
  35. #endif
  36. unsigned long enable_kernel;
  37. unsigned long enable_user;
  38. #ifdef __powerpc64__
  39. unsigned long backtrace_spinlocks;
  40. #endif
  41. };
  42. /* Per-arch configuration */
  43. struct op_powerpc_model {
  44. void (*reg_setup) (struct op_counter_config *,
  45. struct op_system_config *,
  46. int num_counters);
  47. #ifdef __powerpc64__
  48. void (*cpu_setup) (void *);
  49. #endif
  50. void (*start) (struct op_counter_config *);
  51. void (*stop) (void);
  52. void (*handle_interrupt) (struct pt_regs *,
  53. struct op_counter_config *);
  54. int num_counters;
  55. };
  56. #ifdef __powerpc64__
  57. extern struct op_powerpc_model op_model_rs64;
  58. extern struct op_powerpc_model op_model_power4;
  59. static inline unsigned int ctr_read(unsigned int i)
  60. {
  61. switch(i) {
  62. case 0:
  63. return mfspr(SPRN_PMC1);
  64. case 1:
  65. return mfspr(SPRN_PMC2);
  66. case 2:
  67. return mfspr(SPRN_PMC3);
  68. case 3:
  69. return mfspr(SPRN_PMC4);
  70. case 4:
  71. return mfspr(SPRN_PMC5);
  72. case 5:
  73. return mfspr(SPRN_PMC6);
  74. case 6:
  75. return mfspr(SPRN_PMC7);
  76. case 7:
  77. return mfspr(SPRN_PMC8);
  78. default:
  79. return 0;
  80. }
  81. }
  82. static inline void ctr_write(unsigned int i, unsigned int val)
  83. {
  84. switch(i) {
  85. case 0:
  86. mtspr(SPRN_PMC1, val);
  87. break;
  88. case 1:
  89. mtspr(SPRN_PMC2, val);
  90. break;
  91. case 2:
  92. mtspr(SPRN_PMC3, val);
  93. break;
  94. case 3:
  95. mtspr(SPRN_PMC4, val);
  96. break;
  97. case 4:
  98. mtspr(SPRN_PMC5, val);
  99. break;
  100. case 5:
  101. mtspr(SPRN_PMC6, val);
  102. break;
  103. case 6:
  104. mtspr(SPRN_PMC7, val);
  105. break;
  106. case 7:
  107. mtspr(SPRN_PMC8, val);
  108. break;
  109. default:
  110. break;
  111. }
  112. }
  113. #endif /* __powerpc64__ */
  114. #endif /* _ASM_POWERPC_OPROFILE_IMPL_H */