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

4.104.114.84.95
Last change on this file since a29d2e7 was cbd849c, checked in by Ralf Corsepius <ralf.corsepius@…>, on 11/01/04 at 13:14:33

2004-11-01 Ralf Corsepius <ralf_corsepius@…>

  • monitor/monitor.h: Let rtems_monitor_config_dump return int.
  • monitor/mon-config.c: Ditto. Use PRI*N macros.
  • monitor/mon-itask.c, monitor/mon-prmisc.c: Use PRI*N macros.
  • Property mode set to 100644
File size: 6.3 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", 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    { "Wbuf",   STATES_WAITING_FOR_BUFFER },
135    { "Wseg",   STATES_WAITING_FOR_SEGMENT },
136    { "Wmsg" ,  STATES_WAITING_FOR_MESSAGE },
137    { "Wevnt",  STATES_WAITING_FOR_EVENT },
138    { "Wsem",   STATES_WAITING_FOR_SEMAPHORE },
139    { "Wtime",  STATES_WAITING_FOR_TIME },
140    { "Wrpc",   STATES_WAITING_FOR_RPC_REPLY },
141    { "Wmutex", STATES_WAITING_FOR_MUTEX },
142    { "Wcvar",  STATES_WAITING_FOR_CONDITION_VARIABLE },
143    { "Wjatx",  STATES_WAITING_FOR_JOIN_AT_EXIT },
144    { "Wsig",   STATES_WAITING_FOR_SIGNAL },
145    { "WRATE",  STATES_WAITING_FOR_PERIOD },
146    { "Wisig",  STATES_INTERRUPTIBLE_BY_SIGNAL },
147    { 0, 0, 0 },
148};
149
150int
151rtems_monitor_dump_state(States_Control state)
152{
153    int   length = 0;
154
155    if (state == STATES_READY)  /* assoc doesn't deal with this as it is 0 */
156        length += fprintf(stdout,"READY");
157
158    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_state_assoc,
159                                                ":",
160                                                state);
161    return length;
162}
163
164rtems_assoc_t rtems_monitor_attribute_assoc[] = {
165    { "FL",  RTEMS_FLOATING_POINT },
166    { "GL",  RTEMS_GLOBAL },
167    { "PR",  RTEMS_PRIORITY },
168    { "BI",  RTEMS_BINARY_SEMAPHORE },
169    { "IN",  RTEMS_INHERIT_PRIORITY },
170    { 0, 0, 0 },
171};
172
173int
174rtems_monitor_dump_attributes(rtems_attribute attributes)
175{
176    int   length = 0;
177
178    if (attributes == RTEMS_DEFAULT_ATTRIBUTES)  /* value is 0 */
179        length += fprintf(stdout,"DEFAULT");
180
181    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_attribute_assoc,
182                                                ":",
183                                                attributes);
184    return length;
185}
186
187rtems_assoc_t rtems_monitor_modes_assoc[] = {
188    { "nP",     RTEMS_NO_PREEMPT },
189    { "T",      RTEMS_TIMESLICE },
190    { "nA",     RTEMS_NO_ASR },
191    { 0, 0, 0 },
192};
193
194int
195rtems_monitor_dump_modes(rtems_mode modes)
196{
197    uint32_t   length = 0;
198
199    if (modes == RTEMS_DEFAULT_MODES)  /* value is 0 */
200        length += fprintf(stdout,"P:T:nA");
201
202    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_modes_assoc,
203                                                ":",
204                                                modes);
205    return length;
206}
207
208rtems_assoc_t rtems_monitor_events_assoc[] = {
209    { "0",   RTEMS_EVENT_0 },
210    { "1",   RTEMS_EVENT_1 },
211    { "2",   RTEMS_EVENT_2 },
212    { "3",   RTEMS_EVENT_3 },
213    { "4",   RTEMS_EVENT_4 },
214    { "5",   RTEMS_EVENT_5 },
215    { "6",   RTEMS_EVENT_6 },
216    { "7",   RTEMS_EVENT_7 },
217    { "8",   RTEMS_EVENT_8 },
218    { "9",   RTEMS_EVENT_9 },
219    { "10",  RTEMS_EVENT_10 },
220    { "11",  RTEMS_EVENT_11 },
221    { "12",  RTEMS_EVENT_12 },
222    { "13",  RTEMS_EVENT_13 },
223    { "14",  RTEMS_EVENT_14 },
224    { "15",  RTEMS_EVENT_15 },
225    { "16",  RTEMS_EVENT_16 },
226    { "17",  RTEMS_EVENT_17 },
227    { "18",  RTEMS_EVENT_18 },
228    { "19",  RTEMS_EVENT_19 },
229    { "20",  RTEMS_EVENT_20 },
230    { "21",  RTEMS_EVENT_21 },
231    { "22",  RTEMS_EVENT_22 },
232    { "23",  RTEMS_EVENT_23 },
233    { "24",  RTEMS_EVENT_24 },
234    { "25",  RTEMS_EVENT_25 },
235    { "26",  RTEMS_EVENT_26 },
236    { "27",  RTEMS_EVENT_27 },
237    { "28",  RTEMS_EVENT_28 },
238    { "29",  RTEMS_EVENT_29 },
239    { "30",  RTEMS_EVENT_30 },
240    { "31",  RTEMS_EVENT_31 },
241    { 0, 0, 0 },
242};
243
244int
245rtems_monitor_dump_events(rtems_event_set events)
246{
247    uint32_t   length = 0;
248
249    if (events == EVENT_SETS_NONE_PENDING)  /* value is 0 */
250        length += fprintf(stdout,"NONE");
251
252    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_events_assoc,
253                                                ":",
254                                                events);
255    return length;
256}
257
258int
259rtems_monitor_dump_notepad(uint32_t   *notepad)
260{
261    int   length = 0;
262    int i;
263
264    for (i=0; i < RTEMS_NUMBER_NOTEPADS; i++)
265        if (notepad[i])
266            length += fprintf(stdout,"%d: 0x%" PRIx32, i, notepad[i]);
267
268    return length;
269}
Note: See TracBrowser for help on using the repository browser.