Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:42

0001 /* Copyright 2014 Daniel Ramirez (javamonn@gmail.com)
0002  *
0003  * This file's license is 2-clause BSD as in this distribution's LICENSE.2 file.
0004  */
0005 
0006 /*
0007  *  WARNING!!!!!!!!!
0008  *
0009  *  THIS TEST USES INTERNAL RTEMS VARIABLES!!!
0010  */
0011 
0012 #ifdef HAVE_CONFIG_H
0013 #include "config.h"
0014 #endif
0015 
0016 #define CONFIGURE_INIT
0017 #include <timesys.h>
0018 #include <rtems/btimer.h>
0019 #include <rtems/score/schedulerpriorityimpl.h>
0020 
0021 /* configuration information */
0022 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0023 #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
0024 #define CONFIGURE_MAXIMUM_TASKS              2
0025 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0026 #define CONFIGURE_SCHEDULER_PRIORITY
0027 
0028 #include <rtems/confdefs.h>
0029 
0030 #include <bsp.h>
0031 
0032 #define _RTEMS_TMTEST27
0033 #include <tm27.h>
0034 
0035 const char rtems_test_name[] = "RHILATENCY";
0036 
0037 #define BENCHMARKS 50000
0038 
0039 rtems_task Task_1(
0040   rtems_task_argument argument
0041 );
0042 
0043 uint32_t   Interrupt_nest;
0044 uint32_t   timer_overhead;
0045 uint32_t   Interrupt_enter_time;
0046 
0047 rtems_task Init(
0048   rtems_task_argument argument
0049 )
0050 {
0051   rtems_status_code status;
0052   rtems_id Task_id;
0053 
0054   Print_Warning();
0055 
0056   TEST_BEGIN();
0057 
0058   if (
0059     _Scheduler_Table[ 0 ].Operations.initialize
0060       != _Scheduler_priority_Initialize
0061   ) {
0062     puts( "  Error ==> " );
0063     puts( "Test only supported for deterministic priority scheduler\n" );
0064     rtems_test_exit( 0 );
0065   }
0066 
0067 #define LOW_PRIORITY (RTEMS_MAXIMUM_PRIORITY - 1u)
0068   status = rtems_task_create(
0069     rtems_build_name( 'T', 'A', '1', ' ' ),
0070     LOW_PRIORITY,
0071     RTEMS_MINIMUM_STACK_SIZE,
0072     RTEMS_DEFAULT_MODES,
0073     RTEMS_DEFAULT_ATTRIBUTES,
0074     &Task_id
0075   );
0076   directive_failed( status, "rtems_task_create Task_1" );
0077 
0078   status = rtems_task_start( Task_id, Task_1, 0 );
0079   directive_failed( status, "rtems_task_start Task_1" );
0080 
0081   benchmark_timer_initialize();
0082   benchmark_timer_read();
0083   benchmark_timer_initialize();
0084   timer_overhead = benchmark_timer_read();
0085 
0086   rtems_task_exit();
0087 }
0088 
0089 #ifdef TM27_USE_VECTOR_HANDLER
0090 static rtems_isr Isr_handler( rtems_vector_number arg )
0091 #else
0092 static void Isr_handler( void *arg )
0093 #endif
0094 {
0095   (void) arg;
0096 
0097   /* See how long it took system to recognize interrupt */
0098   Interrupt_enter_time = benchmark_timer_read();
0099   Clear_tm27_intr();
0100 }
0101 
0102 rtems_task Task_1(
0103   rtems_task_argument argument
0104 )
0105 {
0106   Install_tm27_vector( Isr_handler ) ;
0107   Interrupt_nest = 0;
0108 
0109   /* Benchmark code */
0110   benchmark_timer_initialize();
0111   /* goes to Isr_handler */
0112   Cause_tm27_intr();
0113 
0114   put_time(
0115     "Rhealstone: Interrupt Latency",
0116     Interrupt_enter_time,
0117     1,                             /* Only Rhealstone that isn't an average */
0118     timer_overhead,
0119     0
0120   );
0121 
0122   TEST_END();
0123   rtems_test_exit( 0 );
0124 }