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

4.104.114.84.95
Last change on this file since 6741c2e1 was 714f06c, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/17/04 at 08:12:02

2004-04-17 Ralf Corsepius <ralf_corsepius@…>

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