ds.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Debug Store (DS) support
  3. *
  4. * This provides a low-level interface to the hardware's Debug Store
  5. * feature that is used for last branch recording (LBR) and
  6. * precise-event based sampling (PEBS).
  7. *
  8. * Different architectures use a different DS layout/pointer size.
  9. * The below functions therefore work on a void*.
  10. *
  11. *
  12. * Since there is no user for PEBS, yet, only LBR (or branch
  13. * trace store, BTS) is supported.
  14. *
  15. *
  16. * Copyright (C) 2007 Intel Corporation.
  17. * Markus Metzger <markus.t.metzger@intel.com>, Dec 2007
  18. */
  19. #ifndef _ASM_X86_DS_H
  20. #define _ASM_X86_DS_H
  21. #include <linux/types.h>
  22. #include <linux/init.h>
  23. struct cpuinfo_x86;
  24. /* a branch trace record entry
  25. *
  26. * In order to unify the interface between various processor versions,
  27. * we use the below data structure for all processors.
  28. */
  29. enum bts_qualifier {
  30. BTS_INVALID = 0,
  31. BTS_BRANCH,
  32. BTS_TASK_ARRIVES,
  33. BTS_TASK_DEPARTS
  34. };
  35. struct bts_struct {
  36. u64 qualifier;
  37. union {
  38. /* BTS_BRANCH */
  39. struct {
  40. u64 from_ip;
  41. u64 to_ip;
  42. } lbr;
  43. /* BTS_TASK_ARRIVES or
  44. BTS_TASK_DEPARTS */
  45. u64 jiffies;
  46. } variant;
  47. };
  48. /* Overflow handling mechanisms */
  49. #define DS_O_SIGNAL 1 /* send overflow signal */
  50. #define DS_O_WRAP 2 /* wrap around */
  51. extern int ds_allocate(void **, size_t);
  52. extern int ds_free(void **);
  53. extern int ds_get_bts_size(void *);
  54. extern int ds_get_bts_end(void *);
  55. extern int ds_get_bts_index(void *);
  56. extern int ds_set_overflow(void *, int);
  57. extern int ds_get_overflow(void *);
  58. extern int ds_clear(void *);
  59. extern int ds_read_bts(void *, int, struct bts_struct *);
  60. extern int ds_write_bts(void *, const struct bts_struct *);
  61. extern unsigned long ds_debugctl_mask(void);
  62. extern void __cpuinit ds_init_intel(struct cpuinfo_x86 *c);
  63. #endif /* _ASM_X86_DS_H */