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 Monitor init task 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 
0044 /*
0045  * As above, but just for init tasks
0046  */
0047 void
0048 rtems_monitor_init_task_canonical(
0049     rtems_monitor_init_task_t *canonical_itask,
0050     const void                *itask_void
0051 )
0052 {
0053     const rtems_initialization_tasks_table *rtems_itask = itask_void;
0054 
0055     rtems_monitor_symbol_canonical_by_value(&canonical_itask->entry,
0056                                             (void *) rtems_itask->entry_point);
0057 
0058     canonical_itask->argument = rtems_itask->argument;
0059     canonical_itask->stack_size = rtems_itask->stack_size;
0060     canonical_itask->priority = rtems_itask->initial_priority;
0061     canonical_itask->modes = rtems_itask->mode_set;
0062     canonical_itask->attributes = rtems_itask->attribute_set;
0063 }
0064 
0065 const void *
0066 rtems_monitor_init_task_next(
0067     void                  *object_info RTEMS_UNUSED,
0068     rtems_monitor_init_task_t *canonical_init_task,
0069     rtems_id              *next_id
0070 )
0071 {
0072     const rtems_api_configuration_table *config;
0073     const rtems_initialization_tasks_table *itask;
0074     uint32_t   n = rtems_object_id_get_index(*next_id);
0075 
0076     config = rtems_configuration_get_rtems_api_configuration();
0077     if (n >= config->number_of_initialization_tasks)
0078         goto failed;
0079 
0080     _Objects_Allocator_lock();
0081 
0082     itask = config->User_initialization_tasks_table + n;
0083 
0084     /*
0085      * dummy up a fake id and name for this item
0086      */
0087 
0088     canonical_init_task->id = n;
0089     canonical_init_task->name = itask->name;
0090 
0091     *next_id += 1;
0092     return (const void *) itask;
0093 
0094 failed:
0095     *next_id = RTEMS_OBJECT_ID_FINAL;
0096     return 0;
0097 }
0098 
0099 
0100 void
0101 rtems_monitor_init_task_dump_header(
0102     bool verbose RTEMS_UNUSED
0103 )
0104 {
0105     fprintf(stdout,"\
0106   #    NAME   ENTRY        ARGUMENT    PRIO   MODES  ATTRIBUTES   STACK SIZE\n");
0107 /*23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
0108 0         1         2         3         4         5         6         7       */
0109     rtems_monitor_separator();
0110 }
0111 
0112 /*
0113  */
0114 
0115 void
0116 rtems_monitor_init_task_dump(
0117     rtems_monitor_init_task_t *monitor_itask,
0118     bool  verbose
0119 )
0120 {
0121     int length = 0;
0122 
0123     length += rtems_monitor_dump_decimal(monitor_itask->id);
0124 
0125     length += rtems_monitor_pad(7, length);
0126     length += rtems_monitor_dump_name(monitor_itask->id);
0127 
0128     length += rtems_monitor_pad(14, length);
0129     length += rtems_monitor_symbol_dump(&monitor_itask->entry, verbose);
0130 
0131     length += rtems_monitor_pad(25, length);
0132     length += fprintf(stdout,"%" PRId32 " [0x%" PRIx32 "]",
0133       monitor_itask->argument, monitor_itask->argument);
0134 
0135     length += rtems_monitor_pad(39, length);
0136     length += rtems_monitor_dump_priority(monitor_itask->priority);
0137 
0138     length += rtems_monitor_pad(46, length);
0139     length += rtems_monitor_dump_modes(monitor_itask->modes);
0140 
0141     length += rtems_monitor_pad(54, length);
0142     length += rtems_monitor_dump_attributes(monitor_itask->attributes);
0143 
0144     length += rtems_monitor_pad(66, length);
0145     length += fprintf(stdout,"%" PRId32 " [0x%" PRIx32 "]",
0146       monitor_itask->stack_size, monitor_itask->stack_size);
0147 
0148     fprintf(stdout,"\n");
0149 }