| 1 | #ifndef _LTT_FACILITY_TESTS_H_ |
| 2 | #define _LTT_FACILITY_TESTS_H_ |
| 3 | |
| 4 | |
| 5 | #include <linux/types.h> |
| 6 | #include "ltt-facility-id-tests.h" |
| 7 | #include <ltt/ltt-tracer.h> |
| 8 | |
| 9 | #define ltt_get_index_from_facility_tests ltt_get_index_from_facility |
| 10 | |
| 11 | /* Named types */ |
| 12 | |
| 13 | /* Event write_4bytes structures */ |
| 14 | |
| 15 | /* Event write_4bytes logging function */ |
| 16 | static inline void trace_tests_write_4bytes( |
| 17 | unsigned int lttng_param_value) |
| 18 | { |
| 19 | unsigned int index; |
| 20 | struct ltt_channel_struct *channel; |
| 21 | struct ltt_trace_struct *trace; |
| 22 | void *transport_data; |
| 23 | char *buffer = NULL; |
| 24 | size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */ |
| 25 | size_t *to_base = &real_to_base; |
| 26 | size_t real_to = 0; |
| 27 | size_t *to = &real_to; |
| 28 | size_t real_len = 0; |
| 29 | size_t *len = &real_len; |
| 30 | size_t reserve_size; |
| 31 | size_t slot_size; |
| 32 | size_t align; |
| 33 | const char *real_from; |
| 34 | const char **from = &real_from; |
| 35 | u64 tsc; |
| 36 | size_t before_hdr_pad, after_hdr_pad, header_size; |
| 37 | |
| 38 | if (ltt_traces.num_active_traces == 0) |
| 39 | return; |
| 40 | |
| 41 | /* For each field, calculate the field size. */ |
| 42 | /* size = *to_base + *to + *len */ |
| 43 | /* Assume that the padding for alignment starts at a |
| 44 | * sizeof(void *) address. */ |
| 45 | |
| 46 | *from = (const char*)<tng_param_value; |
| 47 | align = sizeof(unsigned int); |
| 48 | |
| 49 | if (*len == 0) { |
| 50 | *to += ltt_align(*to, align); /* align output */ |
| 51 | } else { |
| 52 | *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ |
| 53 | } |
| 54 | |
| 55 | *len += sizeof(unsigned int); |
| 56 | |
| 57 | reserve_size = *to_base + *to + *len; |
| 58 | preempt_disable(); |
| 59 | ltt_nesting[smp_processor_id()]++; |
| 60 | index = ltt_get_index_from_facility_tests( event_tests_write_4bytes); |
| 61 | |
| 62 | list_for_each_entry_rcu(trace, <t_traces.head, list) { |
| 63 | if (!trace->active) |
| 64 | continue; |
| 65 | |
| 66 | channel = ltt_get_channel_from_index(trace, index); |
| 67 | |
| 68 | slot_size = 0; |
| 69 | buffer = ltt_reserve_slot(trace, channel, &transport_data, |
| 70 | reserve_size, &slot_size, &tsc, |
| 71 | &before_hdr_pad, &after_hdr_pad, &header_size); |
| 72 | if (!buffer) |
| 73 | continue; /* buffer full */ |
| 74 | |
| 75 | *to_base = *to = *len = 0; |
| 76 | |
| 77 | ltt_write_event_header(trace, channel, buffer, |
| 78 | ltt_facility_tests_CA7F1536, event_tests_write_4bytes, |
| 79 | reserve_size, before_hdr_pad, tsc); |
| 80 | *to_base += before_hdr_pad + after_hdr_pad + header_size; |
| 81 | |
| 82 | *from = (const char*)<tng_param_value; |
| 83 | align = sizeof(unsigned int); |
| 84 | |
| 85 | if (*len == 0) { |
| 86 | *to += ltt_align(*to, align); /* align output */ |
| 87 | } else { |
| 88 | *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */ |
| 89 | } |
| 90 | |
| 91 | *len += sizeof(unsigned int); |
| 92 | |
| 93 | /* Flush pending memcpy */ |
| 94 | if (*len != 0) { |
| 95 | memcpy(buffer+*to_base+*to, *from, *len); |
| 96 | *to += *len; |
| 97 | *len = 0; |
| 98 | } |
| 99 | |
| 100 | ltt_commit_slot(channel, &transport_data, buffer, slot_size); |
| 101 | |
| 102 | } |
| 103 | |
| 104 | ltt_nesting[smp_processor_id()]--; |
| 105 | preempt_enable_no_resched(); |
| 106 | } |
| 107 | |
| 108 | #endif //_LTT_FACILITY_TESTS_H_ |