| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | #ifdef HAVE_CONFIG_H1 |
| 8 | #include "config.h" |
| 9 | #endif |
| 10 | |
| 11 | #include <rtems.h> |
| 12 | #include "monitor.h" |
| 13 | #include <rtems/rtems/attr.inl> |
| 14 | #include <stdio.h> |
| 15 | #include <string.h> /* memcpy() */ |
| 16 | |
| 17 | void |
| 18 | rtems_monitor_sema_canonical( |
| 19 | rtems_monitor_sema_t *canonical_sema, |
| 20 | void *sema_void |
| 21 | ) |
| 22 | { |
| 23 | Semaphore_Control *rtems_sema = (Semaphore_Control *) sema_void; |
| 24 | |
| 25 | canonical_sema->attribute = rtems_sema->attribute_set; |
| 26 | canonical_sema->priority_ceiling = |
| 27 | rtems_sema->Core_control.mutex.Attributes.priority_ceiling; |
| 28 | |
| 29 | canonical_sema->holder_id = |
| 30 | rtems_sema->Core_control.mutex.holder_id; |
| 31 | |
| 32 | if (_Attributes_Is_counting_semaphore(canonical_sema->attribute)) { |
| 33 | |
| 34 | canonical_sema->cur_count = |
| 35 | rtems_sema->Core_control.semaphore.count; |
| 36 | |
| 37 | canonical_sema->max_count = |
| 38 | rtems_sema->Core_control.semaphore.Attributes.maximum_count; |
| 39 | } |
| 40 | else { |
| 41 | |
| 42 | canonical_sema->cur_count = rtems_sema->Core_control.mutex.lock; |
| 43 | canonical_sema->max_count = 1; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | |
| 48 | void |
| 49 | rtems_monitor_sema_dump_header( |
| 50 | bool_Bool verbose __attribute__((unused)) |
| 51 | ) |
| 52 | { |
| 53 | printf("\ |
| 54 | ID NAME ATTR PRICEIL CURR_CNT HOLDID \n"); |
| 55 | |
| 56 | |
| 57 | |
| 58 | rtems_monitor_separator(); |
| 59 | } |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | void |
| 65 | rtems_monitor_sema_dump( |
| 66 | rtems_monitor_sema_t *monitor_sema, |
| 67 | bool_Bool verbose __attribute__((unused)) |
| 68 | ) |
| 69 | { |
| 70 | int length = 0; |
| 71 | |
| 72 | length += rtems_monitor_dump_id(monitor_sema->id); |
| 73 | length += rtems_monitor_pad(11, length); |
| 74 | length += rtems_monitor_dump_name(monitor_sema->id); |
| 75 | length += rtems_monitor_pad(18, length); |
| 76 | length += rtems_monitor_dump_attributes(monitor_sema->attribute); |
| 77 | length += rtems_monitor_pad(30, length); |
| 78 | length += rtems_monitor_dump_priority(monitor_sema->priority_ceiling); |
| 79 | length += rtems_monitor_pad(38, length); |
| 80 | length += rtems_monitor_dump_decimal(monitor_sema->cur_count); |
| 81 | length += rtems_monitor_pad(47, length); |
| 82 | length += rtems_monitor_dump_id(monitor_sema->holder_id); |
| Value stored to 'length' is never read |
| 83 | printf("\n"); |
| 84 | } |