source: rtems/testsuites/rhealstone/rhilatency/ilatency.c @ 10ee41a8

Last change on this file since 10ee41a8 was 10ee41a8, checked in by Sebastian Huber <sebastian.huber@…>, on 01/23/23 at 13:56:31

tm27: Avoid function pointer casts

Add TM27_USE_VECTOR_HANDLER to select the interrupt handler type used by
the <tm27.h> implementation.

Close #4820.

  • Property mode set to 100644
File size: 2.6 KB
Line 
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_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
36const char rtems_test_name[] = "RHILATENCY";
37
38#define BENCHMARKS 50000
39
40rtems_task Task_1(
41  rtems_task_argument argument
42);
43
44uint32_t   Interrupt_nest;
45uint32_t   timer_overhead;
46uint32_t   Interrupt_enter_time;
47
48rtems_task Init(
49  rtems_task_argument argument
50)
51{
52  rtems_status_code status;
53  rtems_id Task_id;
54
55  Print_Warning();
56
57  TEST_BEGIN();
58
59  if (
60    _Scheduler_Table[ 0 ].Operations.initialize
61      != _Scheduler_priority_Initialize
62  ) {
63    puts( "  Error ==> " );
64    puts( "Test only supported for deterministic priority scheduler\n" );
65    rtems_test_exit( 0 );
66  }
67
68#define LOW_PRIORITY (RTEMS_MAXIMUM_PRIORITY - 1u)
69  status = rtems_task_create(
70    rtems_build_name( 'T', 'A', '1', ' ' ),
71    LOW_PRIORITY,
72    RTEMS_MINIMUM_STACK_SIZE,
73    RTEMS_DEFAULT_MODES,
74    RTEMS_DEFAULT_ATTRIBUTES,
75    &Task_id
76  );
77  directive_failed( status, "rtems_task_create Task_1" );
78
79  status = rtems_task_start( Task_id, Task_1, 0 );
80  directive_failed( status, "rtems_task_start Task_1" );
81
82  benchmark_timer_initialize();
83  benchmark_timer_read();
84  benchmark_timer_initialize();
85  timer_overhead = benchmark_timer_read();
86
87  rtems_task_exit();
88}
89
90#ifdef TM27_USE_VECTOR_HANDLER
91static rtems_isr Isr_handler( rtems_vector_number arg )
92#else
93static void Isr_handler( void *arg )
94#endif
95{
96  (void) arg;
97
98  /* See how long it took system to recognize interrupt */
99  Interrupt_enter_time = benchmark_timer_read();
100  Clear_tm27_intr();
101}
102
103rtems_task Task_1(
104  rtems_task_argument argument
105)
106{
107  Install_tm27_vector( Isr_handler ) ;
108  Interrupt_nest = 0;
109
110  /* Benchmark code */
111  benchmark_timer_initialize();
112  /* goes to Isr_handler */
113  Cause_tm27_intr();
114
115  put_time(
116    "Rhealstone: Interrupt Latency",
117    Interrupt_enter_time,
118    1,                             /* Only Rhealstone that isn't an average */
119    timer_overhead,
120    0
121  );
122
123  TEST_END();
124  rtems_test_exit( 0 );
125}
Note: See TracBrowser for help on using the repository browser.