op_x86_model.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. */
  10. #ifndef OP_X86_MODEL_H
  11. #define OP_X86_MODEL_H
  12. #include <asm/intel_arch_perfmon.h>
  13. #define CTR_IS_RESERVED(msrs, c) ((msrs)->counters[(c)].addr ? 1 : 0)
  14. #define CTRL_IS_RESERVED(msrs, c) ((msrs)->controls[(c)].addr ? 1 : 0)
  15. #define CTRL_SET_ACTIVE(val) ((val) |= ARCH_PERFMON_EVENTSEL0_ENABLE)
  16. #define CTRL_SET_ENABLE(val) ((val) |= ARCH_PERFMON_EVENTSEL_INT)
  17. #define CTRL_SET_INACTIVE(val) ((val) &= ~ARCH_PERFMON_EVENTSEL0_ENABLE)
  18. #define CTRL_SET_KERN(val, k) ((val) |= ((k) ? ARCH_PERFMON_EVENTSEL_OS : 0))
  19. #define CTRL_SET_USR(val, u) ((val) |= ((u) ? ARCH_PERFMON_EVENTSEL_USR : 0))
  20. #define CTRL_SET_UM(val, m) ((val) |= ((m) << 8))
  21. struct op_saved_msr {
  22. unsigned int high;
  23. unsigned int low;
  24. };
  25. struct op_msr {
  26. unsigned long addr;
  27. struct op_saved_msr saved;
  28. };
  29. struct op_msrs {
  30. struct op_msr *counters;
  31. struct op_msr *controls;
  32. };
  33. struct pt_regs;
  34. /* The model vtable abstracts the differences between
  35. * various x86 CPU models' perfctr support.
  36. */
  37. struct op_x86_model_spec {
  38. unsigned int num_counters;
  39. unsigned int num_controls;
  40. int (*init)(struct oprofile_operations *ops);
  41. void (*exit)(void);
  42. void (*fill_in_addresses)(struct op_msrs * const msrs);
  43. void (*setup_ctrs)(struct op_x86_model_spec const *model,
  44. struct op_msrs const * const msrs);
  45. int (*check_ctrs)(struct pt_regs * const regs,
  46. struct op_msrs const * const msrs);
  47. void (*start)(struct op_msrs const * const msrs);
  48. void (*stop)(struct op_msrs const * const msrs);
  49. void (*shutdown)(struct op_msrs const * const msrs);
  50. };
  51. extern struct op_x86_model_spec const op_ppro_spec;
  52. extern struct op_x86_model_spec const op_p4_spec;
  53. extern struct op_x86_model_spec const op_p4_ht2_spec;
  54. extern struct op_x86_model_spec const op_amd_spec;
  55. extern struct op_x86_model_spec op_arch_perfmon_spec;
  56. #endif /* OP_X86_MODEL_H */