Home | History | Annotate | Download | only in traceevent

Lines Matching defs:kbuf

72 	unsigned long long (*read_long)(struct kbuffer *kbuf, void *ptr);
73 int (*next_event)(struct kbuffer *kbuf);
90 static int do_swap(struct kbuffer *kbuf)
92 return ((kbuf->flags & KBUFFER_FL_HOST_BIG_ENDIAN) + kbuf->flags) &
140 static unsigned long long read_8(struct kbuffer *kbuf, void *ptr)
142 return kbuf->read_8(ptr);
145 static unsigned int read_4(struct kbuffer *kbuf, void *ptr)
147 return kbuf->read_4(ptr);
150 static unsigned long long __read_long_8(struct kbuffer *kbuf, void *ptr)
152 return kbuf->read_8(ptr);
155 static unsigned long long __read_long_4(struct kbuffer *kbuf, void *ptr)
157 return kbuf->read_4(ptr);
160 static unsigned long long read_long(struct kbuffer *kbuf, void *ptr)
162 return kbuf->read_long(kbuf, ptr);
165 static int calc_index(struct kbuffer *kbuf, void *ptr)
167 return (unsigned long)ptr - (unsigned long)kbuf->data;
170 static int __next_event(struct kbuffer *kbuf);
182 struct kbuffer *kbuf;
205 kbuf = zmalloc(sizeof(*kbuf));
206 if (!kbuf)
209 kbuf->flags = flags;
212 kbuf->flags |= KBUFFER_FL_HOST_BIG_ENDIAN;
214 if (do_swap(kbuf)) {
215 kbuf->read_8 = __read_8_sw;
216 kbuf->read_4 = __read_4_sw;
218 kbuf->read_8 = __read_8;
219 kbuf->read_4 = __read_4;
222 if (kbuf->flags & KBUFFER_FL_LONG_8)
223 kbuf->read_long = __read_long_8;
225 kbuf->read_long = __read_long_4;
228 kbuf->next_event = __next_event;
230 return kbuf;
234 * @kbuf: The kbuffer to free
238 void kbuffer_free(struct kbuffer *kbuf)
240 free(kbuf);
243 static unsigned int type4host(struct kbuffer *kbuf,
246 if (kbuf->flags & KBUFFER_FL_BIG_ENDIAN)
252 static unsigned int len4host(struct kbuffer *kbuf,
255 if (kbuf->flags & KBUFFER_FL_BIG_ENDIAN)
261 static unsigned int type_len4host(struct kbuffer *kbuf,
264 if (kbuf->flags & KBUFFER_FL_BIG_ENDIAN)
270 static unsigned int ts4host(struct kbuffer *kbuf,
273 if (kbuf->flags & KBUFFER_FL_BIG_ENDIAN)
290 static unsigned int old_update_pointers(struct kbuffer *kbuf)
298 void *ptr = kbuf->data + kbuf->curr;
300 type_len_ts = read_4(kbuf, ptr);
303 type = type4host(kbuf, type_len_ts);
304 len = len4host(kbuf, type_len_ts);
305 delta = ts4host(kbuf, type_len_ts);
309 kbuf->next = kbuf->size;
313 extend = read_4(kbuf, ptr);
322 kbuf->curr = kbuf->size;
323 kbuf->next = kbuf->size;
324 kbuf->index = kbuf->size;
330 length = read_4(kbuf, ptr);
337 kbuf->timestamp += delta;
338 kbuf->index = calc_index(kbuf, ptr);
339 kbuf->next = kbuf->index + length;
344 static int __old_next_event(struct kbuffer *kbuf)
349 kbuf->curr = kbuf->next;
350 if (kbuf->next >= kbuf->size)
352 type = old_update_pointers(kbuf);
359 translate_data(struct kbuffer *kbuf, void *data, void **rptr,
366 type_len_ts = read_4(kbuf, data);
369 type_len = type_len4host(kbuf, type_len_ts);
370 *delta = ts4host(kbuf, type_len_ts);
374 *length = read_4(kbuf, data);
379 extend = read_4(kbuf, data);
392 *length = read_4(kbuf, data) - 4;
406 static unsigned int update_pointers(struct kbuffer *kbuf)
411 void *ptr = kbuf->data + kbuf->curr;
413 type_len = translate_data(kbuf, ptr, &ptr, &delta, &length);
415 kbuf->timestamp += delta;
416 kbuf->index = calc_index(kbuf, ptr);
417 kbuf->next = kbuf->index + length;
435 struct kbuffer kbuf;
441 kbuf.read_8 = __read_8_sw;
442 kbuf.read_4 = __read_4_sw;
443 kbuf.flags = host_is_bigendian() ? 0 : KBUFFER_FL_BIG_ENDIAN;
445 kbuf.read_8 = __read_8;
446 kbuf.read_4 = __read_4;
447 kbuf.flags = host_is_bigendian() ? KBUFFER_FL_BIG_ENDIAN: 0;
450 type_len = translate_data(&kbuf, data, &ptr, &delta, &length);
463 static int __next_event(struct kbuffer *kbuf)
468 kbuf->curr = kbuf->next;
469 if (kbuf->next >= kbuf->size)
471 type = update_pointers(kbuf);
477 static int next_event(struct kbuffer *kbuf)
479 return kbuf->next_event(kbuf);
484 * @kbuf: The kbuffer to read
494 void *kbuffer_next_event(struct kbuffer *kbuf, unsigned long long *ts)
498 if (!kbuf || !kbuf->subbuffer)
501 ret = next_event(kbuf);
506 *ts = kbuf->timestamp;
508 return kbuf->data + kbuf->index;
513 * @kbuf: The kbuffer to load
514 * @subbuffer: The subbuffer to load into @kbuf.
516 * Load a new subbuffer (page) into @kbuf. This will reset all
517 * the pointers and update the @kbuf timestamp. The next read will
522 int kbuffer_load_subbuffer(struct kbuffer *kbuf, void *subbuffer)
527 if (!kbuf || !subbuffer)
530 kbuf->subbuffer = subbuffer;
532 kbuf->timestamp = read_8(kbuf, ptr);
535 kbuf->curr = 0;
537 if (kbuf->flags & KBUFFER_FL_LONG_8)
538 kbuf->start = 16;
540 kbuf->start = 12;
542 kbuf->data = subbuffer + kbuf->start;
544 flags = read_long(kbuf, ptr);
545 kbuf->size = (unsigned int)flags & COMMIT_MASK;
549 ptr = kbuf->data + kbuf->size;
550 kbuf->lost_events = read_long(kbuf, ptr);
552 kbuf->lost_events = -1;
554 kbuf->lost_events = 0;
556 kbuf->index = 0;
557 kbuf->next = 0;
559 next_event(kbuf);
566 * @kbuf: The kbuffer to read from
572 void *kbuffer_read_event(struct kbuffer *kbuf, unsigned long long *ts)
574 if (!kbuf || !kbuf->subbuffer)
577 if (kbuf->curr >= kbuf->size)
581 *ts = kbuf->timestamp;
582 return kbuf->data + kbuf->index;
587 * @kbuf: The kbuffer to read from
591 unsigned long long kbuffer_timestamp(struct kbuffer *kbuf)
593 return kbuf->timestamp;
598 * @kbuf: The kbuffer to read from
602 * The @offset must be an index from the @kbuf subbuffer beginning.
609 * Note, the kbuf timestamp and pointers are updated to the
614 void *kbuffer_read_at_offset(struct kbuffer *kbuf, int offset,
619 if (offset < kbuf->start)
622 offset -= kbuf->start;
625 kbuffer_load_subbuffer(kbuf, kbuf->subbuffer);
627 while (kbuf->curr < offset) {
628 data = kbuffer_next_event(kbuf, ts);
638 * @kbuf: The kbuffer to read from
644 int kbuffer_subbuffer_size(struct kbuffer *kbuf)
646 return kbuf->size;
651 * @kbuf: The kbuffer to read from
659 int kbuffer_curr_index(struct kbuffer *kbuf)
661 return kbuf->curr;
666 * @kbuf: The kbuffer to read from
671 int kbuffer_curr_offset(struct kbuffer *kbuf)
673 return kbuf->curr + kbuf->start;
678 * @kbuf: The kbuffer to read
683 int kbuffer_event_size(struct kbuffer *kbuf)
685 return kbuf->next - kbuf->index;
690 * @kbuf: The kbuffer to read
695 int kbuffer_curr_size(struct kbuffer *kbuf)
697 return kbuf->next - kbuf->curr;
702 * @kbuf
709 int kbuffer_missed_events(struct kbuffer *kbuf)
712 if (kbuf->curr)
715 return kbuf->lost_events;
720 * @kbuf: The kbuffer to set
727 void kbuffer_set_old_format(struct kbuffer *kbuf)
729 kbuf->flags |= KBUFFER_FL_OLD_FORMAT;
731 kbuf->next_event = __old_next_event;