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

Last change on this file since 77c4089 was b9e230a2, checked in by Ralf Corsepius <ralf.corsepius@…>, on 07/08/03 at 08:38:15

2003-07-08 Ralf Corsepius <corsepiu@…>

  • capture/capture-cli.c: Add config-header support.
  • capture/capture.c: Add config-header support.
  • cpuuse/cpuuse.c: Add config-header support.
  • devnull/devnull.c: Add config-header support.
  • dummy/dummy.c: Add config-header support.
  • dumpbuf/dumpbuf.c: Add config-header support.
  • monitor/mon-command.c: Add config-header support.
  • monitor/mon-config.c: Add config-header support.
  • monitor/mon-dname.c: Add config-header support.
  • monitor/mon-driver.c: Add config-header support.
  • monitor/mon-extension.c: Add config-header support.
  • monitor/mon-itask.c: Add config-header support.
  • monitor/mon-manager.c: Add config-header support.
  • monitor/mon-monitor.c: Add config-header support.
  • monitor/mon-mpci.c: Add config-header support.
  • monitor/mon-object.c: Add config-header support.
  • monitor/mon-prmisc.c: Add config-header support.
  • monitor/mon-queue.c: Add config-header support.
  • monitor/mon-server.c: Add config-header support.
  • monitor/mon-symbols.c: Add config-header support.
  • monitor/mon-task.c: Add config-header support.
  • mw-fb/mw_fb.c: Add config-header support.
  • mw-fb/mw_uid.c: Add config-header support.
  • rtmonuse/rtmonuse.c: Add config-header support.
  • serdbg/serdbg.c: Add config-header support.
  • serdbg/serdbgio.c: Add config-header support.
  • serdbg/termios_printk.c: Add config-header support.
  • shell/cmds.c: Add config-header support.
  • stackchk/check.c: Add config-header support.
  • untar/untar.c: Add config-header support.
  • 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
22void
23rtems_monitor_separator(void)
24{
25    printf("------------------------------------------------------------------------------\n");
26}
27
28unsigned32
29rtems_monitor_pad(
30    unsigned32  destination_column,
31    unsigned32  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 printf("%*s", pad_length, "");
42}
43
44unsigned32
45rtems_monitor_dump_char(rtems_unsigned8 ch)
46{
47    if (isprint(ch))
48        return printf("%c", ch);
49    else
50        return printf("%02x", ch);
51}
52
53unsigned32
54rtems_monitor_dump_decimal(unsigned32 num)
55{
56    return printf("%4d", num);
57}
58
59unsigned32
60rtems_monitor_dump_hex(unsigned32 num)
61{
62    return printf("0x%x", num);
63}
64
65unsigned32
66rtems_monitor_dump_assoc_bitfield(
67    rtems_assoc_t *ap,
68    char          *separator,
69    unsigned32     value
70  )
71
72    unsigned32 b;
73    unsigned32 length = 0;
74    const char *name;
75
76    for (b = 1; b; b <<= 1)
77        if (b & value)
78        {
79            if (length)
80                length += printf("%s", separator);
81
82            name = rtems_assoc_name_by_local(ap, b);
83           
84            if (name)
85                length += printf("%s", name);
86            else
87                length += printf("0x%x", b);
88        }
89       
90    return length;
91}
92
93unsigned32
94rtems_monitor_dump_id(rtems_id id)
95{
96    return printf("%08x", id);
97}
98
99unsigned32
100rtems_monitor_dump_name(rtems_name name)
101{
102    unsigned32 i;
103    unsigned32 length = 0;
104    union {
105        unsigned32 ui;
106        char       c[4];
107    } u;
108   
109    u.ui = (rtems_unsigned32) 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
121unsigned32
122rtems_monitor_dump_priority(rtems_task_priority priority)
123{
124    return printf("%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
149unsigned32
150rtems_monitor_dump_state(States_Control state)
151{
152    unsigned32 length = 0;
153
154    if (state == STATES_READY)  /* assoc doesn't deal with this as it is 0 */
155        length += printf("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
172unsigned32
173rtems_monitor_dump_attributes(rtems_attribute attributes)
174{
175    unsigned32 length = 0;
176
177    if (attributes == RTEMS_DEFAULT_ATTRIBUTES)  /* value is 0 */
178        length += printf("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
193unsigned32
194rtems_monitor_dump_modes(rtems_mode modes)
195{
196    unsigned32 length = 0;
197
198    if (modes == RTEMS_DEFAULT_MODES)  /* value is 0 */
199        length += printf("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
243unsigned32
244rtems_monitor_dump_events(rtems_event_set events)
245{
246    unsigned32 length = 0;
247
248    if (events == EVENT_SETS_NONE_PENDING)  /* value is 0 */
249        length += printf("NONE");
250   
251    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_events_assoc,
252                                                ":",
253                                                events);
254    return length;
255}
256
257unsigned32
258rtems_monitor_dump_notepad(unsigned32 *notepad)
259{
260    unsigned32 length = 0;
261    int i;
262
263    for (i=0; i < RTEMS_NUMBER_NOTEPADS; i++)
264        if (notepad[i])
265            length += printf("%d: 0x%x ", i, notepad[i]);
266
267    return length;
268}
Note: See TracBrowser for help on using the repository browser.