[b06e68ef] | 1 | /* |
---|
| 2 | * Print misc stuff for the monitor dump routines |
---|
| 3 | * Each routine returns the number of characters it output. |
---|
| 4 | * |
---|
| 5 | * TODO: |
---|
| 6 | * |
---|
| 7 | * $Id$ |
---|
| 8 | */ |
---|
| 9 | |
---|
[550c3df7] | 10 | #ifdef HAVE_CONFIG_H |
---|
| 11 | #include "config.h" |
---|
| 12 | #endif |
---|
| 13 | |
---|
[b06e68ef] | 14 | #include <rtems.h> |
---|
[5beb562] | 15 | #include <rtems/monitor.h> |
---|
[b06e68ef] | 16 | |
---|
| 17 | #include <rtems/assoc.h> |
---|
| 18 | |
---|
| 19 | #include <stdio.h> |
---|
| 20 | #include <ctype.h> |
---|
[cbd849c] | 21 | #include <inttypes.h> |
---|
[b06e68ef] | 22 | |
---|
| 23 | void |
---|
| 24 | rtems_monitor_separator(void) |
---|
| 25 | { |
---|
[714f06c] | 26 | fprintf(stdout,"------------------------------------------------------------------------------\n"); |
---|
[b06e68ef] | 27 | } |
---|
| 28 | |
---|
[aed742c] | 29 | uint32_t |
---|
[b06e68ef] | 30 | rtems_monitor_pad( |
---|
[3e08d4e] | 31 | uint32_t destination_column, |
---|
| 32 | uint32_t current_column |
---|
[b06e68ef] | 33 | ) |
---|
| 34 | { |
---|
| 35 | int pad_length; |
---|
[aed742c] | 36 | |
---|
[b06e68ef] | 37 | if (destination_column <= current_column) |
---|
| 38 | pad_length = 1; |
---|
| 39 | else |
---|
| 40 | pad_length = destination_column - current_column; |
---|
| 41 | |
---|
[714f06c] | 42 | return fprintf(stdout,"%*s", pad_length, ""); |
---|
[b06e68ef] | 43 | } |
---|
| 44 | |
---|
[c182e2d] | 45 | int |
---|
[3e08d4e] | 46 | rtems_monitor_dump_decimal(uint32_t num) |
---|
[b06e68ef] | 47 | { |
---|
[cbd849c] | 48 | return fprintf(stdout,"%4" PRId32, num); |
---|
[b06e68ef] | 49 | } |
---|
| 50 | |
---|
[5b331cc5] | 51 | int |
---|
| 52 | rtems_monitor_dump_addr(void *addr) |
---|
| 53 | { |
---|
| 54 | return fprintf(stdout,"0x%p", addr); |
---|
| 55 | } |
---|
| 56 | |
---|
[c182e2d] | 57 | int |
---|
[3e08d4e] | 58 | rtems_monitor_dump_hex(uint32_t num) |
---|
[b06e68ef] | 59 | { |
---|
[cbd849c] | 60 | return fprintf(stdout,"0x%" PRIx32, num); |
---|
[b06e68ef] | 61 | } |
---|
| 62 | |
---|
[c182e2d] | 63 | int |
---|
[b06e68ef] | 64 | rtems_monitor_dump_assoc_bitfield( |
---|
[e41eaa88] | 65 | const rtems_assoc_t *ap, |
---|
| 66 | const char *separator, |
---|
[3e08d4e] | 67 | uint32_t value |
---|
[b06e68ef] | 68 | ) |
---|
[aed742c] | 69 | { |
---|
[3e08d4e] | 70 | uint32_t b; |
---|
| 71 | uint32_t length = 0; |
---|
[c64e4ed4] | 72 | const char *name; |
---|
[b06e68ef] | 73 | |
---|
| 74 | for (b = 1; b; b <<= 1) |
---|
| 75 | if (b & value) |
---|
| 76 | { |
---|
| 77 | if (length) |
---|
[714f06c] | 78 | length += fprintf(stdout,"%s", separator); |
---|
[b06e68ef] | 79 | |
---|
| 80 | name = rtems_assoc_name_by_local(ap, b); |
---|
[aed742c] | 81 | |
---|
[b06e68ef] | 82 | if (name) |
---|
[714f06c] | 83 | length += fprintf(stdout,"%s", name); |
---|
[b06e68ef] | 84 | else |
---|
[cbd849c] | 85 | length += fprintf(stdout,"0x%" PRIx32, b); |
---|
[b06e68ef] | 86 | } |
---|
[aed742c] | 87 | |
---|
[b06e68ef] | 88 | return length; |
---|
| 89 | } |
---|
| 90 | |
---|
[c182e2d] | 91 | int |
---|
[b06e68ef] | 92 | rtems_monitor_dump_id(rtems_id id) |
---|
| 93 | { |
---|
[aac23ec7] | 94 | #if defined(RTEMS_USE_16_BIT_OBJECT) |
---|
| 95 | return fprintf(stdout,"%08" PRIx16, id); |
---|
| 96 | #else |
---|
[cbd849c] | 97 | return fprintf(stdout,"%08" PRIx32, id); |
---|
[aac23ec7] | 98 | #endif |
---|
[b06e68ef] | 99 | } |
---|
| 100 | |
---|
[c182e2d] | 101 | int |
---|
[bd5762d] | 102 | rtems_monitor_dump_name(rtems_id id) |
---|
[b06e68ef] | 103 | { |
---|
[bd5762d] | 104 | char name_buffer[18]; |
---|
| 105 | |
---|
[0893220] | 106 | rtems_object_get_name( id, sizeof(name_buffer), name_buffer ); |
---|
[bd5762d] | 107 | |
---|
| 108 | return fprintf( stdout, name_buffer ); |
---|
[b06e68ef] | 109 | } |
---|
| 110 | |
---|
[c182e2d] | 111 | int |
---|
[b06e68ef] | 112 | rtems_monitor_dump_priority(rtems_task_priority priority) |
---|
| 113 | { |
---|
[cbd849c] | 114 | return fprintf(stdout,"%3" PRId32, priority); |
---|
[b06e68ef] | 115 | } |
---|
| 116 | |
---|
| 117 | |
---|
[e41eaa88] | 118 | static const rtems_assoc_t rtems_monitor_state_assoc[] = { |
---|
[bd5b34e5] | 119 | { "DORM", STATES_DORMANT, 0 }, |
---|
| 120 | { "SUSP", STATES_SUSPENDED, 0 }, |
---|
| 121 | { "TRANS", STATES_TRANSIENT, 0 }, |
---|
| 122 | { "DELAY", STATES_DELAYING, 0 }, |
---|
| 123 | { "Wtime", STATES_WAITING_FOR_TIME, 0 }, |
---|
| 124 | { "Wbuf", STATES_WAITING_FOR_BUFFER, 0 }, |
---|
| 125 | { "Wseg", STATES_WAITING_FOR_SEGMENT, 0 }, |
---|
| 126 | { "Wmsg" , STATES_WAITING_FOR_MESSAGE, 0 }, |
---|
| 127 | { "Wevnt", STATES_WAITING_FOR_EVENT, 0 }, |
---|
| 128 | { "Wsem", STATES_WAITING_FOR_SEMAPHORE, 0 }, |
---|
| 129 | { "Wmutex", STATES_WAITING_FOR_MUTEX, 0 }, |
---|
| 130 | { "Wcvar", STATES_WAITING_FOR_CONDITION_VARIABLE, 0 }, |
---|
| 131 | { "Wjatx", STATES_WAITING_FOR_JOIN_AT_EXIT, 0 }, |
---|
| 132 | { "Wrpc", STATES_WAITING_FOR_RPC_REPLY, 0 }, |
---|
| 133 | { "WRATE", STATES_WAITING_FOR_PERIOD, 0 }, |
---|
| 134 | { "Wsig", STATES_WAITING_FOR_SIGNAL, 0 }, |
---|
| 135 | { "Wbar", STATES_WAITING_FOR_BARRIER, 0 }, |
---|
| 136 | { "Wrwlk", STATES_WAITING_FOR_RWLOCK, 0 }, |
---|
| 137 | { "Wisig", STATES_INTERRUPTIBLE_BY_SIGNAL, 0 }, |
---|
[b06e68ef] | 138 | { 0, 0, 0 }, |
---|
| 139 | }; |
---|
| 140 | |
---|
[c182e2d] | 141 | int |
---|
[b06e68ef] | 142 | rtems_monitor_dump_state(States_Control state) |
---|
| 143 | { |
---|
[c182e2d] | 144 | int length = 0; |
---|
[b06e68ef] | 145 | |
---|
| 146 | if (state == STATES_READY) /* assoc doesn't deal with this as it is 0 */ |
---|
[714f06c] | 147 | length += fprintf(stdout,"READY"); |
---|
[aed742c] | 148 | |
---|
[b06e68ef] | 149 | length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_state_assoc, |
---|
| 150 | ":", |
---|
| 151 | state); |
---|
| 152 | return length; |
---|
| 153 | } |
---|
| 154 | |
---|
[e41eaa88] | 155 | static const rtems_assoc_t rtems_monitor_attribute_assoc[] = { |
---|
[bd5b34e5] | 156 | { "GL", RTEMS_GLOBAL, 0 }, |
---|
| 157 | { "PR", RTEMS_PRIORITY, 0 }, |
---|
| 158 | { "FL", RTEMS_FLOATING_POINT, 0 }, |
---|
| 159 | { "BI", RTEMS_BINARY_SEMAPHORE, 0 }, |
---|
| 160 | { "SB", RTEMS_SIMPLE_BINARY_SEMAPHORE, 0 }, |
---|
| 161 | { "IN", RTEMS_INHERIT_PRIORITY, 0 }, |
---|
| 162 | { "CE", RTEMS_PRIORITY_CEILING, 0 }, |
---|
| 163 | { "AR", RTEMS_BARRIER_AUTOMATIC_RELEASE, 0 }, |
---|
| 164 | { "ST", RTEMS_SYSTEM_TASK, 0 }, |
---|
[b06e68ef] | 165 | { 0, 0, 0 }, |
---|
| 166 | }; |
---|
| 167 | |
---|
[c182e2d] | 168 | int |
---|
[b06e68ef] | 169 | rtems_monitor_dump_attributes(rtems_attribute attributes) |
---|
| 170 | { |
---|
[c182e2d] | 171 | int length = 0; |
---|
[b06e68ef] | 172 | |
---|
| 173 | if (attributes == RTEMS_DEFAULT_ATTRIBUTES) /* value is 0 */ |
---|
[714f06c] | 174 | length += fprintf(stdout,"DEFAULT"); |
---|
[aed742c] | 175 | |
---|
[b06e68ef] | 176 | length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_attribute_assoc, |
---|
| 177 | ":", |
---|
| 178 | attributes); |
---|
| 179 | return length; |
---|
| 180 | } |
---|
| 181 | |
---|
[e41eaa88] | 182 | static const rtems_assoc_t rtems_monitor_modes_assoc[] = { |
---|
[bd5b34e5] | 183 | { "nP", RTEMS_NO_PREEMPT, 0 }, |
---|
| 184 | { "T", RTEMS_TIMESLICE, 0 }, |
---|
| 185 | { "nA", RTEMS_NO_ASR, 0 }, |
---|
[b06e68ef] | 186 | { 0, 0, 0 }, |
---|
| 187 | }; |
---|
| 188 | |
---|
[c182e2d] | 189 | int |
---|
[b06e68ef] | 190 | rtems_monitor_dump_modes(rtems_mode modes) |
---|
| 191 | { |
---|
[3e08d4e] | 192 | uint32_t length = 0; |
---|
[b06e68ef] | 193 | |
---|
| 194 | if (modes == RTEMS_DEFAULT_MODES) /* value is 0 */ |
---|
[714f06c] | 195 | length += fprintf(stdout,"P:T:nA"); |
---|
[aed742c] | 196 | |
---|
[b06e68ef] | 197 | length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_modes_assoc, |
---|
| 198 | ":", |
---|
| 199 | modes); |
---|
| 200 | return length; |
---|
| 201 | } |
---|
| 202 | |
---|
[e41eaa88] | 203 | static const rtems_assoc_t rtems_monitor_events_assoc[] = { |
---|
[bd5b34e5] | 204 | { "0", RTEMS_EVENT_0, 0 }, |
---|
| 205 | { "1", RTEMS_EVENT_1, 0 }, |
---|
| 206 | { "2", RTEMS_EVENT_2, 0 }, |
---|
| 207 | { "3", RTEMS_EVENT_3, 0 }, |
---|
| 208 | { "4", RTEMS_EVENT_4, 0 }, |
---|
| 209 | { "5", RTEMS_EVENT_5, 0 }, |
---|
| 210 | { "6", RTEMS_EVENT_6, 0 }, |
---|
| 211 | { "7", RTEMS_EVENT_7, 0 }, |
---|
| 212 | { "8", RTEMS_EVENT_8, 0 }, |
---|
| 213 | { "9", RTEMS_EVENT_9, 0 }, |
---|
| 214 | { "10", RTEMS_EVENT_10, 0 }, |
---|
| 215 | { "11", RTEMS_EVENT_11, 0 }, |
---|
| 216 | { "12", RTEMS_EVENT_12, 0 }, |
---|
| 217 | { "13", RTEMS_EVENT_13, 0 }, |
---|
| 218 | { "14", RTEMS_EVENT_14, 0 }, |
---|
| 219 | { "15", RTEMS_EVENT_15, 0 }, |
---|
| 220 | { "16", RTEMS_EVENT_16, 0 }, |
---|
| 221 | { "17", RTEMS_EVENT_17, 0 }, |
---|
| 222 | { "18", RTEMS_EVENT_18, 0 }, |
---|
| 223 | { "19", RTEMS_EVENT_19, 0 }, |
---|
| 224 | { "20", RTEMS_EVENT_20, 0 }, |
---|
| 225 | { "21", RTEMS_EVENT_21, 0 }, |
---|
| 226 | { "22", RTEMS_EVENT_22, 0 }, |
---|
| 227 | { "23", RTEMS_EVENT_23, 0 }, |
---|
| 228 | { "24", RTEMS_EVENT_24, 0 }, |
---|
| 229 | { "25", RTEMS_EVENT_25, 0 }, |
---|
| 230 | { "26", RTEMS_EVENT_26, 0 }, |
---|
| 231 | { "27", RTEMS_EVENT_27, 0 }, |
---|
| 232 | { "28", RTEMS_EVENT_28, 0 }, |
---|
| 233 | { "29", RTEMS_EVENT_29, 0 }, |
---|
| 234 | { "30", RTEMS_EVENT_30, 0 }, |
---|
| 235 | { "31", RTEMS_EVENT_31, 0 }, |
---|
[b06e68ef] | 236 | { 0, 0, 0 }, |
---|
| 237 | }; |
---|
| 238 | |
---|
[c182e2d] | 239 | int |
---|
[b06e68ef] | 240 | rtems_monitor_dump_events(rtems_event_set events) |
---|
| 241 | { |
---|
| 242 | if (events == EVENT_SETS_NONE_PENDING) /* value is 0 */ |
---|
[bd5762d] | 243 | return fprintf(stdout," NONE "); |
---|
[aed742c] | 244 | |
---|
[bd5762d] | 245 | return fprintf(stdout,"%08" PRIx32, events); |
---|
[b06e68ef] | 246 | } |
---|
| 247 | |
---|
[c182e2d] | 248 | int |
---|
[3e08d4e] | 249 | rtems_monitor_dump_notepad(uint32_t *notepad) |
---|
[b06e68ef] | 250 | { |
---|
[c182e2d] | 251 | int length = 0; |
---|
[b06e68ef] | 252 | int i; |
---|
| 253 | |
---|
| 254 | for (i=0; i < RTEMS_NUMBER_NOTEPADS; i++) |
---|
| 255 | if (notepad[i]) |
---|
[cbd849c] | 256 | length += fprintf(stdout,"%d: 0x%" PRIx32, i, notepad[i]); |
---|
[b06e68ef] | 257 | |
---|
| 258 | return length; |
---|
| 259 | } |
---|