[19e9bf8] | 1 | /* Copyright 2014 Daniel Ramirez (javamonn@gmail.com) |
---|
| 2 | * |
---|
| 3 | * This file's license is 2-clause BSD as in this distribution's LICENSE.2 file. |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | /* |
---|
| 7 | * WARNING!!!!!!!!! |
---|
| 8 | * |
---|
| 9 | * THIS TEST USES INTERNAL RTEMS VARIABLES!!! |
---|
| 10 | */ |
---|
| 11 | |
---|
| 12 | #ifdef HAVE_CONFIG_H |
---|
| 13 | #include "config.h" |
---|
| 14 | #endif |
---|
| 15 | |
---|
| 16 | #define CONFIGURE_INIT |
---|
| 17 | #include <timesys.h> |
---|
| 18 | #include <rtems/timerdrv.h> |
---|
| 19 | #include <coverhd.h> |
---|
| 20 | |
---|
| 21 | /* configuration information */ |
---|
| 22 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
| 23 | #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER |
---|
| 24 | #define CONFIGURE_MAXIMUM_TASKS 2 |
---|
| 25 | #define CONFIGURE_TICKS_PER_TIMESLICE 0 |
---|
| 26 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
| 27 | #define CONFIGURE_SCHEDULER_PRIORITY |
---|
| 28 | |
---|
| 29 | #include <rtems/confdefs.h> |
---|
| 30 | |
---|
| 31 | #include <bsp.h> |
---|
| 32 | |
---|
| 33 | #define _RTEMS_TMTEST27 |
---|
| 34 | #include <tm27.h> |
---|
| 35 | |
---|
| 36 | #define BENCHMARKS 50000 |
---|
| 37 | |
---|
| 38 | rtems_task Task_1( |
---|
| 39 | rtems_task_argument argument |
---|
| 40 | ); |
---|
| 41 | |
---|
| 42 | uint32_t Interrupt_nest; |
---|
| 43 | uint32_t timer_overhead; |
---|
| 44 | uint32_t Interrupt_enter_time; |
---|
| 45 | |
---|
| 46 | rtems_isr Isr_handler( |
---|
| 47 | rtems_vector_number vector |
---|
| 48 | ); |
---|
| 49 | |
---|
| 50 | rtems_task Init( |
---|
| 51 | rtems_task_argument argument |
---|
| 52 | ) |
---|
| 53 | { |
---|
| 54 | rtems_status_code status; |
---|
[e8c7dbe7] | 55 | rtems_id Task_id; |
---|
[19e9bf8] | 56 | |
---|
| 57 | Print_Warning(); |
---|
| 58 | |
---|
[893aac16] | 59 | puts( "*** START OF RHILATENCY ***" ); |
---|
| 60 | |
---|
[19e9bf8] | 61 | if (_Scheduler.Operations.initialize != _Scheduler_priority_Initialize) { |
---|
| 62 | puts( " Error ==> " ); |
---|
| 63 | puts( "Test only supported for deterministic priority scheduler\n" ); |
---|
| 64 | rtems_test_exit( 0 ); |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | #define LOW_PRIORITY (RTEMS_MAXIMUM_PRIORITY - 1u) |
---|
| 68 | status = rtems_task_create( |
---|
| 69 | rtems_build_name( 'T', 'A', '1', ' ' ), |
---|
| 70 | LOW_PRIORITY, |
---|
| 71 | RTEMS_MINIMUM_STACK_SIZE, |
---|
| 72 | RTEMS_DEFAULT_MODES, |
---|
| 73 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 74 | &Task_id |
---|
| 75 | ); |
---|
| 76 | directive_failed( status, "rtems_task_create Task_1" ); |
---|
| 77 | |
---|
| 78 | status = rtems_task_start( Task_id, Task_1, 0 ); |
---|
| 79 | directive_failed( status, "rtems_task_start Task_1" ); |
---|
| 80 | |
---|
| 81 | benchmark_timer_initialize(); |
---|
| 82 | benchmark_timer_read(); |
---|
| 83 | benchmark_timer_initialize(); |
---|
| 84 | timer_overhead = benchmark_timer_read(); |
---|
| 85 | |
---|
| 86 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 87 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | rtems_task Task_1( |
---|
| 91 | rtems_task_argument argument |
---|
| 92 | ) |
---|
| 93 | { |
---|
| 94 | Install_tm27_vector( Isr_handler ) ; |
---|
| 95 | Interrupt_nest = 0; |
---|
| 96 | |
---|
| 97 | /* Benchmark code */ |
---|
| 98 | benchmark_timer_initialize(); |
---|
| 99 | /* goes to Isr_handler */ |
---|
| 100 | Cause_tm27_intr(); |
---|
| 101 | |
---|
| 102 | put_time( |
---|
| 103 | "Rhealstone: Interrupt Latency", |
---|
| 104 | Interrupt_enter_time, |
---|
| 105 | 1, /* Only Rhealstone that isn't an average */ |
---|
| 106 | timer_overhead, |
---|
| 107 | 0 |
---|
| 108 | ); |
---|
| 109 | |
---|
[893aac16] | 110 | puts( "*** END OF RHILATENCY ***" ); |
---|
[19e9bf8] | 111 | rtems_test_exit( 0 ); |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | rtems_isr Isr_handler( |
---|
| 115 | rtems_vector_number vector |
---|
| 116 | ) |
---|
| 117 | { |
---|
| 118 | /* See how long it took system to recognize interrupt */ |
---|
| 119 | Interrupt_enter_time = benchmark_timer_read(); |
---|
| 120 | Clear_tm27_intr(); |
---|
| 121 | } |
---|