2 * Copyright (c) 2014-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.
35 /* An Intel PT packet encoder. */
37 /* The encoder configuration. */
38 struct pt_config config;
40 /** The current position in the trace buffer. */
45 /* Initialize the packet encoder.
47 * Returns zero on success, a negative error code otherwise.
49 extern int pt_encoder_init(struct pt_encoder *, const struct pt_config *);
51 /* Finalize the packet encoder. */
52 extern void pt_encoder_fini(struct pt_encoder *);
55 /* The below functions are convenience wrappers around pt_enc_next(). */
57 /* Encode a Padding (pad) packet. */
58 extern int pt_encode_pad(struct pt_encoder *);
60 /* Encode a Packet Stream Boundary (psb) packet. */
61 extern int pt_encode_psb(struct pt_encoder *);
63 /* Encode an End PSB (psbend) packet. */
64 extern int pt_encode_psbend(struct pt_encoder *);
66 /* Encode a Target Instruction Pointer (tip) packet. */
67 extern int pt_encode_tip(struct pt_encoder *, uint64_t ip,
68 enum pt_ip_compression ipc);
70 /* Encode a Taken Not Taken (tnt) packet - 8-bit version. */
71 extern int pt_encode_tnt_8(struct pt_encoder *, uint8_t tnt, int size);
73 /* Encode a Taken Not Taken (tnt) packet - 64-bit version. */
74 extern int pt_encode_tnt_64(struct pt_encoder *, uint64_t tnt, int size);
76 /* Encode a Packet Generation Enable (tip.pge) packet. */
77 extern int pt_encode_tip_pge(struct pt_encoder *, uint64_t ip,
78 enum pt_ip_compression ipc);
80 /* Encode a Packet Generation Disable (tip.pgd) packet. */
81 extern int pt_encode_tip_pgd(struct pt_encoder *, uint64_t ip,
82 enum pt_ip_compression ipc);
84 /* Encode a Flow Update Packet (fup). */
85 extern int pt_encode_fup(struct pt_encoder *, uint64_t ip,
86 enum pt_ip_compression ipc);
88 /* Encode a Paging Information Packet (pip). */
89 extern int pt_encode_pip(struct pt_encoder *, uint64_t cr3, uint8_t flags);
91 /* Encode a Overflow Packet (ovf). */
92 extern int pt_encode_ovf(struct pt_encoder *);
94 /* Encode a Mode Exec Packet (mode.exec). */
95 extern int pt_encode_mode_exec(struct pt_encoder *, enum pt_exec_mode);
97 /* Encode a Mode Tsx Packet (mode.tsx). */
98 extern int pt_encode_mode_tsx(struct pt_encoder *, uint8_t);
100 /* Encode a Time Stamp Counter (tsc) packet. */
101 extern int pt_encode_tsc(struct pt_encoder *, uint64_t);
103 /* Encode a Core Bus Ratio (cbr) packet. */
104 extern int pt_encode_cbr(struct pt_encoder *, uint8_t);
106 /* Encode a TSC/MTC Alignment (tma) packet. */
107 extern int pt_encode_tma(struct pt_encoder *, uint16_t ctc,
110 /* Encode a Mini Time Counter (mtc) packet. */
111 extern int pt_encode_mtc(struct pt_encoder *, uint8_t ctc);
113 /* Encode a Cycle Count (cyc) packet. */
114 extern int pt_encode_cyc(struct pt_encoder *, uint32_t cyc);
116 /* Encode a TraceStop Packet (stop). */
117 extern int pt_encode_stop(struct pt_encoder *);
119 /* Encode a VMCS packet. */
120 extern int pt_encode_vmcs(struct pt_encoder *, uint64_t);
122 /* Encode a Maintenance (mnt) packet. */
123 extern int pt_encode_mnt(struct pt_encoder *, uint64_t);
125 #endif /* PT_ENCODER_H */