op_x86_model.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /**
  2. * @file op_x86_model.h
  3. * interface to x86 model-specific MSR operations
  4. *
  5. * @remark Copyright 2002 OProfile authors
  6. * @remark Read the file COPYING
  7. *
  8. * @author Graydon Hoare
  9. * @author Robert Richter <robert.richter@amd.com>
  10. */
  11. #ifndef OP_X86_MODEL_H
  12. #define OP_X86_MODEL_H
  13. #include <asm/types.h>
  14. #include <asm/perf_event.h>
  15. struct op_msr {
  16. unsigned long addr;
  17. u64 saved;
  18. };
  19. struct op_msrs {
  20. struct op_msr *counters;
  21. struct op_msr *controls;
  22. struct op_msr *multiplex;
  23. };
  24. struct pt_regs;
  25. struct oprofile_operations;
  26. /* The model vtable abstracts the differences between
  27. * various x86 CPU models' perfctr support.
  28. */
  29. struct op_x86_model_spec {
  30. unsigned int num_counters;
  31. unsigned int num_controls;
  32. unsigned int num_virt_counters;
  33. u64 reserved;
  34. u16 event_mask;
  35. int (*init)(struct oprofile_operations *ops);
  36. int (*fill_in_addresses)(struct op_msrs * const msrs);
  37. void (*setup_ctrs)(struct op_x86_model_spec const *model,
  38. struct op_msrs const * const msrs);
  39. int (*check_ctrs)(struct pt_regs * const regs,
  40. struct op_msrs const * const msrs);
  41. void (*start)(struct op_msrs const * const msrs);
  42. void (*stop)(struct op_msrs const * const msrs);
  43. void (*shutdown)(struct op_msrs const * const msrs);
  44. #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
  45. void (*switch_ctrl)(struct op_x86_model_spec const *model,
  46. struct op_msrs const * const msrs);
  47. #endif
  48. };
  49. struct op_counter_config;
  50. static inline void op_x86_warn_in_use(int counter)
  51. {
  52. /*
  53. * The warning indicates an already running counter. If
  54. * oprofile doesn't collect data, then try using a different
  55. * performance counter on your platform to monitor the desired
  56. * event. Delete counter #%d from the desired event by editing
  57. * the /usr/share/oprofile/%s/<cpu>/events file. If the event
  58. * cannot be monitored by any other counter, contact your
  59. * hardware or BIOS vendor.
  60. */
  61. pr_warning("oprofile: counter #%d on cpu #%d may already be used\n",
  62. counter, smp_processor_id());
  63. }
  64. static inline void op_x86_warn_reserved(int counter)
  65. {
  66. pr_warning("oprofile: counter #%d is already reserved\n", counter);
  67. }
  68. extern u64 op_x86_get_ctrl(struct op_x86_model_spec const *model,
  69. struct op_counter_config *counter_config);
  70. extern int op_x86_phys_to_virt(int phys);
  71. extern int op_x86_virt_to_phys(int virt);
  72. extern struct op_x86_model_spec op_ppro_spec;
  73. extern struct op_x86_model_spec op_p4_spec;
  74. extern struct op_x86_model_spec op_p4_ht2_spec;
  75. extern struct op_x86_model_spec op_amd_spec;
  76. extern struct op_x86_model_spec op_arch_perfmon_spec;
  77. #endif /* OP_X86_MODEL_H */