2 * Copyright (c) 2013-2018, Intel Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
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.
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.
29 #ifndef PT_DECODER_FUNCTION_H
30 #define PT_DECODER_FUNCTION_H
34 struct pt_query_decoder;
35 struct pt_packet_decoder;
40 /* Intel(R) Processor Trace decoder function flags. */
41 enum pt_decoder_function_flag {
42 /* The decoded packet contains an unconditional branch destination. */
45 /* The decode packet contains unconditional branch destinations. */
48 /* The decoded packet contains an event. */
51 /* The decoded packet marks the end of a PSB header. */
54 /* The decoded packet contains a non-branch IP update. */
57 /* The decoded packet is unknown to the decoder. */
58 pdff_unknown = 1 << 5,
60 /* The decoded packet contains timing information. */
63 /* The decoded packet contains padding. */
67 /* An Intel(R) Processor Trace decoder function. */
68 struct pt_decoder_function {
69 /* The function to analyze the next packet. */
70 int (*packet)(struct pt_packet_decoder *, struct pt_packet *);
72 /* The function to decode the next packet. */
73 int (*decode)(struct pt_query_decoder *);
75 /* The function to decode the next packet in segment header
76 * context, i.e. between PSB and ENDPSB.
78 int (*header)(struct pt_query_decoder *);
80 /* Decoder function flags. */
85 /* Fetch the decoder function.
87 * Sets @dfun to the decoder function for decoding the packet at @pos.
89 * Returns 0 on success.
90 * Returns -pte_internal if @dfun or @config is NULL.
91 * Returns -pte_nosync if @pos is NULL or outside @config's trace buffer.
92 * Returns -pte_eos if the opcode is incomplete or missing.
94 extern int pt_df_fetch(const struct pt_decoder_function **dfun,
95 const uint8_t *pos, const struct pt_config *config);
98 /* Decoder functions for the various packet types.
100 * Do not call those functions directly!
102 extern const struct pt_decoder_function pt_decode_unknown;
103 extern const struct pt_decoder_function pt_decode_pad;
104 extern const struct pt_decoder_function pt_decode_psb;
105 extern const struct pt_decoder_function pt_decode_tip;
106 extern const struct pt_decoder_function pt_decode_tnt_8;
107 extern const struct pt_decoder_function pt_decode_tnt_64;
108 extern const struct pt_decoder_function pt_decode_tip_pge;
109 extern const struct pt_decoder_function pt_decode_tip_pgd;
110 extern const struct pt_decoder_function pt_decode_fup;
111 extern const struct pt_decoder_function pt_decode_pip;
112 extern const struct pt_decoder_function pt_decode_ovf;
113 extern const struct pt_decoder_function pt_decode_mode;
114 extern const struct pt_decoder_function pt_decode_psbend;
115 extern const struct pt_decoder_function pt_decode_tsc;
116 extern const struct pt_decoder_function pt_decode_cbr;
117 extern const struct pt_decoder_function pt_decode_tma;
118 extern const struct pt_decoder_function pt_decode_mtc;
119 extern const struct pt_decoder_function pt_decode_cyc;
120 extern const struct pt_decoder_function pt_decode_stop;
121 extern const struct pt_decoder_function pt_decode_vmcs;
122 extern const struct pt_decoder_function pt_decode_mnt;
123 extern const struct pt_decoder_function pt_decode_exstop;
124 extern const struct pt_decoder_function pt_decode_mwait;
125 extern const struct pt_decoder_function pt_decode_pwre;
126 extern const struct pt_decoder_function pt_decode_pwrx;
127 extern const struct pt_decoder_function pt_decode_ptw;
129 #endif /* PT_DECODER_FUNCTION_H */