xref: /freebsd/contrib/processor-trace/libipt/internal/include/pt_packet_decoder.h (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1 /*
2  * Copyright (c) 2014-2019, Intel Corporation
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  *  * Redistributions of source code must retain the above copyright notice,
8  *    this list of conditions and the following disclaimer.
9  *  * Redistributions in binary form must reproduce the above copyright notice,
10  *    this list of conditions and the following disclaimer in the documentation
11  *    and/or other materials provided with the distribution.
12  *  * Neither the name of Intel Corporation nor the names of its contributors
13  *    may be used to endorse or promote products derived from this software
14  *    without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef PT_PACKET_DECODER_H
30 #define PT_PACKET_DECODER_H
31 
32 #include "intel-pt.h"
33 
34 
35 /* An Intel PT packet decoder. */
36 struct pt_packet_decoder {
37 	/* The decoder configuration. */
38 	struct pt_config config;
39 
40 	/* The current position in the trace buffer. */
41 	const uint8_t *pos;
42 
43 	/* The position of the last PSB packet. */
44 	const uint8_t *sync;
45 };
46 
47 
48 /* Initialize the packet decoder.
49  *
50  * Returns zero on success, a negative error code otherwise.
51  */
52 extern int pt_pkt_decoder_init(struct pt_packet_decoder *,
53 			       const struct pt_config *);
54 
55 /* Finalize the packet decoder. */
56 extern void pt_pkt_decoder_fini(struct pt_packet_decoder *);
57 
58 
59 /* Decoder functions for the packet decoder. */
60 extern int pt_pkt_decode_unknown(struct pt_packet_decoder *,
61 				 struct pt_packet *);
62 extern int pt_pkt_decode_pad(struct pt_packet_decoder *, struct pt_packet *);
63 extern int pt_pkt_decode_psb(struct pt_packet_decoder *, struct pt_packet *);
64 extern int pt_pkt_decode_tip(struct pt_packet_decoder *, struct pt_packet *);
65 extern int pt_pkt_decode_tnt_8(struct pt_packet_decoder *, struct pt_packet *);
66 extern int pt_pkt_decode_tnt_64(struct pt_packet_decoder *,
67 				struct pt_packet *);
68 extern int pt_pkt_decode_tip_pge(struct pt_packet_decoder *,
69 				 struct pt_packet *);
70 extern int pt_pkt_decode_tip_pgd(struct pt_packet_decoder *,
71 				 struct pt_packet *);
72 extern int pt_pkt_decode_fup(struct pt_packet_decoder *, struct pt_packet *);
73 extern int pt_pkt_decode_pip(struct pt_packet_decoder *, struct pt_packet *);
74 extern int pt_pkt_decode_ovf(struct pt_packet_decoder *, struct pt_packet *);
75 extern int pt_pkt_decode_mode(struct pt_packet_decoder *, struct pt_packet *);
76 extern int pt_pkt_decode_psbend(struct pt_packet_decoder *,
77 				struct pt_packet *);
78 extern int pt_pkt_decode_tsc(struct pt_packet_decoder *, struct pt_packet *);
79 extern int pt_pkt_decode_cbr(struct pt_packet_decoder *, struct pt_packet *);
80 extern int pt_pkt_decode_tma(struct pt_packet_decoder *, struct pt_packet *);
81 extern int pt_pkt_decode_mtc(struct pt_packet_decoder *, struct pt_packet *);
82 extern int pt_pkt_decode_cyc(struct pt_packet_decoder *, struct pt_packet *);
83 extern int pt_pkt_decode_stop(struct pt_packet_decoder *, struct pt_packet *);
84 extern int pt_pkt_decode_vmcs(struct pt_packet_decoder *, struct pt_packet *);
85 extern int pt_pkt_decode_mnt(struct pt_packet_decoder *, struct pt_packet *);
86 extern int pt_pkt_decode_exstop(struct pt_packet_decoder *, struct pt_packet *);
87 extern int pt_pkt_decode_mwait(struct pt_packet_decoder *, struct pt_packet *);
88 extern int pt_pkt_decode_pwre(struct pt_packet_decoder *, struct pt_packet *);
89 extern int pt_pkt_decode_pwrx(struct pt_packet_decoder *, struct pt_packet *);
90 extern int pt_pkt_decode_ptw(struct pt_packet_decoder *, struct pt_packet *);
91 
92 #endif /* PT_PACKET_DECODER_H */
93