1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * @brief RTEMS Config display 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 | #include <stdlib.h> /* strtoul() */ |
---|
44 | |
---|
45 | #define DATACOL 15 |
---|
46 | #define CONTCOL DATACOL /* continued col */ |
---|
47 | |
---|
48 | /* |
---|
49 | * Fill in entire monitor config table |
---|
50 | * for sending to a remote monitor or printing on the local system |
---|
51 | */ |
---|
52 | |
---|
53 | void |
---|
54 | rtems_monitor_config_canonical( |
---|
55 | rtems_monitor_config_t *canonical_config, |
---|
56 | const void *config_void |
---|
57 | ) |
---|
58 | { |
---|
59 | const rtems_api_configuration_table *r; |
---|
60 | |
---|
61 | r = rtems_configuration_get_rtems_api_configuration(); |
---|
62 | |
---|
63 | canonical_config->work_space_size = rtems_configuration_get_work_space_size(); |
---|
64 | canonical_config->maximum_tasks = rtems_configuration_get_maximum_tasks(); |
---|
65 | canonical_config->maximum_timers = rtems_configuration_get_maximum_timers(); |
---|
66 | canonical_config->maximum_semaphores = rtems_configuration_get_maximum_semaphores(); |
---|
67 | canonical_config->maximum_message_queues = rtems_configuration_get_maximum_message_queues(); |
---|
68 | canonical_config->maximum_partitions = rtems_configuration_get_maximum_partitions(); |
---|
69 | canonical_config->maximum_regions = rtems_configuration_get_maximum_regions(); |
---|
70 | canonical_config->maximum_ports = rtems_configuration_get_maximum_ports(); |
---|
71 | canonical_config->maximum_periods = rtems_configuration_get_maximum_periods(); |
---|
72 | canonical_config->maximum_extensions = rtems_configuration_get_maximum_extensions(); |
---|
73 | canonical_config->microseconds_per_tick = rtems_configuration_get_microseconds_per_tick(); |
---|
74 | canonical_config->ticks_per_timeslice = rtems_configuration_get_ticks_per_timeslice(); |
---|
75 | canonical_config->number_of_initialization_tasks = r->number_of_initialization_tasks; |
---|
76 | } |
---|
77 | |
---|
78 | /* |
---|
79 | * This is easy, since there is only 1 (altho we could get them from |
---|
80 | * other nodes...) |
---|
81 | */ |
---|
82 | |
---|
83 | const void * |
---|
84 | rtems_monitor_config_next( |
---|
85 | void *object_info RTEMS_UNUSED, |
---|
86 | rtems_monitor_config_t *canonical_config RTEMS_UNUSED, |
---|
87 | rtems_id *next_id |
---|
88 | ) |
---|
89 | { |
---|
90 | int n = rtems_object_id_get_index(*next_id); |
---|
91 | |
---|
92 | if (n >= 1) |
---|
93 | goto failed; |
---|
94 | |
---|
95 | _Objects_Allocator_lock(); |
---|
96 | |
---|
97 | *next_id += 1; |
---|
98 | return (const void *) (uintptr_t) 1; |
---|
99 | |
---|
100 | failed: |
---|
101 | *next_id = RTEMS_OBJECT_ID_FINAL; |
---|
102 | return 0; |
---|
103 | } |
---|
104 | |
---|
105 | |
---|
106 | void |
---|
107 | rtems_monitor_config_dump_header( |
---|
108 | bool verbose RTEMS_UNUSED |
---|
109 | ) |
---|
110 | { |
---|
111 | fprintf(stdout,"\ |
---|
112 | INITIAL (startup) Configuration Info\n"); |
---|
113 | /*23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 |
---|
114 | 0 1 2 3 4 5 6 7 */ |
---|
115 | rtems_monitor_separator(); |
---|
116 | } |
---|
117 | |
---|
118 | |
---|
119 | int |
---|
120 | rtems_monitor_config_dump( |
---|
121 | rtems_monitor_config_t *monitor_config, |
---|
122 | bool verbose RTEMS_UNUSED |
---|
123 | ) |
---|
124 | { |
---|
125 | int length = 0; |
---|
126 | |
---|
127 | length = 0; |
---|
128 | length += fprintf(stdout,"WORKSPACE"); |
---|
129 | length += rtems_monitor_pad(DATACOL, length); |
---|
130 | length += fprintf(stdout,"start: %p; size: 0x%" PRIx32 " (%" PRId32 ")\n", |
---|
131 | monitor_config->work_space_start, |
---|
132 | monitor_config->work_space_size, |
---|
133 | monitor_config->work_space_size); |
---|
134 | |
---|
135 | length = 0; |
---|
136 | length += fprintf(stdout,"TIME"); |
---|
137 | length += rtems_monitor_pad(DATACOL, length); |
---|
138 | length += fprintf(stdout,"usec/tick: %" PRId32 "; tick/timeslice: %" PRId32 "; tick/sec: %" PRId32 "\n", |
---|
139 | monitor_config->microseconds_per_tick, |
---|
140 | monitor_config->ticks_per_timeslice, |
---|
141 | 1000000 / monitor_config->microseconds_per_tick); |
---|
142 | |
---|
143 | length = 0; |
---|
144 | length += fprintf(stdout,"MAXIMUMS"); |
---|
145 | length += rtems_monitor_pad(DATACOL, length); |
---|
146 | length += fprintf(stdout,"tasks: %" PRId32 "%c; timers: %" PRId32 "%c; sems: %" PRId32 "%c; que's: %" PRId32 "%c; ext's: %" PRId32 "%c;\n", |
---|
147 | monitor_config->maximum_tasks & ~OBJECTS_UNLIMITED_OBJECTS, |
---|
148 | (monitor_config->maximum_tasks & OBJECTS_UNLIMITED_OBJECTS) == 0 ? ' ' : '+', |
---|
149 | monitor_config->maximum_timers & ~OBJECTS_UNLIMITED_OBJECTS, |
---|
150 | (monitor_config->maximum_timers & OBJECTS_UNLIMITED_OBJECTS) == 0 ? ' ' : '+', |
---|
151 | monitor_config->maximum_semaphores & ~OBJECTS_UNLIMITED_OBJECTS, |
---|
152 | (monitor_config->maximum_semaphores & OBJECTS_UNLIMITED_OBJECTS) == 0 ? ' ' : '+', |
---|
153 | monitor_config->maximum_message_queues & ~OBJECTS_UNLIMITED_OBJECTS, |
---|
154 | (monitor_config->maximum_message_queues & OBJECTS_UNLIMITED_OBJECTS) == 0 ? ' ' : '+', |
---|
155 | monitor_config->maximum_extensions & ~OBJECTS_UNLIMITED_OBJECTS, |
---|
156 | (monitor_config->maximum_extensions & OBJECTS_UNLIMITED_OBJECTS) == 0 ? ' ' : '+'); |
---|
157 | length = 0; |
---|
158 | length += rtems_monitor_pad(CONTCOL, length); |
---|
159 | length += fprintf(stdout,"partitions: %" PRId32 "%c; regions: %" PRId32 "%c; ports: %" PRId32 "%c; periods: %" PRId32 "%c;\n", |
---|
160 | monitor_config->maximum_partitions & ~OBJECTS_UNLIMITED_OBJECTS, |
---|
161 | (monitor_config->maximum_partitions & OBJECTS_UNLIMITED_OBJECTS) == 0 ? ' ' : '+', |
---|
162 | monitor_config->maximum_regions & ~OBJECTS_UNLIMITED_OBJECTS, |
---|
163 | (monitor_config->maximum_regions & OBJECTS_UNLIMITED_OBJECTS) == 0 ? ' ' : '+', |
---|
164 | monitor_config->maximum_ports & ~OBJECTS_UNLIMITED_OBJECTS, |
---|
165 | (monitor_config->maximum_ports & OBJECTS_UNLIMITED_OBJECTS) == 0 ? ' ' : '+', |
---|
166 | monitor_config->maximum_periods & ~OBJECTS_UNLIMITED_OBJECTS, |
---|
167 | (monitor_config->maximum_periods & OBJECTS_UNLIMITED_OBJECTS) == 0 ? ' ' : '+'); |
---|
168 | return length; |
---|
169 | } |
---|