source: rtems/c/src/libmisc/monitor/mon-prmisc.c @ 487a7ca

4.104.114.84.95
Last change on this file since 487a7ca was c64e4ed4, checked in by Joel Sherrill <joel.sherrill@…>, on 01/15/96 at 21:50:28

updates from Tony Bennett for PA and UNIX ports

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