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