File indexing completed on 2025-05-11 08:24:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #ifdef HAVE_CONFIG_H
0037 #include "config.h"
0038 #endif
0039
0040 #include <rtems.h>
0041 #include <rtems/monitor.h>
0042 #include <rtems/assoc.h>
0043
0044 #include <stdio.h>
0045 #include <ctype.h>
0046 #include <inttypes.h>
0047
0048 void
0049 rtems_monitor_separator(void)
0050 {
0051 fprintf(stdout,"------------------------------------------------------------------------------\n");
0052 }
0053
0054 uint32_t
0055 rtems_monitor_pad(
0056 uint32_t destination_column,
0057 uint32_t current_column
0058 )
0059 {
0060 int pad_length;
0061
0062 if (destination_column <= current_column)
0063 pad_length = 1;
0064 else
0065 pad_length = destination_column - current_column;
0066
0067 return fprintf(stdout,"%*s", pad_length, "");
0068 }
0069
0070 int
0071 rtems_monitor_dump_decimal(uint32_t num)
0072 {
0073 return fprintf(stdout,"%4" PRId32, num);
0074 }
0075
0076 int
0077 rtems_monitor_dump_addr(const void *addr)
0078 {
0079 return fprintf(stdout,"%08" PRIxPTR, (intptr_t) addr);
0080 }
0081
0082 int
0083 rtems_monitor_dump_hex(uint32_t num)
0084 {
0085 return fprintf(stdout,"0x%" PRIx32, num);
0086 }
0087
0088 static int
0089 rtems_monitor_dump_assoc_bitfield(
0090 const rtems_assoc_t *ap,
0091 const char *separator,
0092 uint32_t value
0093 )
0094 {
0095 uint32_t b;
0096 uint32_t length = 0;
0097 const char *name;
0098
0099 for (b = 1; b; b <<= 1)
0100 if (b & value)
0101 {
0102 if (length)
0103 length += fprintf(stdout,"%s", separator);
0104
0105 name = rtems_assoc_name_by_local(ap, b);
0106
0107 if (name)
0108 length += fprintf(stdout,"%s", name);
0109 else
0110 length += fprintf(stdout,"0x%" PRIx32, b);
0111 }
0112
0113 return length;
0114 }
0115
0116 int
0117 rtems_monitor_dump_id(rtems_id id)
0118 {
0119 return fprintf(stdout,"%08" PRIx32, id);
0120 }
0121
0122 int
0123 rtems_monitor_dump_name(rtems_id id)
0124 {
0125 char name_buffer[18] = "????";
0126
0127 rtems_object_get_name( id, sizeof(name_buffer), name_buffer );
0128
0129 return fprintf(stdout, "%s", name_buffer);
0130 }
0131
0132 int
0133 rtems_monitor_dump_priority(rtems_task_priority priority)
0134 {
0135 return fprintf(stdout,"%3" PRId32, priority);
0136 }
0137
0138 int
0139 rtems_monitor_dump_state(States_Control state)
0140 {
0141 char buf[16];
0142
0143 rtems_assoc_thread_states_to_string(state, buf, sizeof(buf));
0144 return fprintf(stdout, "%s", buf);
0145 }
0146
0147 static const rtems_assoc_t rtems_monitor_attribute_assoc[] = {
0148 { "GL", RTEMS_GLOBAL, 0 },
0149 { "PR", RTEMS_PRIORITY, 0 },
0150 { "FL", RTEMS_FLOATING_POINT, 0 },
0151 { "BI", RTEMS_BINARY_SEMAPHORE, 0 },
0152 { "SB", RTEMS_SIMPLE_BINARY_SEMAPHORE, 0 },
0153 { "IN", RTEMS_INHERIT_PRIORITY, 0 },
0154 { "CE", RTEMS_PRIORITY_CEILING, 0 },
0155 { "AR", RTEMS_BARRIER_AUTOMATIC_RELEASE, 0 },
0156 { "ST", RTEMS_SYSTEM_TASK, 0 },
0157 { 0, 0, 0 },
0158 };
0159
0160 int
0161 rtems_monitor_dump_attributes(rtems_attribute attributes)
0162 {
0163 int length = 0;
0164
0165 if (attributes == RTEMS_DEFAULT_ATTRIBUTES)
0166 length += fprintf(stdout,"DEFAULT");
0167
0168 length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_attribute_assoc,
0169 ":",
0170 attributes);
0171 return length;
0172 }
0173
0174 static const rtems_assoc_t rtems_monitor_modes_assoc[] = {
0175 { "nP", RTEMS_NO_PREEMPT, 0 },
0176 { "T", RTEMS_TIMESLICE, 0 },
0177 { "nA", RTEMS_NO_ASR, 0 },
0178 { 0, 0, 0 },
0179 };
0180
0181 int
0182 rtems_monitor_dump_modes(rtems_mode modes)
0183 {
0184 uint32_t length = 0;
0185
0186 if (modes == RTEMS_DEFAULT_MODES)
0187 length += fprintf(stdout,"P:T:nA");
0188
0189 length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_modes_assoc,
0190 ":",
0191 modes);
0192 return length;
0193 }
0194
0195 int
0196 rtems_monitor_dump_events(rtems_event_set events)
0197 {
0198 if (events == 0)
0199 return fprintf(stdout," NONE ");
0200
0201 return fprintf(stdout,"%08" PRIx32, events);
0202 }