1*436bf2bcSAndroid Build Coastguard Worker // SPDX-License-Identifier: LGPL-2.1
2*436bf2bcSAndroid Build Coastguard Worker /*
3*436bf2bcSAndroid Build Coastguard Worker * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <[email protected]>
4*436bf2bcSAndroid Build Coastguard Worker *
5*436bf2bcSAndroid Build Coastguard Worker */
6*436bf2bcSAndroid Build Coastguard Worker
7*436bf2bcSAndroid Build Coastguard Worker #include "event-parse.h"
8*436bf2bcSAndroid Build Coastguard Worker #include "event-parse-local.h"
9*436bf2bcSAndroid Build Coastguard Worker #include "event-utils.h"
10*436bf2bcSAndroid Build Coastguard Worker
11*436bf2bcSAndroid Build Coastguard Worker /**
12*436bf2bcSAndroid Build Coastguard Worker * tep_get_event - returns the event with the given index
13*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
14*436bf2bcSAndroid Build Coastguard Worker * @index: index of the requested event, in the range 0 .. nr_events
15*436bf2bcSAndroid Build Coastguard Worker *
16*436bf2bcSAndroid Build Coastguard Worker * This returns pointer to the element of the events array with the given index
17*436bf2bcSAndroid Build Coastguard Worker * If @tep is NULL, or @index is not in the range 0 .. nr_events, NULL is returned.
18*436bf2bcSAndroid Build Coastguard Worker */
tep_get_event(struct tep_handle * tep,int index)19*436bf2bcSAndroid Build Coastguard Worker struct tep_event *tep_get_event(struct tep_handle *tep, int index)
20*436bf2bcSAndroid Build Coastguard Worker {
21*436bf2bcSAndroid Build Coastguard Worker if (tep && tep->events && index < tep->nr_events)
22*436bf2bcSAndroid Build Coastguard Worker return tep->events[index];
23*436bf2bcSAndroid Build Coastguard Worker
24*436bf2bcSAndroid Build Coastguard Worker return NULL;
25*436bf2bcSAndroid Build Coastguard Worker }
26*436bf2bcSAndroid Build Coastguard Worker
27*436bf2bcSAndroid Build Coastguard Worker /**
28*436bf2bcSAndroid Build Coastguard Worker * tep_get_first_event - returns the first event in the events array
29*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
30*436bf2bcSAndroid Build Coastguard Worker *
31*436bf2bcSAndroid Build Coastguard Worker * This returns pointer to the first element of the events array
32*436bf2bcSAndroid Build Coastguard Worker * If @tep is NULL, NULL is returned.
33*436bf2bcSAndroid Build Coastguard Worker */
tep_get_first_event(struct tep_handle * tep)34*436bf2bcSAndroid Build Coastguard Worker struct tep_event *tep_get_first_event(struct tep_handle *tep)
35*436bf2bcSAndroid Build Coastguard Worker {
36*436bf2bcSAndroid Build Coastguard Worker return tep_get_event(tep, 0);
37*436bf2bcSAndroid Build Coastguard Worker }
38*436bf2bcSAndroid Build Coastguard Worker
39*436bf2bcSAndroid Build Coastguard Worker /**
40*436bf2bcSAndroid Build Coastguard Worker * tep_get_events_count - get the number of defined events
41*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
42*436bf2bcSAndroid Build Coastguard Worker *
43*436bf2bcSAndroid Build Coastguard Worker * This returns number of elements in event array
44*436bf2bcSAndroid Build Coastguard Worker * If @tep is NULL, 0 is returned.
45*436bf2bcSAndroid Build Coastguard Worker */
tep_get_events_count(struct tep_handle * tep)46*436bf2bcSAndroid Build Coastguard Worker int tep_get_events_count(struct tep_handle *tep)
47*436bf2bcSAndroid Build Coastguard Worker {
48*436bf2bcSAndroid Build Coastguard Worker if (tep)
49*436bf2bcSAndroid Build Coastguard Worker return tep->nr_events;
50*436bf2bcSAndroid Build Coastguard Worker return 0;
51*436bf2bcSAndroid Build Coastguard Worker }
52*436bf2bcSAndroid Build Coastguard Worker
53*436bf2bcSAndroid Build Coastguard Worker /**
54*436bf2bcSAndroid Build Coastguard Worker * tep_get_events_count - get the number of defined events
55*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
56*436bf2bcSAndroid Build Coastguard Worker *
57*436bf2bcSAndroid Build Coastguard Worker * This returns number of elements in event array
58*436bf2bcSAndroid Build Coastguard Worker * If @tep is NULL, 0 is returned.
59*436bf2bcSAndroid Build Coastguard Worker */
tep_get_function_count(struct tep_handle * tep)60*436bf2bcSAndroid Build Coastguard Worker int tep_get_function_count(struct tep_handle *tep)
61*436bf2bcSAndroid Build Coastguard Worker {
62*436bf2bcSAndroid Build Coastguard Worker if (tep)
63*436bf2bcSAndroid Build Coastguard Worker return tep->func_count;
64*436bf2bcSAndroid Build Coastguard Worker return 0;
65*436bf2bcSAndroid Build Coastguard Worker }
66*436bf2bcSAndroid Build Coastguard Worker
67*436bf2bcSAndroid Build Coastguard Worker /**
68*436bf2bcSAndroid Build Coastguard Worker * tep_set_flag - set event parser flag
69*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
70*436bf2bcSAndroid Build Coastguard Worker * @flag: flag, or combination of flags to be set
71*436bf2bcSAndroid Build Coastguard Worker * can be any combination from enum tep_flag
72*436bf2bcSAndroid Build Coastguard Worker *
73*436bf2bcSAndroid Build Coastguard Worker * This sets a flag or combination of flags from enum tep_flag
74*436bf2bcSAndroid Build Coastguard Worker */
tep_set_flag(struct tep_handle * tep,int flag)75*436bf2bcSAndroid Build Coastguard Worker void tep_set_flag(struct tep_handle *tep, int flag)
76*436bf2bcSAndroid Build Coastguard Worker {
77*436bf2bcSAndroid Build Coastguard Worker if (tep)
78*436bf2bcSAndroid Build Coastguard Worker tep->flags |= flag;
79*436bf2bcSAndroid Build Coastguard Worker }
80*436bf2bcSAndroid Build Coastguard Worker
81*436bf2bcSAndroid Build Coastguard Worker /**
82*436bf2bcSAndroid Build Coastguard Worker * tep_clear_flag - clear event parser flag
83*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
84*436bf2bcSAndroid Build Coastguard Worker * @flag: flag to be cleared
85*436bf2bcSAndroid Build Coastguard Worker *
86*436bf2bcSAndroid Build Coastguard Worker * This clears a tep flag
87*436bf2bcSAndroid Build Coastguard Worker */
tep_clear_flag(struct tep_handle * tep,enum tep_flag flag)88*436bf2bcSAndroid Build Coastguard Worker void tep_clear_flag(struct tep_handle *tep, enum tep_flag flag)
89*436bf2bcSAndroid Build Coastguard Worker {
90*436bf2bcSAndroid Build Coastguard Worker if (tep)
91*436bf2bcSAndroid Build Coastguard Worker tep->flags &= ~flag;
92*436bf2bcSAndroid Build Coastguard Worker }
93*436bf2bcSAndroid Build Coastguard Worker
94*436bf2bcSAndroid Build Coastguard Worker /**
95*436bf2bcSAndroid Build Coastguard Worker * tep_test_flag - check the state of event parser flag
96*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
97*436bf2bcSAndroid Build Coastguard Worker * @flag: flag to be checked
98*436bf2bcSAndroid Build Coastguard Worker *
99*436bf2bcSAndroid Build Coastguard Worker * This returns the state of the requested tep flag.
100*436bf2bcSAndroid Build Coastguard Worker * Returns: true if the flag is set, false otherwise.
101*436bf2bcSAndroid Build Coastguard Worker */
tep_test_flag(struct tep_handle * tep,enum tep_flag flag)102*436bf2bcSAndroid Build Coastguard Worker bool tep_test_flag(struct tep_handle *tep, enum tep_flag flag)
103*436bf2bcSAndroid Build Coastguard Worker {
104*436bf2bcSAndroid Build Coastguard Worker if (tep)
105*436bf2bcSAndroid Build Coastguard Worker return tep->flags & flag;
106*436bf2bcSAndroid Build Coastguard Worker return false;
107*436bf2bcSAndroid Build Coastguard Worker }
108*436bf2bcSAndroid Build Coastguard Worker
data2host2(struct tep_handle * tep,unsigned short data)109*436bf2bcSAndroid Build Coastguard Worker __hidden unsigned short data2host2(struct tep_handle *tep, unsigned short data)
110*436bf2bcSAndroid Build Coastguard Worker {
111*436bf2bcSAndroid Build Coastguard Worker unsigned short swap;
112*436bf2bcSAndroid Build Coastguard Worker
113*436bf2bcSAndroid Build Coastguard Worker if (!tep || tep->host_bigendian == tep->file_bigendian)
114*436bf2bcSAndroid Build Coastguard Worker return data;
115*436bf2bcSAndroid Build Coastguard Worker
116*436bf2bcSAndroid Build Coastguard Worker swap = ((data & 0xffULL) << 8) |
117*436bf2bcSAndroid Build Coastguard Worker ((data & (0xffULL << 8)) >> 8);
118*436bf2bcSAndroid Build Coastguard Worker
119*436bf2bcSAndroid Build Coastguard Worker return swap;
120*436bf2bcSAndroid Build Coastguard Worker }
121*436bf2bcSAndroid Build Coastguard Worker
data2host4(struct tep_handle * tep,unsigned int data)122*436bf2bcSAndroid Build Coastguard Worker __hidden unsigned int data2host4(struct tep_handle *tep, unsigned int data)
123*436bf2bcSAndroid Build Coastguard Worker {
124*436bf2bcSAndroid Build Coastguard Worker unsigned int swap;
125*436bf2bcSAndroid Build Coastguard Worker
126*436bf2bcSAndroid Build Coastguard Worker if (!tep || tep->host_bigendian == tep->file_bigendian)
127*436bf2bcSAndroid Build Coastguard Worker return data;
128*436bf2bcSAndroid Build Coastguard Worker
129*436bf2bcSAndroid Build Coastguard Worker swap = ((data & 0xffULL) << 24) |
130*436bf2bcSAndroid Build Coastguard Worker ((data & (0xffULL << 8)) << 8) |
131*436bf2bcSAndroid Build Coastguard Worker ((data & (0xffULL << 16)) >> 8) |
132*436bf2bcSAndroid Build Coastguard Worker ((data & (0xffULL << 24)) >> 24);
133*436bf2bcSAndroid Build Coastguard Worker
134*436bf2bcSAndroid Build Coastguard Worker return swap;
135*436bf2bcSAndroid Build Coastguard Worker }
136*436bf2bcSAndroid Build Coastguard Worker
137*436bf2bcSAndroid Build Coastguard Worker __hidden unsigned long long
data2host8(struct tep_handle * tep,unsigned long long data)138*436bf2bcSAndroid Build Coastguard Worker data2host8(struct tep_handle *tep, unsigned long long data)
139*436bf2bcSAndroid Build Coastguard Worker {
140*436bf2bcSAndroid Build Coastguard Worker unsigned long long swap;
141*436bf2bcSAndroid Build Coastguard Worker
142*436bf2bcSAndroid Build Coastguard Worker if (!tep || tep->host_bigendian == tep->file_bigendian)
143*436bf2bcSAndroid Build Coastguard Worker return data;
144*436bf2bcSAndroid Build Coastguard Worker
145*436bf2bcSAndroid Build Coastguard Worker swap = ((data & 0xffULL) << 56) |
146*436bf2bcSAndroid Build Coastguard Worker ((data & (0xffULL << 8)) << 40) |
147*436bf2bcSAndroid Build Coastguard Worker ((data & (0xffULL << 16)) << 24) |
148*436bf2bcSAndroid Build Coastguard Worker ((data & (0xffULL << 24)) << 8) |
149*436bf2bcSAndroid Build Coastguard Worker ((data & (0xffULL << 32)) >> 8) |
150*436bf2bcSAndroid Build Coastguard Worker ((data & (0xffULL << 40)) >> 24) |
151*436bf2bcSAndroid Build Coastguard Worker ((data & (0xffULL << 48)) >> 40) |
152*436bf2bcSAndroid Build Coastguard Worker ((data & (0xffULL << 56)) >> 56);
153*436bf2bcSAndroid Build Coastguard Worker
154*436bf2bcSAndroid Build Coastguard Worker return swap;
155*436bf2bcSAndroid Build Coastguard Worker }
156*436bf2bcSAndroid Build Coastguard Worker
157*436bf2bcSAndroid Build Coastguard Worker /**
158*436bf2bcSAndroid Build Coastguard Worker * tep_get_header_page_size - get size of the header page
159*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
160*436bf2bcSAndroid Build Coastguard Worker *
161*436bf2bcSAndroid Build Coastguard Worker * This returns size of the header page
162*436bf2bcSAndroid Build Coastguard Worker * If @tep is NULL, 0 is returned.
163*436bf2bcSAndroid Build Coastguard Worker */
tep_get_header_page_size(struct tep_handle * tep)164*436bf2bcSAndroid Build Coastguard Worker int tep_get_header_page_size(struct tep_handle *tep)
165*436bf2bcSAndroid Build Coastguard Worker {
166*436bf2bcSAndroid Build Coastguard Worker if (tep)
167*436bf2bcSAndroid Build Coastguard Worker return tep->header_page_size_size;
168*436bf2bcSAndroid Build Coastguard Worker return 0;
169*436bf2bcSAndroid Build Coastguard Worker }
170*436bf2bcSAndroid Build Coastguard Worker
171*436bf2bcSAndroid Build Coastguard Worker /**
172*436bf2bcSAndroid Build Coastguard Worker * tep_get_header_timestamp_size - get size of the timestamp in the header page
173*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
174*436bf2bcSAndroid Build Coastguard Worker *
175*436bf2bcSAndroid Build Coastguard Worker * This returns size of the timestamp in the header page
176*436bf2bcSAndroid Build Coastguard Worker * If @tep is NULL, 0 is returned.
177*436bf2bcSAndroid Build Coastguard Worker */
tep_get_header_timestamp_size(struct tep_handle * tep)178*436bf2bcSAndroid Build Coastguard Worker int tep_get_header_timestamp_size(struct tep_handle *tep)
179*436bf2bcSAndroid Build Coastguard Worker {
180*436bf2bcSAndroid Build Coastguard Worker if (tep)
181*436bf2bcSAndroid Build Coastguard Worker return tep->header_page_ts_size;
182*436bf2bcSAndroid Build Coastguard Worker return 0;
183*436bf2bcSAndroid Build Coastguard Worker }
184*436bf2bcSAndroid Build Coastguard Worker
185*436bf2bcSAndroid Build Coastguard Worker /**
186*436bf2bcSAndroid Build Coastguard Worker * tep_get_cpus - get the number of CPUs
187*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
188*436bf2bcSAndroid Build Coastguard Worker *
189*436bf2bcSAndroid Build Coastguard Worker * This returns the number of CPUs
190*436bf2bcSAndroid Build Coastguard Worker * If @tep is NULL, 0 is returned.
191*436bf2bcSAndroid Build Coastguard Worker */
tep_get_cpus(struct tep_handle * tep)192*436bf2bcSAndroid Build Coastguard Worker int tep_get_cpus(struct tep_handle *tep)
193*436bf2bcSAndroid Build Coastguard Worker {
194*436bf2bcSAndroid Build Coastguard Worker if (tep)
195*436bf2bcSAndroid Build Coastguard Worker return tep->cpus;
196*436bf2bcSAndroid Build Coastguard Worker return 0;
197*436bf2bcSAndroid Build Coastguard Worker }
198*436bf2bcSAndroid Build Coastguard Worker
199*436bf2bcSAndroid Build Coastguard Worker /**
200*436bf2bcSAndroid Build Coastguard Worker * tep_set_cpus - set the number of CPUs
201*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
202*436bf2bcSAndroid Build Coastguard Worker *
203*436bf2bcSAndroid Build Coastguard Worker * This sets the number of CPUs
204*436bf2bcSAndroid Build Coastguard Worker */
tep_set_cpus(struct tep_handle * tep,int cpus)205*436bf2bcSAndroid Build Coastguard Worker void tep_set_cpus(struct tep_handle *tep, int cpus)
206*436bf2bcSAndroid Build Coastguard Worker {
207*436bf2bcSAndroid Build Coastguard Worker if (tep)
208*436bf2bcSAndroid Build Coastguard Worker tep->cpus = cpus;
209*436bf2bcSAndroid Build Coastguard Worker }
210*436bf2bcSAndroid Build Coastguard Worker
211*436bf2bcSAndroid Build Coastguard Worker /**
212*436bf2bcSAndroid Build Coastguard Worker * tep_get_long_size - get the size of a long integer on the traced machine
213*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
214*436bf2bcSAndroid Build Coastguard Worker *
215*436bf2bcSAndroid Build Coastguard Worker * This returns the size of a long integer on the traced machine
216*436bf2bcSAndroid Build Coastguard Worker * If @tep is NULL, 0 is returned.
217*436bf2bcSAndroid Build Coastguard Worker */
tep_get_long_size(struct tep_handle * tep)218*436bf2bcSAndroid Build Coastguard Worker int tep_get_long_size(struct tep_handle *tep)
219*436bf2bcSAndroid Build Coastguard Worker {
220*436bf2bcSAndroid Build Coastguard Worker if (tep)
221*436bf2bcSAndroid Build Coastguard Worker return tep->long_size;
222*436bf2bcSAndroid Build Coastguard Worker return 0;
223*436bf2bcSAndroid Build Coastguard Worker }
224*436bf2bcSAndroid Build Coastguard Worker
225*436bf2bcSAndroid Build Coastguard Worker /**
226*436bf2bcSAndroid Build Coastguard Worker * tep_set_long_size - set the size of a long integer on the traced machine
227*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
228*436bf2bcSAndroid Build Coastguard Worker * @size: size, in bytes, of a long integer
229*436bf2bcSAndroid Build Coastguard Worker *
230*436bf2bcSAndroid Build Coastguard Worker * This sets the size of a long integer on the traced machine
231*436bf2bcSAndroid Build Coastguard Worker */
tep_set_long_size(struct tep_handle * tep,int long_size)232*436bf2bcSAndroid Build Coastguard Worker void tep_set_long_size(struct tep_handle *tep, int long_size)
233*436bf2bcSAndroid Build Coastguard Worker {
234*436bf2bcSAndroid Build Coastguard Worker if (tep)
235*436bf2bcSAndroid Build Coastguard Worker tep->long_size = long_size;
236*436bf2bcSAndroid Build Coastguard Worker }
237*436bf2bcSAndroid Build Coastguard Worker
238*436bf2bcSAndroid Build Coastguard Worker /**
239*436bf2bcSAndroid Build Coastguard Worker * tep_get_page_size - get the size of a memory page on the traced machine
240*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
241*436bf2bcSAndroid Build Coastguard Worker *
242*436bf2bcSAndroid Build Coastguard Worker * This returns the size of a memory page on the traced machine
243*436bf2bcSAndroid Build Coastguard Worker * If @tep is NULL, 0 is returned.
244*436bf2bcSAndroid Build Coastguard Worker */
tep_get_page_size(struct tep_handle * tep)245*436bf2bcSAndroid Build Coastguard Worker int tep_get_page_size(struct tep_handle *tep)
246*436bf2bcSAndroid Build Coastguard Worker {
247*436bf2bcSAndroid Build Coastguard Worker if (tep)
248*436bf2bcSAndroid Build Coastguard Worker return tep->page_size;
249*436bf2bcSAndroid Build Coastguard Worker return 0;
250*436bf2bcSAndroid Build Coastguard Worker }
251*436bf2bcSAndroid Build Coastguard Worker
252*436bf2bcSAndroid Build Coastguard Worker /**
253*436bf2bcSAndroid Build Coastguard Worker * tep_set_page_size - set the size of a memory page on the traced machine
254*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
255*436bf2bcSAndroid Build Coastguard Worker * @_page_size: size of a memory page, in bytes
256*436bf2bcSAndroid Build Coastguard Worker *
257*436bf2bcSAndroid Build Coastguard Worker * This sets the size of a memory page on the traced machine
258*436bf2bcSAndroid Build Coastguard Worker */
tep_set_page_size(struct tep_handle * tep,int _page_size)259*436bf2bcSAndroid Build Coastguard Worker void tep_set_page_size(struct tep_handle *tep, int _page_size)
260*436bf2bcSAndroid Build Coastguard Worker {
261*436bf2bcSAndroid Build Coastguard Worker if (tep)
262*436bf2bcSAndroid Build Coastguard Worker tep->page_size = _page_size;
263*436bf2bcSAndroid Build Coastguard Worker }
264*436bf2bcSAndroid Build Coastguard Worker
265*436bf2bcSAndroid Build Coastguard Worker /**
266*436bf2bcSAndroid Build Coastguard Worker * tep_get_sub_buffer_data_size - get the size of the data portion
267*436bf2bcSAndroid Build Coastguard Worker * @tep: The handle to the tep to get the data size from
268*436bf2bcSAndroid Build Coastguard Worker *
269*436bf2bcSAndroid Build Coastguard Worker * Returns the size of the data portion of the sub buffer
270*436bf2bcSAndroid Build Coastguard Worker */
tep_get_sub_buffer_data_size(struct tep_handle * tep)271*436bf2bcSAndroid Build Coastguard Worker int tep_get_sub_buffer_data_size(struct tep_handle *tep)
272*436bf2bcSAndroid Build Coastguard Worker {
273*436bf2bcSAndroid Build Coastguard Worker if (!tep)
274*436bf2bcSAndroid Build Coastguard Worker return -1;
275*436bf2bcSAndroid Build Coastguard Worker
276*436bf2bcSAndroid Build Coastguard Worker return tep->header_page_data_size;
277*436bf2bcSAndroid Build Coastguard Worker }
278*436bf2bcSAndroid Build Coastguard Worker
279*436bf2bcSAndroid Build Coastguard Worker /**
280*436bf2bcSAndroid Build Coastguard Worker * tep_get_sub_buffer_size - get the size of a trace buffer page
281*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
282*436bf2bcSAndroid Build Coastguard Worker *
283*436bf2bcSAndroid Build Coastguard Worker * This returns the size of a trace buffer page on the traced machine.
284*436bf2bcSAndroid Build Coastguard Worker * If @tep is NULL then -1 is returned.
285*436bf2bcSAndroid Build Coastguard Worker */
tep_get_sub_buffer_size(struct tep_handle * tep)286*436bf2bcSAndroid Build Coastguard Worker int tep_get_sub_buffer_size(struct tep_handle *tep)
287*436bf2bcSAndroid Build Coastguard Worker {
288*436bf2bcSAndroid Build Coastguard Worker if (!tep)
289*436bf2bcSAndroid Build Coastguard Worker return -1;
290*436bf2bcSAndroid Build Coastguard Worker
291*436bf2bcSAndroid Build Coastguard Worker return tep->header_page_data_size + tep->header_page_data_offset;
292*436bf2bcSAndroid Build Coastguard Worker }
293*436bf2bcSAndroid Build Coastguard Worker
294*436bf2bcSAndroid Build Coastguard Worker /**
295*436bf2bcSAndroid Build Coastguard Worker * tep_get_sub_buffer_commit_offset - return offset of the commit location
296*436bf2bcSAndroid Build Coastguard Worker * @tep: the handle to the tep_handle
297*436bf2bcSAndroid Build Coastguard Worker *
298*436bf2bcSAndroid Build Coastguard Worker * Returns the offset of where to find the "commit" field of the offset.
299*436bf2bcSAndroid Build Coastguard Worker * Use tep_get_header_page_size() to find the size of the commit field.
300*436bf2bcSAndroid Build Coastguard Worker */
tep_get_sub_buffer_commit_offset(struct tep_handle * tep)301*436bf2bcSAndroid Build Coastguard Worker int tep_get_sub_buffer_commit_offset(struct tep_handle *tep)
302*436bf2bcSAndroid Build Coastguard Worker {
303*436bf2bcSAndroid Build Coastguard Worker if (!tep)
304*436bf2bcSAndroid Build Coastguard Worker return -1;
305*436bf2bcSAndroid Build Coastguard Worker
306*436bf2bcSAndroid Build Coastguard Worker return tep->header_page_size_offset;
307*436bf2bcSAndroid Build Coastguard Worker }
308*436bf2bcSAndroid Build Coastguard Worker
309*436bf2bcSAndroid Build Coastguard Worker /**
310*436bf2bcSAndroid Build Coastguard Worker * tep_is_file_bigendian - return the endian of the file
311*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
312*436bf2bcSAndroid Build Coastguard Worker *
313*436bf2bcSAndroid Build Coastguard Worker * This returns true if the file is in big endian order
314*436bf2bcSAndroid Build Coastguard Worker * If @tep is NULL, false is returned.
315*436bf2bcSAndroid Build Coastguard Worker */
tep_is_file_bigendian(struct tep_handle * tep)316*436bf2bcSAndroid Build Coastguard Worker bool tep_is_file_bigendian(struct tep_handle *tep)
317*436bf2bcSAndroid Build Coastguard Worker {
318*436bf2bcSAndroid Build Coastguard Worker if (tep)
319*436bf2bcSAndroid Build Coastguard Worker return (tep->file_bigendian == TEP_BIG_ENDIAN);
320*436bf2bcSAndroid Build Coastguard Worker return false;
321*436bf2bcSAndroid Build Coastguard Worker }
322*436bf2bcSAndroid Build Coastguard Worker
323*436bf2bcSAndroid Build Coastguard Worker /**
324*436bf2bcSAndroid Build Coastguard Worker * tep_set_file_bigendian - set if the file is in big endian order
325*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
326*436bf2bcSAndroid Build Coastguard Worker * @endian: non zero, if the file is in big endian order
327*436bf2bcSAndroid Build Coastguard Worker *
328*436bf2bcSAndroid Build Coastguard Worker * This sets if the file is in big endian order
329*436bf2bcSAndroid Build Coastguard Worker */
tep_set_file_bigendian(struct tep_handle * tep,enum tep_endian endian)330*436bf2bcSAndroid Build Coastguard Worker void tep_set_file_bigendian(struct tep_handle *tep, enum tep_endian endian)
331*436bf2bcSAndroid Build Coastguard Worker {
332*436bf2bcSAndroid Build Coastguard Worker if (tep)
333*436bf2bcSAndroid Build Coastguard Worker tep->file_bigendian = endian;
334*436bf2bcSAndroid Build Coastguard Worker }
335*436bf2bcSAndroid Build Coastguard Worker
336*436bf2bcSAndroid Build Coastguard Worker /**
337*436bf2bcSAndroid Build Coastguard Worker * tep_is_local_bigendian - return the endian of the saved local machine
338*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
339*436bf2bcSAndroid Build Coastguard Worker *
340*436bf2bcSAndroid Build Coastguard Worker * This returns true if the saved local machine in @tep is big endian.
341*436bf2bcSAndroid Build Coastguard Worker * If @tep is NULL, false is returned.
342*436bf2bcSAndroid Build Coastguard Worker */
tep_is_local_bigendian(struct tep_handle * tep)343*436bf2bcSAndroid Build Coastguard Worker bool tep_is_local_bigendian(struct tep_handle *tep)
344*436bf2bcSAndroid Build Coastguard Worker {
345*436bf2bcSAndroid Build Coastguard Worker if (tep)
346*436bf2bcSAndroid Build Coastguard Worker return (tep->host_bigendian == TEP_BIG_ENDIAN);
347*436bf2bcSAndroid Build Coastguard Worker return 0;
348*436bf2bcSAndroid Build Coastguard Worker }
349*436bf2bcSAndroid Build Coastguard Worker
350*436bf2bcSAndroid Build Coastguard Worker /**
351*436bf2bcSAndroid Build Coastguard Worker * tep_set_local_bigendian - set the stored local machine endian order
352*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
353*436bf2bcSAndroid Build Coastguard Worker * @endian: non zero, if the local host has big endian order
354*436bf2bcSAndroid Build Coastguard Worker *
355*436bf2bcSAndroid Build Coastguard Worker * This sets the endian order for the local machine.
356*436bf2bcSAndroid Build Coastguard Worker */
tep_set_local_bigendian(struct tep_handle * tep,enum tep_endian endian)357*436bf2bcSAndroid Build Coastguard Worker void tep_set_local_bigendian(struct tep_handle *tep, enum tep_endian endian)
358*436bf2bcSAndroid Build Coastguard Worker {
359*436bf2bcSAndroid Build Coastguard Worker if (tep)
360*436bf2bcSAndroid Build Coastguard Worker tep->host_bigendian = endian;
361*436bf2bcSAndroid Build Coastguard Worker }
362*436bf2bcSAndroid Build Coastguard Worker
363*436bf2bcSAndroid Build Coastguard Worker /**
364*436bf2bcSAndroid Build Coastguard Worker * tep_is_old_format - get if an old kernel is used
365*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
366*436bf2bcSAndroid Build Coastguard Worker *
367*436bf2bcSAndroid Build Coastguard Worker * This returns true, if an old kernel is used to generate the tracing events or
368*436bf2bcSAndroid Build Coastguard Worker * false if a new kernel is used. Old kernels did not have header page info.
369*436bf2bcSAndroid Build Coastguard Worker * If @tep is NULL, false is returned.
370*436bf2bcSAndroid Build Coastguard Worker */
tep_is_old_format(struct tep_handle * tep)371*436bf2bcSAndroid Build Coastguard Worker bool tep_is_old_format(struct tep_handle *tep)
372*436bf2bcSAndroid Build Coastguard Worker {
373*436bf2bcSAndroid Build Coastguard Worker if (tep)
374*436bf2bcSAndroid Build Coastguard Worker return tep->old_format;
375*436bf2bcSAndroid Build Coastguard Worker return false;
376*436bf2bcSAndroid Build Coastguard Worker }
377*436bf2bcSAndroid Build Coastguard Worker
378*436bf2bcSAndroid Build Coastguard Worker /**
379*436bf2bcSAndroid Build Coastguard Worker * tep_set_test_filters - set a flag to test a filter string
380*436bf2bcSAndroid Build Coastguard Worker * @tep: a handle to the tep_handle
381*436bf2bcSAndroid Build Coastguard Worker * @test_filters: the new value of the test_filters flag
382*436bf2bcSAndroid Build Coastguard Worker *
383*436bf2bcSAndroid Build Coastguard Worker * This sets a flag to test a filter string. If this flag is set, when
384*436bf2bcSAndroid Build Coastguard Worker * tep_filter_add_filter_str() API as called,it will print the filter string
385*436bf2bcSAndroid Build Coastguard Worker * instead of adding it.
386*436bf2bcSAndroid Build Coastguard Worker */
tep_set_test_filters(struct tep_handle * tep,int test_filters)387*436bf2bcSAndroid Build Coastguard Worker void tep_set_test_filters(struct tep_handle *tep, int test_filters)
388*436bf2bcSAndroid Build Coastguard Worker {
389*436bf2bcSAndroid Build Coastguard Worker if (tep)
390*436bf2bcSAndroid Build Coastguard Worker tep->test_filters = test_filters;
391*436bf2bcSAndroid Build Coastguard Worker }
392