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

4.104.114.84.95
Last change on this file since 9ffcaa4a was 9ffcaa4a, checked in by Joel Sherrill <joel.sherrill@…>, on 04/07/97 at 21:30:58

changed signed int to unsigned int to eliminate a warning.

  • Property mode set to 100644
File size: 5.9 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 "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    for (i=0; i<sizeof(u.c); i++)
108        length += rtems_monitor_dump_char(u.c[i]);
109    return length;
110}
111
112unsigned32
113rtems_monitor_dump_priority(rtems_task_priority priority)
114{
115    return printf("%3d", priority);
116}
117
118
119rtems_assoc_t rtems_monitor_state_assoc[] = {
120    { "DORM",   STATES_DORMANT },
121    { "SUSP",   STATES_SUSPENDED },
122    { "TRANS",  STATES_TRANSIENT },
123    { "DELAY",  STATES_DELAYING },
124    { "Wbuf",   STATES_WAITING_FOR_BUFFER },
125    { "Wseg",   STATES_WAITING_FOR_SEGMENT },
126    { "Wmsg" ,  STATES_WAITING_FOR_MESSAGE },
127    { "Wevnt",  STATES_WAITING_FOR_EVENT },
128    { "Wsem",   STATES_WAITING_FOR_SEMAPHORE },
129    { "Wtime",  STATES_WAITING_FOR_TIME },
130    { "Wrpc",   STATES_WAITING_FOR_RPC_REPLY },
131    { "WRATE",  STATES_WAITING_FOR_PERIOD },
132    { 0, 0, 0 },
133};
134
135unsigned32
136rtems_monitor_dump_state(States_Control state)
137{
138    unsigned32 length = 0;
139
140    if (state == STATES_READY)  /* assoc doesn't deal with this as it is 0 */
141        length += printf("READY");
142   
143    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_state_assoc,
144                                                ":",
145                                                state);
146    return length;
147}
148
149rtems_assoc_t rtems_monitor_attribute_assoc[] = {
150    { "FL",  RTEMS_FLOATING_POINT },
151    { "GL",  RTEMS_GLOBAL },
152    { "PR",  RTEMS_PRIORITY },
153    { "BI",  RTEMS_BINARY_SEMAPHORE },
154    { "IN",  RTEMS_INHERIT_PRIORITY },
155    { 0, 0, 0 },
156};
157
158unsigned32
159rtems_monitor_dump_attributes(rtems_attribute attributes)
160{
161    unsigned32 length = 0;
162
163    if (attributes == RTEMS_DEFAULT_ATTRIBUTES)  /* value is 0 */
164        length += printf("DEFAULT");
165   
166    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_attribute_assoc,
167                                                ":",
168                                                attributes);
169    return length;
170}
171
172rtems_assoc_t rtems_monitor_modes_assoc[] = {
173    { "nP",     RTEMS_NO_PREEMPT },
174    { "T",      RTEMS_TIMESLICE },
175    { "nA",     RTEMS_NO_ASR },
176    { 0, 0, 0 },
177};
178
179unsigned32
180rtems_monitor_dump_modes(rtems_mode modes)
181{
182    unsigned32 length = 0;
183
184    if (modes == RTEMS_DEFAULT_MODES)  /* value is 0 */
185        length += printf("P:T:nA");
186   
187    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_modes_assoc,
188                                                ":",
189                                                modes);
190    return length;
191}
192
193rtems_assoc_t rtems_monitor_events_assoc[] = {
194    { "0",   RTEMS_EVENT_0 },
195    { "1",   RTEMS_EVENT_1 },
196    { "2",   RTEMS_EVENT_2 },
197    { "3",   RTEMS_EVENT_3 },
198    { "4",   RTEMS_EVENT_4 },
199    { "5",   RTEMS_EVENT_5 },
200    { "6",   RTEMS_EVENT_6 },
201    { "7",   RTEMS_EVENT_7 },
202    { "8",   RTEMS_EVENT_8 },
203    { "9",   RTEMS_EVENT_9 },
204    { "10",  RTEMS_EVENT_10 },
205    { "11",  RTEMS_EVENT_11 },
206    { "12",  RTEMS_EVENT_12 },
207    { "13",  RTEMS_EVENT_13 },
208    { "14",  RTEMS_EVENT_14 },
209    { "15",  RTEMS_EVENT_15 },
210    { "16",  RTEMS_EVENT_16 },
211    { "17",  RTEMS_EVENT_17 },
212    { "18",  RTEMS_EVENT_18 },
213    { "19",  RTEMS_EVENT_19 },
214    { "20",  RTEMS_EVENT_20 },
215    { "21",  RTEMS_EVENT_21 },
216    { "22",  RTEMS_EVENT_22 },
217    { "23",  RTEMS_EVENT_23 },
218    { "24",  RTEMS_EVENT_24 },
219    { "25",  RTEMS_EVENT_25 },
220    { "26",  RTEMS_EVENT_26 },
221    { "27",  RTEMS_EVENT_27 },
222    { "28",  RTEMS_EVENT_28 },
223    { "29",  RTEMS_EVENT_29 },
224    { "30",  RTEMS_EVENT_30 },
225    { "31",  RTEMS_EVENT_31 },
226    { 0, 0, 0 },
227};
228
229unsigned32
230rtems_monitor_dump_events(rtems_event_set events)
231{
232    unsigned32 length = 0;
233
234    if (events == EVENT_SETS_NONE_PENDING)  /* value is 0 */
235        length += printf("NONE");
236   
237    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_events_assoc,
238                                                ":",
239                                                events);
240    return length;
241}
242
243unsigned32
244rtems_monitor_dump_notepad(unsigned32 *notepad)
245{
246    unsigned32 length = 0;
247    int i;
248
249    for (i=0; i < RTEMS_NUMBER_NOTEPADS; i++)
250        if (notepad[i])
251            length += printf("%d: 0x%x ", i, notepad[i]);
252
253    return length;
254}
Note: See TracBrowser for help on using the repository browser.