1 | /* |
---|
2 | * RTEMS Monitor task support |
---|
3 | */ |
---|
4 | |
---|
5 | #ifdef HAVE_CONFIG_H |
---|
6 | #include "config.h" |
---|
7 | #endif |
---|
8 | |
---|
9 | #include <rtems.h> |
---|
10 | #include <rtems/monitor.h> |
---|
11 | #include <rtems/score/threadimpl.h> |
---|
12 | #include <rtems/score/threadqimpl.h> |
---|
13 | |
---|
14 | #include <stdio.h> |
---|
15 | #include <string.h> /* memcpy() */ |
---|
16 | |
---|
17 | void |
---|
18 | rtems_monitor_task_canonical( |
---|
19 | rtems_monitor_task_t *canonical_task, |
---|
20 | const void *thread_void |
---|
21 | ) |
---|
22 | { |
---|
23 | const Thread_Control *rtems_thread = (const Thread_Control *) thread_void; |
---|
24 | RTEMS_API_Control *api; |
---|
25 | |
---|
26 | api = rtems_thread->API_Extensions[ THREAD_API_RTEMS ]; |
---|
27 | |
---|
28 | canonical_task->entry = rtems_thread->Start.Entry; |
---|
29 | canonical_task->stack = rtems_thread->Start.Initial_stack.area; |
---|
30 | canonical_task->stack_size = rtems_thread->Start.Initial_stack.size; |
---|
31 | canonical_task->cpu = _Per_CPU_Get_index( _Thread_Get_CPU( rtems_thread ) ); |
---|
32 | canonical_task->priority = rtems_thread->current_priority; |
---|
33 | canonical_task->state = rtems_thread->current_state; |
---|
34 | canonical_task->wait_id = rtems_thread->Wait.id; |
---|
35 | canonical_task->wait_queue = rtems_thread->Wait.queue; |
---|
36 | canonical_task->wait_operations = rtems_thread->Wait.operations; |
---|
37 | canonical_task->events = api->Event.pending_events; |
---|
38 | /* |
---|
39 | * FIXME: make this optionally cpu_time_executed |
---|
40 | */ |
---|
41 | #if 0 |
---|
42 | canonical_task->ticks = rtems_thread->cpu_time_executed; |
---|
43 | #else |
---|
44 | canonical_task->ticks = 0; |
---|
45 | #endif |
---|
46 | |
---|
47 | /* XXX modes and attributes only exist in the RTEMS API .. */ |
---|
48 | /* XXX not directly in the core thread.. they will have to be derived */ |
---|
49 | /* XXX if they are important enough to include anymore. */ |
---|
50 | canonical_task->modes = 0; /* XXX FIX ME.... rtems_thread->current_modes; */ |
---|
51 | canonical_task->attributes = 0 /* XXX FIX ME rtems_thread->API_Extensions[ THREAD_API_RTEMS ]->attribute_set */; |
---|
52 | } |
---|
53 | |
---|
54 | |
---|
55 | void |
---|
56 | rtems_monitor_task_dump_header( |
---|
57 | bool verbose RTEMS_UNUSED |
---|
58 | ) |
---|
59 | { |
---|
60 | fprintf(stdout,"\ |
---|
61 | ID NAME CPU PRI STATE MODES EVENTS WAITID WAITQUEUE\n"); /* |
---|
62 | 0a010004 SHLL 0 100 READY P:T:nA NONE 00000000 00000000 [DFLT] */ |
---|
63 | |
---|
64 | rtems_monitor_separator(); |
---|
65 | } |
---|
66 | |
---|
67 | /* |
---|
68 | */ |
---|
69 | |
---|
70 | void |
---|
71 | rtems_monitor_task_dump( |
---|
72 | rtems_monitor_task_t *monitor_task, |
---|
73 | bool verbose RTEMS_UNUSED |
---|
74 | ) |
---|
75 | { |
---|
76 | int length = 0; |
---|
77 | |
---|
78 | length += rtems_monitor_dump_id(monitor_task->id); |
---|
79 | length += rtems_monitor_pad(11, length); |
---|
80 | length += rtems_monitor_dump_name(monitor_task->id); |
---|
81 | length += rtems_monitor_pad(21, length); |
---|
82 | length += rtems_monitor_dump_decimal(monitor_task->cpu); |
---|
83 | length += rtems_monitor_pad(26, length); |
---|
84 | length += rtems_monitor_dump_priority(monitor_task->priority); |
---|
85 | length += rtems_monitor_pad(30, length); |
---|
86 | length += rtems_monitor_dump_state(monitor_task->state); |
---|
87 | length += rtems_monitor_pad(37, length); |
---|
88 | length += rtems_monitor_dump_modes(monitor_task->modes); |
---|
89 | length += rtems_monitor_pad(44, length); |
---|
90 | length += rtems_monitor_dump_events(monitor_task->events); |
---|
91 | length += rtems_monitor_pad(53, length); |
---|
92 | length += rtems_monitor_dump_id(monitor_task->wait_id); |
---|
93 | length += rtems_monitor_pad(62, length); |
---|
94 | length += rtems_monitor_dump_addr(monitor_task->wait_queue); |
---|
95 | if (monitor_task->wait_operations == &_Thread_queue_Operations_default) { |
---|
96 | length += fprintf(stdout, " [DFLT]"); |
---|
97 | } else if (monitor_task->wait_operations == &_Thread_queue_Operations_FIFO) { |
---|
98 | length += fprintf(stdout, " [FIFO]"); |
---|
99 | } else if (monitor_task->wait_operations == &_Thread_queue_Operations_priority) { |
---|
100 | length += fprintf(stdout, " [PRIO]"); |
---|
101 | } else { |
---|
102 | length += fprintf(stdout, " [?]"); |
---|
103 | } |
---|
104 | |
---|
105 | fprintf(stdout,"\n"); |
---|
106 | } |
---|