op_x86_model.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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/intel_arch_perfmon.h>
  15. #define CTR_IS_RESERVED(msrs, c) ((msrs)->counters[(c)].addr ? 1 : 0)
  16. #define CTRL_IS_RESERVED(msrs, c) ((msrs)->controls[(c)].addr ? 1 : 0)
  17. struct op_saved_msr {
  18. unsigned int high;
  19. unsigned int low;
  20. };
  21. struct op_msr {
  22. unsigned long addr;
  23. struct op_saved_msr saved;
  24. };
  25. struct op_msrs {
  26. struct op_msr *counters;
  27. struct op_msr *controls;
  28. };
  29. struct pt_regs;
  30. struct oprofile_operations;
  31. /* The model vtable abstracts the differences between
  32. * various x86 CPU models' perfctr support.
  33. */
  34. struct op_x86_model_spec {
  35. unsigned int num_counters;
  36. unsigned int num_controls;
  37. u64 reserved;
  38. u16 event_mask;
  39. int (*init)(struct oprofile_operations *ops);
  40. void (*exit)(void);
  41. void (*fill_in_addresses)(struct op_msrs * const msrs);
  42. void (*setup_ctrs)(struct op_x86_model_spec const *model,
  43. struct op_msrs const * const msrs);
  44. int (*check_ctrs)(struct pt_regs * const regs,
  45. struct op_msrs const * const msrs);
  46. void (*start)(struct op_msrs const * const msrs);
  47. void (*stop)(struct op_msrs const * const msrs);
  48. void (*shutdown)(struct op_msrs const * const msrs);
  49. };
  50. struct op_counter_config;
  51. extern u64 op_x86_get_ctrl(struct op_x86_model_spec const *model,
  52. struct op_counter_config *counter_config);
  53. extern struct op_x86_model_spec const op_ppro_spec;
  54. extern struct op_x86_model_spec const op_p4_spec;
  55. extern struct op_x86_model_spec const op_p4_ht2_spec;
  56. extern struct op_x86_model_spec const op_amd_spec;
  57. extern struct op_x86_model_spec op_arch_perfmon_spec;
  58. #endif /* OP_X86_MODEL_H */