kfsw-services/src/event-parameters/event_table.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include <stdint.h> | ||
| 2 | |||
| 3 | #include <zephyr/sys/util.h> | ||
| 4 | |||
| 5 | #include <kfsw/services/event.h> | ||
| 6 | #include <kfsw/services/parameter.h> | ||
| 7 | |||
| 8 | /* Event record counters. */ | ||
| 9 | static uint32_t event_recorded; | ||
| 10 | static uint32_t event_rejected; | ||
| 11 | static uint32_t event_overwritten; | ||
| 12 | static uint16_t event_held; | ||
| 13 | static uint16_t event_capacity; | ||
| 14 | |||
| 15 | 6 | static void sample_stats(void) | |
| 16 | { | ||
| 17 | struct kfsw_event_stats stats; | ||
| 18 | |||
| 19 | 6 | kfsw_event_get_stats(&stats); | |
| 20 | 6 | event_recorded = stats.recorded; | |
| 21 | 6 | event_rejected = stats.rejected; | |
| 22 | 6 | event_overwritten = stats.overwritten; | |
| 23 | 6 | event_held = stats.held; | |
| 24 | 6 | event_capacity = stats.capacity; | |
| 25 | 6 | } | |
| 26 | |||
| 27 | 4 | static void sample_recorded(void *value) | |
| 28 | { | ||
| 29 | 4 | sample_stats(); | |
| 30 | 4 | *(uint32_t *)value = event_recorded; | |
| 31 | 4 | } | |
| 32 | |||
| 33 | ✗ | static void sample_rejected(void *value) | |
| 34 | { | ||
| 35 | ✗ | sample_stats(); | |
| 36 | ✗ | *(uint32_t *)value = event_rejected; | |
| 37 | ✗ | } | |
| 38 | |||
| 39 | ✗ | static void sample_overwritten(void *value) | |
| 40 | { | ||
| 41 | ✗ | sample_stats(); | |
| 42 | ✗ | *(uint32_t *)value = event_overwritten; | |
| 43 | ✗ | } | |
| 44 | |||
| 45 | ✗ | static void sample_held(void *value) | |
| 46 | { | ||
| 47 | ✗ | sample_stats(); | |
| 48 | ✗ | *(uint16_t *)value = event_held; | |
| 49 | ✗ | } | |
| 50 | |||
| 51 | 2 | static void sample_capacity(void *value) | |
| 52 | { | ||
| 53 | 2 | sample_stats(); | |
| 54 | 2 | *(uint16_t *)value = event_capacity; | |
| 55 | 2 | } | |
| 56 | |||
| 57 | static const struct kfsw_param_definition event_param_definitions[] = { | ||
| 58 | { | ||
| 59 | .offset = 0x00U, | ||
| 60 | .type = KFSW_PARAM_U32, | ||
| 61 | .flags = KFSW_PARAM_FLAG_READ_ONLY, | ||
| 62 | .name = "events_recorded", | ||
| 63 | .description = "Events accepted since start", | ||
| 64 | .value = &event_recorded, | ||
| 65 | .sample = sample_recorded, | ||
| 66 | }, | ||
| 67 | { | ||
| 68 | .offset = 0x04U, | ||
| 69 | .type = KFSW_PARAM_U32, | ||
| 70 | .flags = KFSW_PARAM_FLAG_READ_ONLY, | ||
| 71 | .name = "events_overwritten", | ||
| 72 | .description = "Events lost to the ring wrapping before they were read", | ||
| 73 | .value = &event_overwritten, | ||
| 74 | .sample = sample_overwritten, | ||
| 75 | }, | ||
| 76 | { | ||
| 77 | .offset = 0x08U, | ||
| 78 | .type = KFSW_PARAM_U32, | ||
| 79 | .flags = KFSW_PARAM_FLAG_READ_ONLY, | ||
| 80 | .name = "events_rejected", | ||
| 81 | .description = "Events refused for an invalid payload size or source", | ||
| 82 | .value = &event_rejected, | ||
| 83 | .sample = sample_rejected, | ||
| 84 | }, | ||
| 85 | { | ||
| 86 | .offset = 0x0cU, | ||
| 87 | .type = KFSW_PARAM_U16, | ||
| 88 | .flags = KFSW_PARAM_FLAG_READ_ONLY, | ||
| 89 | .name = "events_held", | ||
| 90 | .description = "Records currently in the ring", | ||
| 91 | .value = &event_held, | ||
| 92 | .sample = sample_held, | ||
| 93 | }, | ||
| 94 | { | ||
| 95 | .offset = 0x0eU, | ||
| 96 | .type = KFSW_PARAM_U16, | ||
| 97 | .flags = KFSW_PARAM_FLAG_READ_ONLY, | ||
| 98 | .name = "events_capacity", | ||
| 99 | .description = "Ring capacity", | ||
| 100 | .value = &event_capacity, | ||
| 101 | .sample = sample_capacity, | ||
| 102 | }, | ||
| 103 | }; | ||
| 104 | |||
| 105 | KFSW_PARAM_TABLE_FITS_THE_LINK(event_param_definitions); | ||
| 106 | |||
| 107 | const struct kfsw_param_definition_set kfsw_event_param_definitions = { | ||
| 108 | .table = KFSW_EVENT_PARAM_TABLE_ID, | ||
| 109 | .name = KFSW_EVENT_PARAM_TABLE_NAME, | ||
| 110 | .description = "Event record counters", | ||
| 111 | .definitions = event_param_definitions, | ||
| 112 | .count = ARRAY_SIZE(event_param_definitions), | ||
| 113 | }; | ||
| 114 |