1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * @brief RTEMS Monitor init task support |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 1989-2022. On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * Redistribution and use in source and binary forms, with or without |
---|
13 | * modification, are permitted provided that the following conditions |
---|
14 | * are met: |
---|
15 | * 1. Redistributions of source code must retain the above copyright |
---|
16 | * notice, this list of conditions and the following disclaimer. |
---|
17 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
18 | * notice, this list of conditions and the following disclaimer in the |
---|
19 | * documentation and/or other materials provided with the distribution. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
31 | * POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | #ifdef HAVE_CONFIG_H |
---|
35 | #include "config.h" |
---|
36 | #endif |
---|
37 | |
---|
38 | #include <rtems.h> |
---|
39 | #include <rtems/monitor.h> |
---|
40 | |
---|
41 | #include <inttypes.h> |
---|
42 | #include <stdio.h> |
---|
43 | |
---|
44 | /* |
---|
45 | * As above, but just for init tasks |
---|
46 | */ |
---|
47 | void |
---|
48 | rtems_monitor_init_task_canonical( |
---|
49 | rtems_monitor_init_task_t *canonical_itask, |
---|
50 | const void *itask_void |
---|
51 | ) |
---|
52 | { |
---|
53 | const rtems_initialization_tasks_table *rtems_itask = itask_void; |
---|
54 | |
---|
55 | rtems_monitor_symbol_canonical_by_value(&canonical_itask->entry, |
---|
56 | (void *) rtems_itask->entry_point); |
---|
57 | |
---|
58 | canonical_itask->argument = rtems_itask->argument; |
---|
59 | canonical_itask->stack_size = rtems_itask->stack_size; |
---|
60 | canonical_itask->priority = rtems_itask->initial_priority; |
---|
61 | canonical_itask->modes = rtems_itask->mode_set; |
---|
62 | canonical_itask->attributes = rtems_itask->attribute_set; |
---|
63 | } |
---|
64 | |
---|
65 | const void * |
---|
66 | rtems_monitor_init_task_next( |
---|
67 | void *object_info RTEMS_UNUSED, |
---|
68 | rtems_monitor_init_task_t *canonical_init_task, |
---|
69 | rtems_id *next_id |
---|
70 | ) |
---|
71 | { |
---|
72 | const rtems_api_configuration_table *config; |
---|
73 | const rtems_initialization_tasks_table *itask; |
---|
74 | uint32_t n = rtems_object_id_get_index(*next_id); |
---|
75 | |
---|
76 | config = rtems_configuration_get_rtems_api_configuration(); |
---|
77 | if (n >= config->number_of_initialization_tasks) |
---|
78 | goto failed; |
---|
79 | |
---|
80 | _Objects_Allocator_lock(); |
---|
81 | |
---|
82 | itask = config->User_initialization_tasks_table + n; |
---|
83 | |
---|
84 | /* |
---|
85 | * dummy up a fake id and name for this item |
---|
86 | */ |
---|
87 | |
---|
88 | canonical_init_task->id = n; |
---|
89 | canonical_init_task->name = itask->name; |
---|
90 | |
---|
91 | *next_id += 1; |
---|
92 | return (const void *) itask; |
---|
93 | |
---|
94 | failed: |
---|
95 | *next_id = RTEMS_OBJECT_ID_FINAL; |
---|
96 | return 0; |
---|
97 | } |
---|
98 | |
---|
99 | |
---|
100 | void |
---|
101 | rtems_monitor_init_task_dump_header( |
---|
102 | bool verbose RTEMS_UNUSED |
---|
103 | ) |
---|
104 | { |
---|
105 | fprintf(stdout,"\ |
---|
106 | # NAME ENTRY ARGUMENT PRIO MODES ATTRIBUTES STACK SIZE\n"); |
---|
107 | /*23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 |
---|
108 | 0 1 2 3 4 5 6 7 */ |
---|
109 | rtems_monitor_separator(); |
---|
110 | } |
---|
111 | |
---|
112 | /* |
---|
113 | */ |
---|
114 | |
---|
115 | void |
---|
116 | rtems_monitor_init_task_dump( |
---|
117 | rtems_monitor_init_task_t *monitor_itask, |
---|
118 | bool verbose |
---|
119 | ) |
---|
120 | { |
---|
121 | int length = 0; |
---|
122 | |
---|
123 | length += rtems_monitor_dump_decimal(monitor_itask->id); |
---|
124 | |
---|
125 | length += rtems_monitor_pad(7, length); |
---|
126 | length += rtems_monitor_dump_name(monitor_itask->id); |
---|
127 | |
---|
128 | length += rtems_monitor_pad(14, length); |
---|
129 | length += rtems_monitor_symbol_dump(&monitor_itask->entry, verbose); |
---|
130 | |
---|
131 | length += rtems_monitor_pad(25, length); |
---|
132 | length += fprintf(stdout,"%" PRId32 " [0x%" PRIx32 "]", |
---|
133 | monitor_itask->argument, monitor_itask->argument); |
---|
134 | |
---|
135 | length += rtems_monitor_pad(39, length); |
---|
136 | length += rtems_monitor_dump_priority(monitor_itask->priority); |
---|
137 | |
---|
138 | length += rtems_monitor_pad(46, length); |
---|
139 | length += rtems_monitor_dump_modes(monitor_itask->modes); |
---|
140 | |
---|
141 | length += rtems_monitor_pad(54, length); |
---|
142 | length += rtems_monitor_dump_attributes(monitor_itask->attributes); |
---|
143 | |
---|
144 | length += rtems_monitor_pad(66, length); |
---|
145 | length += fprintf(stdout,"%" PRId32 " [0x%" PRIx32 "]", |
---|
146 | monitor_itask->stack_size, monitor_itask->stack_size); |
---|
147 | |
---|
148 | fprintf(stdout,"\n"); |
---|
149 | } |
---|