Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:18

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @brief RTEMS Config display support
0007  */
0008 
0009 /*
0010  * COPYRIGHT (c) 1989-2022. On-Line Applications Research Corporation (OAR).
0011  *
0012  * Redistribution and use in source and binary forms, with or without
0013  * modification, are permitted provided that the following conditions
0014  * are met:
0015  * 1. Redistributions of source code must retain the above copyright
0016  *    notice, this list of conditions and the following disclaimer.
0017  * 2. Redistributions in binary form must reproduce the above copyright
0018  *    notice, this list of conditions and the following disclaimer in the
0019  *    documentation and/or other materials provided with the distribution.
0020  *
0021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0022  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0024  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0025  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0026  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0027  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0028  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0029  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0030  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0031  * POSSIBILITY OF SUCH DAMAGE.
0032  */
0033 
0034 #ifdef HAVE_CONFIG_H
0035 #include "config.h"
0036 #endif
0037 
0038 #include <rtems.h>
0039 #include <rtems/monitor.h>
0040 
0041 #include <inttypes.h>
0042 #include <stdio.h>
0043 #include <stdlib.h>             /* strtoul() */
0044 
0045 #define DATACOL 15
0046 #define CONTCOL DATACOL     /* continued col */
0047 
0048 /*
0049  * Fill in entire monitor config table
0050  * for sending to a remote monitor or printing on the local system
0051  */
0052 
0053 void
0054 rtems_monitor_config_canonical(
0055     rtems_monitor_config_t *canonical_config,
0056     const void             *config_void
0057 )
0058 {
0059     const rtems_api_configuration_table *r;
0060 
0061     r = rtems_configuration_get_rtems_api_configuration();
0062 
0063     canonical_config->work_space_size = rtems_configuration_get_work_space_size();
0064     canonical_config->maximum_tasks = rtems_configuration_get_maximum_tasks();
0065     canonical_config->maximum_timers = rtems_configuration_get_maximum_timers();
0066     canonical_config->maximum_semaphores = rtems_configuration_get_maximum_semaphores();
0067     canonical_config->maximum_message_queues = rtems_configuration_get_maximum_message_queues();
0068     canonical_config->maximum_partitions = rtems_configuration_get_maximum_partitions();
0069     canonical_config->maximum_regions = rtems_configuration_get_maximum_regions();
0070     canonical_config->maximum_ports = rtems_configuration_get_maximum_ports();
0071     canonical_config->maximum_periods = rtems_configuration_get_maximum_periods();
0072     canonical_config->maximum_extensions = rtems_configuration_get_maximum_extensions();
0073     canonical_config->microseconds_per_tick = rtems_configuration_get_microseconds_per_tick();
0074     canonical_config->ticks_per_timeslice = rtems_configuration_get_ticks_per_timeslice();
0075     canonical_config->number_of_initialization_tasks = r->number_of_initialization_tasks;
0076 }
0077 
0078 /*
0079  * This is easy, since there is only 1 (altho we could get them from
0080  *    other nodes...)
0081  */
0082 
0083 const void *
0084 rtems_monitor_config_next(
0085     void                  *object_info RTEMS_UNUSED,
0086     rtems_monitor_config_t *canonical_config RTEMS_UNUSED,
0087     rtems_id              *next_id
0088 )
0089 {
0090     int n = rtems_object_id_get_index(*next_id);
0091 
0092     if (n >= 1)
0093         goto failed;
0094 
0095     _Objects_Allocator_lock();
0096 
0097     *next_id += 1;
0098     return (const void *) (uintptr_t) 1;
0099 
0100 failed:
0101     *next_id = RTEMS_OBJECT_ID_FINAL;
0102     return 0;
0103 }
0104 
0105 
0106 void
0107 rtems_monitor_config_dump_header(
0108     bool verbose RTEMS_UNUSED
0109 )
0110 {
0111     fprintf(stdout,"\
0112 INITIAL (startup) Configuration Info\n");
0113 /*23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
0114 0         1         2         3         4         5         6         7       */
0115     rtems_monitor_separator();
0116 }
0117 
0118 
0119 int
0120 rtems_monitor_config_dump(
0121     rtems_monitor_config_t *monitor_config,
0122     bool                 verbose RTEMS_UNUSED
0123 )
0124 {
0125     int     length = 0;
0126 
0127     length = 0;
0128     length += fprintf(stdout,"WORKSPACE");
0129     length += rtems_monitor_pad(DATACOL, length);
0130     length += fprintf(stdout,"start: %p;  size: 0x%" PRIx32 " (%" PRId32 ")\n",
0131                      monitor_config->work_space_start,
0132                      monitor_config->work_space_size,
0133                      monitor_config->work_space_size);
0134 
0135     length = 0;
0136     length += fprintf(stdout,"TIME");
0137     length += rtems_monitor_pad(DATACOL, length);
0138     length += fprintf(stdout,"usec/tick: %" PRId32 ";  tick/timeslice: %" PRId32 ";  tick/sec: %" PRId32 "\n",
0139                      monitor_config->microseconds_per_tick,
0140                      monitor_config->ticks_per_timeslice,
0141                      1000000 / monitor_config->microseconds_per_tick);
0142 
0143     length = 0;
0144     length += fprintf(stdout,"MAXIMUMS");
0145     length += rtems_monitor_pad(DATACOL, length);
0146     length += fprintf(stdout,"tasks: %" PRId32 "%c;  timers: %" PRId32 "%c;  sems: %" PRId32 "%c;  que's: %" PRId32 "%c;  ext's: %" PRId32 "%c;\n",
0147                      monitor_config->maximum_tasks & ~OBJECTS_UNLIMITED_OBJECTS,
0148                      (monitor_config->maximum_tasks & OBJECTS_UNLIMITED_OBJECTS) == 0 ? ' ' : '+',
0149                      monitor_config->maximum_timers & ~OBJECTS_UNLIMITED_OBJECTS,
0150                      (monitor_config->maximum_timers & OBJECTS_UNLIMITED_OBJECTS) == 0 ? ' ' : '+',
0151                      monitor_config->maximum_semaphores & ~OBJECTS_UNLIMITED_OBJECTS,
0152                      (monitor_config->maximum_semaphores & OBJECTS_UNLIMITED_OBJECTS) == 0 ? ' ' : '+',
0153                      monitor_config->maximum_message_queues & ~OBJECTS_UNLIMITED_OBJECTS,
0154                      (monitor_config->maximum_message_queues & OBJECTS_UNLIMITED_OBJECTS) == 0 ? ' ' : '+',
0155                      monitor_config->maximum_extensions & ~OBJECTS_UNLIMITED_OBJECTS,
0156                      (monitor_config->maximum_extensions & OBJECTS_UNLIMITED_OBJECTS) == 0 ? ' ' : '+');
0157     length = 0;
0158     length += rtems_monitor_pad(CONTCOL, length);
0159     length += fprintf(stdout,"partitions: %" PRId32 "%c;  regions: %" PRId32 "%c;  ports: %" PRId32 "%c;  periods: %" PRId32 "%c;\n",
0160                      monitor_config->maximum_partitions & ~OBJECTS_UNLIMITED_OBJECTS,
0161                      (monitor_config->maximum_partitions & OBJECTS_UNLIMITED_OBJECTS) == 0 ? ' ' : '+',
0162                      monitor_config->maximum_regions & ~OBJECTS_UNLIMITED_OBJECTS,
0163                      (monitor_config->maximum_regions & OBJECTS_UNLIMITED_OBJECTS) == 0 ? ' ' : '+',
0164                      monitor_config->maximum_ports & ~OBJECTS_UNLIMITED_OBJECTS,
0165                      (monitor_config->maximum_ports & OBJECTS_UNLIMITED_OBJECTS) == 0 ? ' ' : '+',
0166                      monitor_config->maximum_periods & ~OBJECTS_UNLIMITED_OBJECTS,
0167                      (monitor_config->maximum_periods & OBJECTS_UNLIMITED_OBJECTS) == 0 ? ' ' : '+');
0168     return length;
0169 }