source: rtems/cpukit/libmisc/monitor/mon-prmisc.c @ 1b65557

4.104.115
Last change on this file since 1b65557 was 5b331cc5, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/12/10 at 15:23:41

Add rtems_monitor_dump_addr().

  • Property mode set to 100644
File size: 6.4 KB
Line 
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#include <inttypes.h>
22
23void
24rtems_monitor_separator(void)
25{
26    fprintf(stdout,"------------------------------------------------------------------------------\n");
27}
28
29uint32_t
30rtems_monitor_pad(
31    uint32_t    destination_column,
32    uint32_t    current_column
33)
34{
35    int pad_length;
36
37    if (destination_column <= current_column)
38        pad_length = 1;
39    else
40        pad_length = destination_column - current_column;
41
42    return fprintf(stdout,"%*s", pad_length, "");
43}
44
45int
46rtems_monitor_dump_decimal(uint32_t   num)
47{
48    return fprintf(stdout,"%4" PRId32, num);
49}
50
51int
52rtems_monitor_dump_addr(void *addr)
53{
54    return fprintf(stdout,"0x%p", addr);
55}
56
57int
58rtems_monitor_dump_hex(uint32_t   num)
59{
60    return fprintf(stdout,"0x%" PRIx32, num);
61}
62
63int
64rtems_monitor_dump_assoc_bitfield(
65    const rtems_assoc_t *ap,
66    const char          *separator,
67    uint32_t       value
68  )
69{
70    uint32_t   b;
71    uint32_t   length = 0;
72    const char *name;
73
74    for (b = 1; b; b <<= 1)
75        if (b & value)
76        {
77            if (length)
78                length += fprintf(stdout,"%s", separator);
79
80            name = rtems_assoc_name_by_local(ap, b);
81
82            if (name)
83                length += fprintf(stdout,"%s", name);
84            else
85                length += fprintf(stdout,"0x%" PRIx32, b);
86        }
87
88    return length;
89}
90
91int
92rtems_monitor_dump_id(rtems_id id)
93{
94#if defined(RTEMS_USE_16_BIT_OBJECT)
95    return fprintf(stdout,"%08" PRIx16, id);
96#else
97    return fprintf(stdout,"%08" PRIx32, id);
98#endif
99}
100
101int
102rtems_monitor_dump_name(rtems_id id)
103{
104    char name_buffer[18];
105
106    rtems_object_get_name( id, sizeof(name_buffer), name_buffer );
107
108    return fprintf( stdout, name_buffer );
109}
110
111int
112rtems_monitor_dump_priority(rtems_task_priority priority)
113{
114    return fprintf(stdout,"%3" PRId32, priority);
115}
116
117
118static const rtems_assoc_t rtems_monitor_state_assoc[] = {
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 },
138    { 0, 0, 0 },
139};
140
141int
142rtems_monitor_dump_state(States_Control state)
143{
144    int   length = 0;
145
146    if (state == STATES_READY)  /* assoc doesn't deal with this as it is 0 */
147        length += fprintf(stdout,"READY");
148
149    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_state_assoc,
150                                                ":",
151                                                state);
152    return length;
153}
154
155static const rtems_assoc_t rtems_monitor_attribute_assoc[] = {
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 },
165    { 0, 0, 0 },
166};
167
168int
169rtems_monitor_dump_attributes(rtems_attribute attributes)
170{
171    int   length = 0;
172
173    if (attributes == RTEMS_DEFAULT_ATTRIBUTES)  /* value is 0 */
174        length += fprintf(stdout,"DEFAULT");
175
176    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_attribute_assoc,
177                                                ":",
178                                                attributes);
179    return length;
180}
181
182static const rtems_assoc_t rtems_monitor_modes_assoc[] = {
183    { "nP",     RTEMS_NO_PREEMPT, 0 },
184    { "T",      RTEMS_TIMESLICE, 0 },
185    { "nA",     RTEMS_NO_ASR, 0 },
186    { 0, 0, 0 },
187};
188
189int
190rtems_monitor_dump_modes(rtems_mode modes)
191{
192    uint32_t   length = 0;
193
194    if (modes == RTEMS_DEFAULT_MODES)  /* value is 0 */
195        length += fprintf(stdout,"P:T:nA");
196
197    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_modes_assoc,
198                                                ":",
199                                                modes);
200    return length;
201}
202
203static const rtems_assoc_t rtems_monitor_events_assoc[] = {
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 },
236    { 0, 0, 0 },
237};
238
239int
240rtems_monitor_dump_events(rtems_event_set events)
241{
242    if (events == EVENT_SETS_NONE_PENDING)  /* value is 0 */
243        return fprintf(stdout,"  NONE  ");
244
245    return fprintf(stdout,"%08" PRIx32, events);
246}
247
248int
249rtems_monitor_dump_notepad(uint32_t   *notepad)
250{
251    int   length = 0;
252    int i;
253
254    for (i=0; i < RTEMS_NUMBER_NOTEPADS; i++)
255        if (notepad[i])
256            length += fprintf(stdout,"%d: 0x%" PRIx32, i, notepad[i]);
257
258    return length;
259}
Note: See TracBrowser for help on using the repository browser.