oprofile.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /**
  2. * @file oprofile.h
  3. *
  4. * API for machine-specific interrupts to interface
  5. * to oprofile.
  6. *
  7. * @remark Copyright 2002 OProfile authors
  8. * @remark Read the file COPYING
  9. *
  10. * @author John Levon <levon@movementarian.org>
  11. */
  12. #ifndef OPROFILE_H
  13. #define OPROFILE_H
  14. /* Each escaped entry is prefixed by ESCAPE_CODE
  15. * then one of the following codes, then the
  16. * relevant data.
  17. * These #defines live in this file so that arch-specific
  18. * buffer sync'ing code can access them.
  19. */
  20. #define ESCAPE_CODE ~0UL
  21. #define CTX_SWITCH_CODE 1
  22. #define CPU_SWITCH_CODE 2
  23. #define COOKIE_SWITCH_CODE 3
  24. #define KERNEL_ENTER_SWITCH_CODE 4
  25. #define KERNEL_EXIT_SWITCH_CODE 5
  26. #define MODULE_LOADED_CODE 6
  27. #define CTX_TGID_CODE 7
  28. #define TRACE_BEGIN_CODE 8
  29. #define TRACE_END_CODE 9
  30. #define XEN_ENTER_SWITCH_CODE 10
  31. #define SPU_PROFILING_CODE 11
  32. #define SPU_CTX_SWITCH_CODE 12
  33. #define IBS_FETCH_CODE 13
  34. #define IBS_OP_CODE 14
  35. #pragma incomplete Ureg
  36. /**
  37. * One-time exit/cleanup for the arch.
  38. */
  39. void oprofile_arch_exit(void);
  40. /**
  41. * Add a sample. This may be called from any context.
  42. */
  43. void oprofile_add_sample(void* const regs, unsigned long event);
  44. /**
  45. * Add an extended sample. Use this when the PC is not from the regs, and
  46. * we cannot determine if we're in kernel mode from the regs.
  47. *
  48. * This function does perform a backtrace.
  49. *
  50. */
  51. void oprofile_add_ext_sample(unsigned long pc, void * const regs,
  52. unsigned long event, int is_kernel);
  53. /**
  54. * Add an hardware sample.
  55. */
  56. void oprofile_add_ext_hw_sample(unsigned long pc, Ureg *regs,
  57. unsigned long event, int is_kernel,
  58. Proc *proc);
  59. /* Use this instead when the PC value is not from the regs. Doesn't
  60. * backtrace. */
  61. void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event);
  62. void oprofile_add_backtrace(uintptr_t pc, uintptr_t fp);
  63. void oprofile_add_userpc(uintptr_t pc);
  64. /* add a backtrace entry, to be called from the ->backtrace callback */
  65. void oprofile_add_trace(unsigned long eip);
  66. /**
  67. * Add the contents of a circular buffer to the event buffer.
  68. */
  69. void oprofile_put_buff(unsigned long *buf, unsigned int start,
  70. unsigned int stop, unsigned int max);
  71. unsigned long oprofile_get_cpu_buffer_size(void);
  72. void oprofile_cpu_buffer_inc_smpl_lost(void);
  73. /* cpu buffer functions */
  74. /* CPU buffer is composed of samples.
  75. * As these are extracted from the buffer, they are encapsulated
  76. * in entries, which include additional info.
  77. */
  78. struct op_sample {
  79. unsigned long eip;
  80. unsigned long event;
  81. unsigned long data[0];
  82. };
  83. struct op_entry {
  84. void *event;
  85. struct op_sample *sample;
  86. unsigned long size;
  87. unsigned long *data;
  88. };
  89. void oprofile_write_reserve(struct op_entry *entry,
  90. Ureg *regs,
  91. unsigned long pc, int code, int size);
  92. int oprofile_add_data(struct op_entry *entry, unsigned long val);
  93. int oprofile_add_data64(struct op_entry *entry, uint64_t val);
  94. int oprofile_write_commit(struct op_entry *entry);
  95. void oprofile_perf_exit(void);
  96. char *op_name_from_perf_id(void);
  97. struct op_sample *op_cpu_buffer_read_entry(struct op_entry *entry, int cpu);
  98. unsigned long op_cpu_buffer_entries(int cpu);
  99. void oprofile_cpubuf_flushone(int core, int newbuf);
  100. void oprofile_cpubuf_flushall(int alloc);
  101. void oprofile_control_trace(int onoff);
  102. int oprofread(void *,int);
  103. int oproflen(void);
  104. #endif /* OPROFILE_H */