Markus Metzger | eee3af4 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 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 | |
| 20 | #ifndef _ASM_X86_DS_H |
| 21 | #define _ASM_X86_DS_H |
| 22 | |
| 23 | #include <linux/types.h> |
| 24 | #include <linux/init.h> |
| 25 | |
| 26 | struct cpuinfo_x86; |
| 27 | |
| 28 | |
| 29 | /* a branch trace record entry |
| 30 | * |
| 31 | * In order to unify the interface between various processor versions, |
| 32 | * we use the below data structure for all processors. |
| 33 | */ |
| 34 | enum bts_qualifier { |
| 35 | BTS_INVALID = 0, |
| 36 | BTS_BRANCH, |
| 37 | BTS_TASK_ARRIVES, |
| 38 | BTS_TASK_DEPARTS |
| 39 | }; |
| 40 | |
| 41 | struct bts_struct { |
Markus Metzger | e6ae5d9 | 2008-01-30 13:32:03 +0100 | [diff] [blame] | 42 | u64 qualifier; |
Markus Metzger | eee3af4 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 43 | union { |
| 44 | /* BTS_BRANCH */ |
| 45 | struct { |
Markus Metzger | e6ae5d9 | 2008-01-30 13:32:03 +0100 | [diff] [blame] | 46 | u64 from_ip; |
| 47 | u64 to_ip; |
Markus Metzger | eee3af4 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 48 | } lbr; |
| 49 | /* BTS_TASK_ARRIVES or |
| 50 | BTS_TASK_DEPARTS */ |
Markus Metzger | e6ae5d9 | 2008-01-30 13:32:03 +0100 | [diff] [blame] | 51 | u64 jiffies; |
Markus Metzger | eee3af4 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 52 | } variant; |
| 53 | }; |
| 54 | |
Markus Metzger | a95d67f | 2008-01-30 13:31:20 +0100 | [diff] [blame] | 55 | /* Overflow handling mechanisms */ |
| 56 | #define DS_O_SIGNAL 1 /* send overflow signal */ |
| 57 | #define DS_O_WRAP 2 /* wrap around */ |
Markus Metzger | eee3af4 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 58 | |
| 59 | extern int ds_allocate(void **, size_t); |
| 60 | extern int ds_free(void **); |
| 61 | extern int ds_get_bts_size(void *); |
Markus Metzger | a95d67f | 2008-01-30 13:31:20 +0100 | [diff] [blame] | 62 | extern int ds_get_bts_end(void *); |
Markus Metzger | eee3af4 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 63 | extern int ds_get_bts_index(void *); |
Markus Metzger | a95d67f | 2008-01-30 13:31:20 +0100 | [diff] [blame] | 64 | extern int ds_set_overflow(void *, int); |
| 65 | extern int ds_get_overflow(void *); |
| 66 | extern int ds_clear(void *); |
Markus Metzger | e6ae5d9 | 2008-01-30 13:32:03 +0100 | [diff] [blame] | 67 | extern int ds_read_bts(void *, int, struct bts_struct *); |
Markus Metzger | eee3af4 | 2008-01-30 13:31:09 +0100 | [diff] [blame] | 68 | extern int ds_write_bts(void *, const struct bts_struct *); |
| 69 | extern unsigned long ds_debugctl_mask(void); |
| 70 | extern void __cpuinit ds_init_intel(struct cpuinfo_x86 *c); |
| 71 | |
| 72 | #endif /* _ASM_X86_DS_H */ |