source: rtems/cpukit/libmisc/monitor/mon-prmisc.c @ 17049c39

4.104.114.95
Last change on this file since 17049c39 was 17049c39, checked in by Joel Sherrill <joel.sherrill@…>, on 07/01/08 at 18:44:12

2008-07-01 Joel Sherrill <joel.sherrill@…>

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