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

4.104.114.84.95
Last change on this file since 5e622a9 was ab09d083, checked in by Joel Sherrill <joel.sherrill@…>, on 03/20/02 at 14:33:00

2002-03-20 Chris Johns <ccj@…>

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