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