File indexing completed on 2025-05-11 08:24:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #ifdef HAVE_CONFIG_H
0029 #include "config.h"
0030 #endif
0031
0032 #include <rtems/cpuuse.h>
0033 #include <rtems/print.h>
0034
0035 #include <ctype.h>
0036 #include <inttypes.h>
0037
0038 #include <rtems/score/schedulerimpl.h>
0039
0040 static char bits_to_char( uint8_t bits )
0041 {
0042 return isprint( bits ) ? (char) bits : '?';
0043 }
0044
0045 static void name_to_str( uint32_t name, char str[ 5 ] )
0046 {
0047 str[ 0 ] = bits_to_char( (uint8_t) ( name >> 24 ) );
0048 str[ 1 ] = bits_to_char( (uint8_t) ( name >> 16 ) );
0049 str[ 2 ] = bits_to_char( (uint8_t) ( name >> 8 ) );
0050 str[ 3 ] = bits_to_char( (uint8_t) ( name >> 0 ) );
0051 str[ 4 ] = '\0';
0052 }
0053
0054 int rtems_cpu_info_report( const rtems_printer *printer )
0055 {
0056 uint32_t cpu_max;
0057 uint32_t cpu_index;
0058 int n;
0059
0060 cpu_max = rtems_configuration_get_maximum_processors();
0061
0062 n = rtems_printf(
0063 printer,
0064 "-------------------------------------------------------------------------------\n"
0065 " PER PROCESSOR INFORMATION\n"
0066 "-------+--------+--------------+-----------------------------------------------\n"
0067 " INDEX | ONLINE | SCHEDULER ID | SCHEDULER NAME\n"
0068 "-------+--------+--------------+-----------------------------------------------\n"
0069 );
0070
0071 for ( cpu_index = 0; cpu_index < cpu_max; ++cpu_index ) {
0072 const Per_CPU_Control *cpu;
0073 const Scheduler_Control *scheduler;
0074 char scheduler_str[ 5 ];
0075 uint32_t scheduler_id;
0076
0077 cpu = _Per_CPU_Get_by_index( cpu_index );
0078 scheduler = _Scheduler_Get_by_CPU( cpu );
0079
0080 if ( scheduler != NULL ) {
0081 scheduler_id = _Scheduler_Build_id( _Scheduler_Get_index( scheduler ) );
0082 name_to_str( scheduler->name, scheduler_str );
0083 } else {
0084 scheduler_id = 0;
0085 scheduler_str[ 0 ] = '\0';
0086 }
0087
0088 n += rtems_printf(
0089 printer,
0090 " %5" PRIu32 " | %6i | 0x%08" PRIx32 " | %s\n",
0091 cpu_index,
0092 _Per_CPU_Is_processor_online( cpu ),
0093 scheduler_id,
0094 &scheduler_str[ 0 ]
0095 );
0096 }
0097
0098 return n;
0099 }