[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> |
---|
[8fbe2e6] | 18 | #include <rtems/btimer.h> |
---|
[e1598a6] | 19 | #include <rtems/score/schedulerpriorityimpl.h> |
---|
[19e9bf8] | 20 | #include <coverhd.h> |
---|
| 21 | |
---|
| 22 | /* configuration information */ |
---|
| 23 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
| 24 | #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER |
---|
| 25 | #define CONFIGURE_MAXIMUM_TASKS 2 |
---|
| 26 | #define CONFIGURE_TICKS_PER_TIMESLICE 0 |
---|
| 27 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
| 28 | #define CONFIGURE_SCHEDULER_PRIORITY |
---|
| 29 | |
---|
| 30 | #include <rtems/confdefs.h> |
---|
| 31 | |
---|
| 32 | #include <bsp.h> |
---|
| 33 | |
---|
| 34 | #define _RTEMS_TMTEST27 |
---|
| 35 | #include <tm27.h> |
---|
| 36 | |
---|
[1d799ad] | 37 | const char rtems_test_name[] = "RHILATENCY"; |
---|
| 38 | |
---|
[19e9bf8] | 39 | #define BENCHMARKS 50000 |
---|
| 40 | |
---|
| 41 | rtems_task Task_1( |
---|
| 42 | rtems_task_argument argument |
---|
| 43 | ); |
---|
| 44 | |
---|
| 45 | uint32_t Interrupt_nest; |
---|
| 46 | uint32_t timer_overhead; |
---|
| 47 | uint32_t Interrupt_enter_time; |
---|
| 48 | |
---|
| 49 | rtems_isr Isr_handler( |
---|
| 50 | rtems_vector_number vector |
---|
| 51 | ); |
---|
| 52 | |
---|
| 53 | rtems_task Init( |
---|
| 54 | rtems_task_argument argument |
---|
| 55 | ) |
---|
| 56 | { |
---|
| 57 | rtems_status_code status; |
---|
[e8c7dbe7] | 58 | rtems_id Task_id; |
---|
[19e9bf8] | 59 | |
---|
| 60 | Print_Warning(); |
---|
| 61 | |
---|
[1d799ad] | 62 | TEST_BEGIN(); |
---|
[893aac16] | 63 | |
---|
[e1598a6] | 64 | if ( |
---|
| 65 | _Scheduler_Table[ 0 ].Operations.initialize |
---|
| 66 | != _Scheduler_priority_Initialize |
---|
| 67 | ) { |
---|
[19e9bf8] | 68 | puts( " Error ==> " ); |
---|
| 69 | puts( "Test only supported for deterministic priority scheduler\n" ); |
---|
| 70 | rtems_test_exit( 0 ); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | #define LOW_PRIORITY (RTEMS_MAXIMUM_PRIORITY - 1u) |
---|
| 74 | status = rtems_task_create( |
---|
| 75 | rtems_build_name( 'T', 'A', '1', ' ' ), |
---|
| 76 | LOW_PRIORITY, |
---|
| 77 | RTEMS_MINIMUM_STACK_SIZE, |
---|
| 78 | RTEMS_DEFAULT_MODES, |
---|
| 79 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 80 | &Task_id |
---|
| 81 | ); |
---|
| 82 | directive_failed( status, "rtems_task_create Task_1" ); |
---|
| 83 | |
---|
| 84 | status = rtems_task_start( Task_id, Task_1, 0 ); |
---|
| 85 | directive_failed( status, "rtems_task_start Task_1" ); |
---|
| 86 | |
---|
| 87 | benchmark_timer_initialize(); |
---|
| 88 | benchmark_timer_read(); |
---|
| 89 | benchmark_timer_initialize(); |
---|
| 90 | timer_overhead = benchmark_timer_read(); |
---|
| 91 | |
---|
| 92 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 93 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | rtems_task Task_1( |
---|
| 97 | rtems_task_argument argument |
---|
| 98 | ) |
---|
| 99 | { |
---|
| 100 | Install_tm27_vector( Isr_handler ) ; |
---|
| 101 | Interrupt_nest = 0; |
---|
| 102 | |
---|
| 103 | /* Benchmark code */ |
---|
| 104 | benchmark_timer_initialize(); |
---|
| 105 | /* goes to Isr_handler */ |
---|
| 106 | Cause_tm27_intr(); |
---|
| 107 | |
---|
| 108 | put_time( |
---|
| 109 | "Rhealstone: Interrupt Latency", |
---|
| 110 | Interrupt_enter_time, |
---|
| 111 | 1, /* Only Rhealstone that isn't an average */ |
---|
| 112 | timer_overhead, |
---|
| 113 | 0 |
---|
| 114 | ); |
---|
| 115 | |
---|
[1d799ad] | 116 | TEST_END(); |
---|
[19e9bf8] | 117 | rtems_test_exit( 0 ); |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | rtems_isr Isr_handler( |
---|
| 121 | rtems_vector_number vector |
---|
| 122 | ) |
---|
| 123 | { |
---|
| 124 | /* See how long it took system to recognize interrupt */ |
---|
| 125 | Interrupt_enter_time = benchmark_timer_read(); |
---|
| 126 | Clear_tm27_intr(); |
---|
| 127 | } |
---|