OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [libmisc/] [monitor/] [mon-prmisc.c] - Blame information for rev 300

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: mon-prmisc.c,v 1.2 2001-09-27 12:01:43 chris Exp $
8
 */
9
 
10
#include <rtems.h>
11
#include <rtems/monitor.h>
12
 
13
#include <rtems/assoc.h>
14
 
15
#include <stdio.h>
16
#include <ctype.h>
17
 
18
void
19
rtems_monitor_separator(void)
20
{
21
    printf("------------------------------------------------------------------------------\n");
22
}
23
 
24
unsigned32
25
rtems_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
 
40
unsigned32
41
rtems_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
 
49
unsigned32
50
rtems_monitor_dump_decimal(unsigned32 num)
51
{
52
    return printf("%4d", num);
53
}
54
 
55
unsigned32
56
rtems_monitor_dump_hex(unsigned32 num)
57
{
58
    return printf("0x%x", num);
59
}
60
 
61
unsigned32
62
rtems_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
 
89
unsigned32
90
rtems_monitor_dump_id(rtems_id id)
91
{
92
    return printf("%08x", id);
93
}
94
 
95
unsigned32
96
rtems_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
#if (CPU_BIG_ENDIAN == TRUE)
108
    for (i=0; i<sizeof(u.c); i++)
109
        length += rtems_monitor_dump_char(u.c[i]);
110
#else
111
    for (i=sizeof(u.c)-1; i ; i--)
112
        length += rtems_monitor_dump_char(u.c[i]);
113
#endif
114
    return length;
115
}
116
 
117
unsigned32
118
rtems_monitor_dump_priority(rtems_task_priority priority)
119
{
120
    return printf("%3d", priority);
121
}
122
 
123
 
124
rtems_assoc_t rtems_monitor_state_assoc[] = {
125
    { "DORM",   STATES_DORMANT },
126
    { "SUSP",   STATES_SUSPENDED },
127
    { "TRANS",  STATES_TRANSIENT },
128
    { "DELAY",  STATES_DELAYING },
129
    { "Wbuf",   STATES_WAITING_FOR_BUFFER },
130
    { "Wseg",   STATES_WAITING_FOR_SEGMENT },
131
    { "Wmsg" ,  STATES_WAITING_FOR_MESSAGE },
132
    { "Wevnt",  STATES_WAITING_FOR_EVENT },
133
    { "Wsem",   STATES_WAITING_FOR_SEMAPHORE },
134
    { "Wtime",  STATES_WAITING_FOR_TIME },
135
    { "Wrpc",   STATES_WAITING_FOR_RPC_REPLY },
136
    { "WRATE",  STATES_WAITING_FOR_PERIOD },
137
    { 0, 0, 0 },
138
};
139
 
140
unsigned32
141
rtems_monitor_dump_state(States_Control state)
142
{
143
    unsigned32 length = 0;
144
 
145
    if (state == STATES_READY)  /* assoc doesn't deal with this as it is 0 */
146
        length += printf("READY");
147
 
148
    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_state_assoc,
149
                                                ":",
150
                                                state);
151
    return length;
152
}
153
 
154
rtems_assoc_t rtems_monitor_attribute_assoc[] = {
155
    { "FL",  RTEMS_FLOATING_POINT },
156
    { "GL",  RTEMS_GLOBAL },
157
    { "PR",  RTEMS_PRIORITY },
158
    { "BI",  RTEMS_BINARY_SEMAPHORE },
159
    { "IN",  RTEMS_INHERIT_PRIORITY },
160
    { 0, 0, 0 },
161
};
162
 
163
unsigned32
164
rtems_monitor_dump_attributes(rtems_attribute attributes)
165
{
166
    unsigned32 length = 0;
167
 
168
    if (attributes == RTEMS_DEFAULT_ATTRIBUTES)  /* value is 0 */
169
        length += printf("DEFAULT");
170
 
171
    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_attribute_assoc,
172
                                                ":",
173
                                                attributes);
174
    return length;
175
}
176
 
177
rtems_assoc_t rtems_monitor_modes_assoc[] = {
178
    { "nP",     RTEMS_NO_PREEMPT },
179
    { "T",      RTEMS_TIMESLICE },
180
    { "nA",     RTEMS_NO_ASR },
181
    { 0, 0, 0 },
182
};
183
 
184
unsigned32
185
rtems_monitor_dump_modes(rtems_mode modes)
186
{
187
    unsigned32 length = 0;
188
 
189
    if (modes == RTEMS_DEFAULT_MODES)  /* value is 0 */
190
        length += printf("P:T:nA");
191
 
192
    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_modes_assoc,
193
                                                ":",
194
                                                modes);
195
    return length;
196
}
197
 
198
rtems_assoc_t rtems_monitor_events_assoc[] = {
199
    { "0",   RTEMS_EVENT_0 },
200
    { "1",   RTEMS_EVENT_1 },
201
    { "2",   RTEMS_EVENT_2 },
202
    { "3",   RTEMS_EVENT_3 },
203
    { "4",   RTEMS_EVENT_4 },
204
    { "5",   RTEMS_EVENT_5 },
205
    { "6",   RTEMS_EVENT_6 },
206
    { "7",   RTEMS_EVENT_7 },
207
    { "8",   RTEMS_EVENT_8 },
208
    { "9",   RTEMS_EVENT_9 },
209
    { "10",  RTEMS_EVENT_10 },
210
    { "11",  RTEMS_EVENT_11 },
211
    { "12",  RTEMS_EVENT_12 },
212
    { "13",  RTEMS_EVENT_13 },
213
    { "14",  RTEMS_EVENT_14 },
214
    { "15",  RTEMS_EVENT_15 },
215
    { "16",  RTEMS_EVENT_16 },
216
    { "17",  RTEMS_EVENT_17 },
217
    { "18",  RTEMS_EVENT_18 },
218
    { "19",  RTEMS_EVENT_19 },
219
    { "20",  RTEMS_EVENT_20 },
220
    { "21",  RTEMS_EVENT_21 },
221
    { "22",  RTEMS_EVENT_22 },
222
    { "23",  RTEMS_EVENT_23 },
223
    { "24",  RTEMS_EVENT_24 },
224
    { "25",  RTEMS_EVENT_25 },
225
    { "26",  RTEMS_EVENT_26 },
226
    { "27",  RTEMS_EVENT_27 },
227
    { "28",  RTEMS_EVENT_28 },
228
    { "29",  RTEMS_EVENT_29 },
229
    { "30",  RTEMS_EVENT_30 },
230
    { "31",  RTEMS_EVENT_31 },
231
    { 0, 0, 0 },
232
};
233
 
234
unsigned32
235
rtems_monitor_dump_events(rtems_event_set events)
236
{
237
    unsigned32 length = 0;
238
 
239
    if (events == EVENT_SETS_NONE_PENDING)  /* value is 0 */
240
        length += printf("NONE");
241
 
242
    length += rtems_monitor_dump_assoc_bitfield(rtems_monitor_events_assoc,
243
                                                ":",
244
                                                events);
245
    return length;
246
}
247
 
248
unsigned32
249
rtems_monitor_dump_notepad(unsigned32 *notepad)
250
{
251
    unsigned32 length = 0;
252
    int i;
253
 
254
    for (i=0; i < RTEMS_NUMBER_NOTEPADS; i++)
255
        if (notepad[i])
256
            length += printf("%d: 0x%x ", i, notepad[i]);
257
 
258
    return length;
259
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.