File indexing completed on 2025-05-11 08:24:21
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/record.h>
0033 #include <rtems/config.h>
0034 #include <rtems/sysinit.h>
0035 #include <rtems/score/timecounter.h>
0036 #include <rtems/score/watchdogimpl.h>
0037
0038 static Watchdog_Interval _Record_Tick_interval;
0039
0040 void _Record_Initialize( void )
0041 {
0042 Record_Control *control;
0043 size_t control_size;
0044 uint32_t cpu_max;
0045 uint32_t cpu_index;
0046 unsigned int item_count;
0047
0048 cpu_max = rtems_configuration_get_maximum_processors();
0049 item_count = _Record_Configuration.item_count;
0050 control = _Record_Configuration.controls;
0051 control_size = sizeof( *control );
0052 control_size += sizeof( control->Items[ 0 ] ) * item_count;
0053
0054 for ( cpu_index = 0; cpu_index < cpu_max; ++cpu_index ) {
0055 Per_CPU_Control *cpu;
0056
0057 cpu = _Per_CPU_Get_by_index( cpu_index );
0058 control->mask = item_count - 1U;
0059 cpu->record = control;
0060 control = (Record_Control *) ( (char *) control + control_size );
0061 }
0062 }
0063
0064 static void _Record_Watchdog( Watchdog_Control *watchdog )
0065 {
0066 ISR_Level level;
0067 rtems_record_context context;
0068 sbintime_t now;
0069
0070 _ISR_Local_disable( level );
0071 _Watchdog_Per_CPU_insert_ticks(
0072 watchdog,
0073 _Watchdog_Get_CPU( watchdog ),
0074 _Record_Tick_interval
0075 );
0076 now = _Timecounter_Sbinuptime();
0077 rtems_record_prepare_critical( &context, _Per_CPU_Get() );
0078 rtems_record_add(
0079 &context,
0080 RTEMS_RECORD_UPTIME_LOW,
0081 (uint32_t) ( now >> 0 )
0082 );
0083 rtems_record_add(
0084 &context,
0085 RTEMS_RECORD_UPTIME_HIGH,
0086 (uint32_t) ( now >> 32 )
0087 );
0088 rtems_record_commit_critical( &context );
0089 _ISR_Local_enable( level );
0090 }
0091
0092 static void _Record_Initialize_watchdogs( void )
0093 {
0094 Watchdog_Interval interval;
0095 uint32_t cpu_max;
0096 uint32_t cpu_index;
0097 sbintime_t now;
0098
0099 interval = rtems_counter_frequency() / _Watchdog_Ticks_per_second;
0100 interval = ( UINT32_C( 1 ) << 22 ) / interval;
0101
0102 if ( interval == 0 ) {
0103 interval = 1;
0104 }
0105
0106 _Record_Tick_interval = interval;
0107
0108 cpu_max = rtems_configuration_get_maximum_processors();
0109
0110 for ( cpu_index = 0; cpu_index < cpu_max; ++cpu_index ) {
0111 Per_CPU_Control *cpu;
0112 Record_Control *control;
0113
0114 cpu = _Per_CPU_Get_by_index( cpu_index );
0115 control = cpu->record;
0116 _Watchdog_Preinitialize( &control->Watchdog, cpu );
0117 _Watchdog_Initialize( &control->Watchdog, _Record_Watchdog );
0118 _Watchdog_Per_CPU_insert_ticks(
0119 &control->Watchdog,
0120 cpu,
0121 _Record_Tick_interval
0122 );
0123 }
0124
0125 now = _Timecounter_Sbinuptime();
0126 rtems_record_produce_2(
0127 RTEMS_RECORD_UPTIME_LOW,
0128 (uint32_t) ( now >> 0 ),
0129 RTEMS_RECORD_UPTIME_HIGH,
0130 (uint32_t) ( now >> 32 )
0131 );
0132 }
0133
0134 RTEMS_SYSINIT_ITEM(
0135 _Record_Initialize_watchdogs,
0136 RTEMS_SYSINIT_DEVICE_DRIVERS,
0137 RTEMS_SYSINIT_ORDER_LAST_BUT_5
0138 );