source: rtems/cpukit/libmisc/monitor/mon-config.c

Last change on this file was e4cc56a7, checked in by Joel Sherrill <joel@…>, on 03/24/22 at 17:37:47

cpukit/libmisc/monitor/: Manually change to BSD-2 license

This code did not have any copyrights or licenses and a bit
of archeology was needed to determine authorship.

This code was in the initial import into the RTEMS CVS repository when
it was established in May 1995. There was very little, if any, code not
written by OAR Corporation in that initial import. After discussion
with Chris Johns, it was determined that this code was from OAR
Corporation and that he had added a few features later. Both
Chris Johns and OAR Corporation have given permission to relicense.

Updates #3053.

  • Property mode set to 100644
File size: 7.0 KB
Line 
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
53void
54rtems_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
83const void *
84rtems_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
100failed:
101    *next_id = RTEMS_OBJECT_ID_FINAL;
102    return 0;
103}
104
105
106void
107rtems_monitor_config_dump_header(
108    bool verbose RTEMS_UNUSED
109)
110{
111    fprintf(stdout,"\
112INITIAL (startup) Configuration Info\n");
113/*23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
1140         1         2         3         4         5         6         7       */
115    rtems_monitor_separator();
116}
117
118
119int
120rtems_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}
Note: See TracBrowser for help on using the repository browser.