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/btimer.h> |
---|
19 | #include <rtems/score/schedulerpriorityimpl.h> |
---|
20 | |
---|
21 | /* configuration information */ |
---|
22 | #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER |
---|
23 | #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER |
---|
24 | #define CONFIGURE_MAXIMUM_TASKS 2 |
---|
25 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
26 | #define CONFIGURE_SCHEDULER_PRIORITY |
---|
27 | |
---|
28 | #include <rtems/confdefs.h> |
---|
29 | |
---|
30 | #include <bsp.h> |
---|
31 | |
---|
32 | #define _RTEMS_TMTEST27 |
---|
33 | #include <tm27.h> |
---|
34 | |
---|
35 | const char rtems_test_name[] = "RHILATENCY"; |
---|
36 | |
---|
37 | #define BENCHMARKS 50000 |
---|
38 | |
---|
39 | rtems_task Task_1( |
---|
40 | rtems_task_argument argument |
---|
41 | ); |
---|
42 | |
---|
43 | uint32_t Interrupt_nest; |
---|
44 | uint32_t timer_overhead; |
---|
45 | uint32_t Interrupt_enter_time; |
---|
46 | |
---|
47 | rtems_task Init( |
---|
48 | rtems_task_argument argument |
---|
49 | ) |
---|
50 | { |
---|
51 | rtems_status_code status; |
---|
52 | rtems_id Task_id; |
---|
53 | |
---|
54 | Print_Warning(); |
---|
55 | |
---|
56 | TEST_BEGIN(); |
---|
57 | |
---|
58 | if ( |
---|
59 | _Scheduler_Table[ 0 ].Operations.initialize |
---|
60 | != _Scheduler_priority_Initialize |
---|
61 | ) { |
---|
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 | rtems_task_exit(); |
---|
87 | } |
---|
88 | |
---|
89 | #ifdef TM27_USE_VECTOR_HANDLER |
---|
90 | static rtems_isr Isr_handler( rtems_vector_number arg ) |
---|
91 | #else |
---|
92 | static void Isr_handler( void *arg ) |
---|
93 | #endif |
---|
94 | { |
---|
95 | (void) arg; |
---|
96 | |
---|
97 | /* See how long it took system to recognize interrupt */ |
---|
98 | Interrupt_enter_time = benchmark_timer_read(); |
---|
99 | Clear_tm27_intr(); |
---|
100 | } |
---|
101 | |
---|
102 | rtems_task Task_1( |
---|
103 | rtems_task_argument argument |
---|
104 | ) |
---|
105 | { |
---|
106 | Install_tm27_vector( Isr_handler ) ; |
---|
107 | Interrupt_nest = 0; |
---|
108 | |
---|
109 | /* Benchmark code */ |
---|
110 | benchmark_timer_initialize(); |
---|
111 | /* goes to Isr_handler */ |
---|
112 | Cause_tm27_intr(); |
---|
113 | |
---|
114 | put_time( |
---|
115 | "Rhealstone: Interrupt Latency", |
---|
116 | Interrupt_enter_time, |
---|
117 | 1, /* Only Rhealstone that isn't an average */ |
---|
118 | timer_overhead, |
---|
119 | 0 |
---|
120 | ); |
---|
121 | |
---|
122 | TEST_END(); |
---|
123 | rtems_test_exit( 0 ); |
---|
124 | } |
---|