source: rtems/cpukit/libmisc/monitor/mon-prmisc.c @ 17049c39

4.104.114.95
Last change on this file since 17049c39 was 17049c39, checked in by Joel Sherrill <joel.sherrill@…>, on 07/01/08 at 18:44:12

2008-07-01 Joel Sherrill <joel.sherrill@…>

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