oprofile_impl.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. #endif
  32. unsigned long enable_kernel;
  33. unsigned long enable_user;
  34. };
  35. /* Per-arch configuration */
  36. struct op_powerpc_model {
  37. void (*reg_setup) (struct op_counter_config *,
  38. struct op_system_config *,
  39. int num_counters);
  40. void (*cpu_setup) (void *);
  41. void (*start) (struct op_counter_config *);
  42. void (*stop) (void);
  43. void (*handle_interrupt) (struct pt_regs *,
  44. struct op_counter_config *);
  45. int num_counters;
  46. };
  47. extern struct op_powerpc_model op_model_fsl_booke;
  48. extern struct op_powerpc_model op_model_rs64;
  49. extern struct op_powerpc_model op_model_power4;
  50. extern struct op_powerpc_model op_model_7450;
  51. #ifndef CONFIG_FSL_BOOKE
  52. /* All the classic PPC parts use these */
  53. static inline unsigned int ctr_read(unsigned int i)
  54. {
  55. switch(i) {
  56. case 0:
  57. return mfspr(SPRN_PMC1);
  58. case 1:
  59. return mfspr(SPRN_PMC2);
  60. case 2:
  61. return mfspr(SPRN_PMC3);
  62. case 3:
  63. return mfspr(SPRN_PMC4);
  64. case 4:
  65. return mfspr(SPRN_PMC5);
  66. case 5:
  67. return mfspr(SPRN_PMC6);
  68. /* No PPC32 chip has more than 6 so far */
  69. #ifdef CONFIG_PPC64
  70. case 6:
  71. return mfspr(SPRN_PMC7);
  72. case 7:
  73. return mfspr(SPRN_PMC8);
  74. #endif
  75. default:
  76. return 0;
  77. }
  78. }
  79. static inline void ctr_write(unsigned int i, unsigned int val)
  80. {
  81. switch(i) {
  82. case 0:
  83. mtspr(SPRN_PMC1, val);
  84. break;
  85. case 1:
  86. mtspr(SPRN_PMC2, val);
  87. break;
  88. case 2:
  89. mtspr(SPRN_PMC3, val);
  90. break;
  91. case 3:
  92. mtspr(SPRN_PMC4, val);
  93. break;
  94. case 4:
  95. mtspr(SPRN_PMC5, val);
  96. break;
  97. case 5:
  98. mtspr(SPRN_PMC6, val);
  99. break;
  100. /* No PPC32 chip has more than 6, yet */
  101. #ifdef CONFIG_PPC64
  102. case 6:
  103. mtspr(SPRN_PMC7, val);
  104. break;
  105. case 7:
  106. mtspr(SPRN_PMC8, val);
  107. break;
  108. #endif
  109. default:
  110. break;
  111. }
  112. }
  113. #endif /* !CONFIG_FSL_BOOKE */
  114. extern void op_powerpc_backtrace(struct pt_regs * const regs, unsigned int depth);
  115. #endif /* __KERNEL__ */
  116. #endif /* _ASM_POWERPC_OPROFILE_IMPL_H */