File indexing completed on 2025-05-11 08:24:44
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
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032
0033 #include "system.h"
0034
0035 #include <rtems/score/watchdogimpl.h>
0036
0037
0038
0039
0040 #define TA6_ITERATIONS 10
0041 #define TA6_PERIOD_FACTOR 10
0042
0043 uint32_t Periods[7] = { 0, 2, 2, 2, 2, 100, 0 };
0044 uint32_t Iterations[7] = { 0, 50, 50, 50, 50, 1, TA6_ITERATIONS };
0045 rtems_task_priority Priorities[7] = { 0, 1, 1, 3, 4, 5, 1 };
0046
0047 static char *name( size_t i, char buf[ 4 ] )
0048 {
0049 rtems_name_to_characters(
0050 Task_name[ i ],
0051 &buf[ 0 ],
0052 &buf[ 1 ],
0053 &buf[ 2 ],
0054 &buf[ 3 ]
0055 );
0056 buf[ 3 ] = '\0';
0057 return &buf[ 0 ];
0058 }
0059
0060 rtems_task Task_1_through_6(
0061 rtems_task_argument argument
0062 )
0063 {
0064 rtems_id rmid;
0065 rtems_id test_rmid;
0066 int index;
0067 int pass;
0068 uint32_t failed;
0069 rtems_status_code status;
0070 char buf[ 4 ];
0071
0072 status = rtems_rate_monotonic_create( argument, &rmid );
0073 directive_failed( status, "rtems_rate_monotonic_create" );
0074 rtems_test_printf(
0075 "%s - rtems_rate_monotonic_create id = 0x%08" PRIxrtems_id "\n",
0076 name( argument, buf ),
0077 rmid
0078 );
0079
0080 status = rtems_rate_monotonic_ident( argument, &test_rmid );
0081 directive_failed( status, "rtems_rate_monotonic_ident" );
0082 rtems_test_printf(
0083 "%s - rtems_rate_monotonic_ident id = 0x%08" PRIxrtems_id "\n",
0084 name( argument, buf ),
0085 test_rmid
0086 );
0087
0088 if ( rmid != test_rmid ) {
0089 rtems_test_printf(
0090 "RMID's DO NOT MATCH (0x%" PRIxrtems_id " and 0x%" PRIxrtems_id ")\n",
0091 rmid,
0092 test_rmid
0093 );
0094 rtems_test_exit( 0 );
0095 }
0096
0097 rtems_test_printf(
0098 "%s - (0x%08" PRIxrtems_id ") period %" PRIu32 "\n",
0099 name( argument, buf ),
0100 rmid,
0101 Periods[ argument ]
0102 );
0103
0104 status = rtems_task_wake_after( 2 );
0105 directive_failed( status, "rtems_task_wake_after" );
0106
0107 switch ( argument ) {
0108 case 1:
0109 case 2:
0110 case 3:
0111 case 4:
0112 while ( FOREVER ) {
0113 status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
0114 directive_failed( status, "rtems_rate_monotonic_period" );
0115
0116 Count.count[ argument ]++;
0117 }
0118 break;
0119 case 5:
0120 pass = 0;
0121 failed = 0;
0122
0123 status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
0124 directive_failed( status, "rtems_rate_monotonic_period 1 of TA5" );
0125
0126 Get_all_counters();
0127
0128 while ( FOREVER ) {
0129
0130 status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
0131 directive_failed( status, "rtems_rate_monotonic_period 2 of TA5" );
0132
0133 Get_all_counters();
0134
0135 for( index = 1 ; index <= 4 ; index++ ) {
0136 if ( Temporary_count.count[ index ] != Iterations[ index ] ) {
0137 rtems_test_printf(
0138 "%s - FAIL - Actual=%" PRIu32 ", Expected=%" PRIu32 "\n",
0139 name( index, buf ),
0140 Temporary_count.count[ index ],
0141 Iterations[ index ]
0142 );
0143 failed += 1;
0144 }
0145 }
0146
0147 if ( failed == 5 )
0148 rtems_test_exit( 0 );
0149
0150 pass += 1;
0151
0152 rtems_test_printf( "TA5 - PERIODS CHECK OK (%d)\n", pass );
0153
0154 if ( pass == 10 ) {
0155 end_of_test();
0156 }
0157
0158 }
0159 break;
0160 case 6:
0161
0162 {
0163 uint32_t time[TA6_ITERATIONS+1];
0164 rtems_interval period;
0165
0166 period = 1*TA6_PERIOD_FACTOR;
0167 status = rtems_rate_monotonic_period( rmid, period);
0168 directive_failed( status, "rtems_rate_monotonic_period of TA6" );
0169 time[0] = _Watchdog_Ticks_since_boot;
0170
0171
0172 for (index = 1; index <= TA6_ITERATIONS; index++) {
0173 period = (index+1)*TA6_PERIOD_FACTOR;
0174 status = rtems_rate_monotonic_period( rmid, period);
0175 directive_failed( status, "rtems_rate_monotonic_period of TA6" );
0176 time[index] = _Watchdog_Ticks_since_boot;
0177
0178 }
0179
0180 for (index = 1; index <= TA6_ITERATIONS; index++) {
0181 rtems_interval meas = time[index] - time[index-1];
0182 period = index*TA6_PERIOD_FACTOR;
0183 rtems_test_printf(
0184 "TA6 - Actual: %" PRIdrtems_interval
0185 " Expected: %" PRIdrtems_interval,
0186 meas,
0187 period
0188 );
0189 if (period == meas) rtems_test_printf(" - OK\n");
0190 else rtems_test_printf(" - FAILED\n");
0191 }
0192 }
0193 rtems_task_suspend(RTEMS_SELF);
0194 break;
0195 }
0196 }