0001
0002
0003
0004
0005
0006
0007 #include "event-parse.h"
0008 #include "event-parse-local.h"
0009 #include "event-utils.h"
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 struct tep_event *tep_get_event(struct tep_handle *tep, int index)
0020 {
0021 if (tep && tep->events && index < tep->nr_events)
0022 return tep->events[index];
0023
0024 return NULL;
0025 }
0026
0027
0028
0029
0030
0031
0032
0033
0034 struct tep_event *tep_get_first_event(struct tep_handle *tep)
0035 {
0036 return tep_get_event(tep, 0);
0037 }
0038
0039
0040
0041
0042
0043
0044
0045
0046 int tep_get_events_count(struct tep_handle *tep)
0047 {
0048 if (tep)
0049 return tep->nr_events;
0050 return 0;
0051 }
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061 void tep_set_flag(struct tep_handle *tep, int flag)
0062 {
0063 if (tep)
0064 tep->flags |= flag;
0065 }
0066
0067
0068
0069
0070
0071
0072
0073
0074 void tep_clear_flag(struct tep_handle *tep, enum tep_flag flag)
0075 {
0076 if (tep)
0077 tep->flags &= ~flag;
0078 }
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088 bool tep_test_flag(struct tep_handle *tep, enum tep_flag flag)
0089 {
0090 if (tep)
0091 return tep->flags & flag;
0092 return false;
0093 }
0094
0095 __hidden unsigned short data2host2(struct tep_handle *tep, unsigned short data)
0096 {
0097 unsigned short swap;
0098
0099 if (!tep || tep->host_bigendian == tep->file_bigendian)
0100 return data;
0101
0102 swap = ((data & 0xffULL) << 8) |
0103 ((data & (0xffULL << 8)) >> 8);
0104
0105 return swap;
0106 }
0107
0108 __hidden unsigned int data2host4(struct tep_handle *tep, unsigned int data)
0109 {
0110 unsigned int swap;
0111
0112 if (!tep || tep->host_bigendian == tep->file_bigendian)
0113 return data;
0114
0115 swap = ((data & 0xffULL) << 24) |
0116 ((data & (0xffULL << 8)) << 8) |
0117 ((data & (0xffULL << 16)) >> 8) |
0118 ((data & (0xffULL << 24)) >> 24);
0119
0120 return swap;
0121 }
0122
0123 __hidden unsigned long long
0124 data2host8(struct tep_handle *tep, unsigned long long data)
0125 {
0126 unsigned long long swap;
0127
0128 if (!tep || tep->host_bigendian == tep->file_bigendian)
0129 return data;
0130
0131 swap = ((data & 0xffULL) << 56) |
0132 ((data & (0xffULL << 8)) << 40) |
0133 ((data & (0xffULL << 16)) << 24) |
0134 ((data & (0xffULL << 24)) << 8) |
0135 ((data & (0xffULL << 32)) >> 8) |
0136 ((data & (0xffULL << 40)) >> 24) |
0137 ((data & (0xffULL << 48)) >> 40) |
0138 ((data & (0xffULL << 56)) >> 56);
0139
0140 return swap;
0141 }
0142
0143
0144
0145
0146
0147
0148
0149
0150 int tep_get_header_page_size(struct tep_handle *tep)
0151 {
0152 if (tep)
0153 return tep->header_page_size_size;
0154 return 0;
0155 }
0156
0157
0158
0159
0160
0161
0162
0163
0164 int tep_get_header_timestamp_size(struct tep_handle *tep)
0165 {
0166 if (tep)
0167 return tep->header_page_ts_size;
0168 return 0;
0169 }
0170
0171
0172
0173
0174
0175
0176
0177
0178 int tep_get_cpus(struct tep_handle *tep)
0179 {
0180 if (tep)
0181 return tep->cpus;
0182 return 0;
0183 }
0184
0185
0186
0187
0188
0189
0190
0191 void tep_set_cpus(struct tep_handle *tep, int cpus)
0192 {
0193 if (tep)
0194 tep->cpus = cpus;
0195 }
0196
0197
0198
0199
0200
0201
0202
0203
0204 int tep_get_long_size(struct tep_handle *tep)
0205 {
0206 if (tep)
0207 return tep->long_size;
0208 return 0;
0209 }
0210
0211
0212
0213
0214
0215
0216
0217
0218 void tep_set_long_size(struct tep_handle *tep, int long_size)
0219 {
0220 if (tep)
0221 tep->long_size = long_size;
0222 }
0223
0224
0225
0226
0227
0228
0229
0230
0231 int tep_get_page_size(struct tep_handle *tep)
0232 {
0233 if (tep)
0234 return tep->page_size;
0235 return 0;
0236 }
0237
0238
0239
0240
0241
0242
0243
0244
0245 void tep_set_page_size(struct tep_handle *tep, int _page_size)
0246 {
0247 if (tep)
0248 tep->page_size = _page_size;
0249 }
0250
0251
0252
0253
0254
0255
0256
0257
0258 bool tep_is_file_bigendian(struct tep_handle *tep)
0259 {
0260 if (tep)
0261 return (tep->file_bigendian == TEP_BIG_ENDIAN);
0262 return false;
0263 }
0264
0265
0266
0267
0268
0269
0270
0271
0272 void tep_set_file_bigendian(struct tep_handle *tep, enum tep_endian endian)
0273 {
0274 if (tep)
0275 tep->file_bigendian = endian;
0276 }
0277
0278
0279
0280
0281
0282
0283
0284
0285 bool tep_is_local_bigendian(struct tep_handle *tep)
0286 {
0287 if (tep)
0288 return (tep->host_bigendian == TEP_BIG_ENDIAN);
0289 return 0;
0290 }
0291
0292
0293
0294
0295
0296
0297
0298
0299 void tep_set_local_bigendian(struct tep_handle *tep, enum tep_endian endian)
0300 {
0301 if (tep)
0302 tep->host_bigendian = endian;
0303 }
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313 bool tep_is_old_format(struct tep_handle *tep)
0314 {
0315 if (tep)
0316 return tep->old_format;
0317 return false;
0318 }
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329 void tep_set_test_filters(struct tep_handle *tep, int test_filters)
0330 {
0331 if (tep)
0332 tep->test_filters = test_filters;
0333 }