source: rtems/testsuites/sptests/spintrcritical17/init.c @ 3c8eda7

4.115
Last change on this file since 3c8eda7 was 3c8eda7, checked in by Joel Sherrill <joel.sherrill@…>, on 05/12/12 at 16:01:26

sptests - Eliminate missing prototype warnings

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 * Copyright (c) 2009
3 * embedded brains GmbH
4 * Obere Lagerstr. 30
5 * D-82178 Puchheim
6 * Germany
7 * <rtems@embedded-brains.de>
8 *
9 * The license and distribution terms for this file may be
10 * found in the file LICENSE in this distribution or at
11 * http://www.rtems.com/license/LICENSE.
12 */
13
14#ifdef HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <tmacros.h>
19#include <intrcritical.h>
20
21/* forward declarations to avoid warnings */
22rtems_task Init(rtems_task_argument argument);
23
24#define TIMER_COUNT 4
25
26#define TIMER_TRIGGER 0
27#define TIMER_RESET 1
28#define TIMER_NEVER_INTERVAL 2
29#define TIMER_NEVER_TOD 3
30
31static rtems_id timer [TIMER_COUNT];
32
33static rtems_time_of_day tod;
34
35static volatile bool case_hit;
36
37static void never_callback(rtems_id timer, void *arg)
38{
39  rtems_test_assert(false);
40}
41
42static void reset_tod_timer(void)
43{
44  rtems_status_code sc = RTEMS_SUCCESSFUL;
45
46  sc = rtems_timer_server_fire_when(
47    timer [TIMER_NEVER_TOD],
48    &tod,
49    never_callback,
50    NULL
51  );
52  directive_failed_with_level(sc, "rtems_timer_server_fire_after", -1);
53}
54
55static void reset_callback(rtems_id timer_id, void *arg)
56{
57  rtems_status_code sc = RTEMS_SUCCESSFUL;
58
59  sc = rtems_timer_reset(timer [TIMER_RESET]);
60  directive_failed_with_level(sc, "rtems_timer_reset", -1);
61
62  sc = rtems_timer_reset(timer [TIMER_NEVER_INTERVAL]);
63  directive_failed_with_level(sc, "rtems_timer_reset", -1);
64
65  reset_tod_timer();
66
67  if (!case_hit) {
68    case_hit = _Timer_server->insert_chain != NULL;
69  }
70}
71
72static void trigger_callback(rtems_id timer_id, void *arg)
73{
74  rtems_status_code sc = RTEMS_SUCCESSFUL;
75
76  if (case_hit) {
77    puts("*** END OF INTERRUPT CRITICAL SECTION 17 ***");
78
79    rtems_test_exit(0);
80  } else if (interrupt_critical_section_test_support_delay()) {
81    puts("test case not hit, give up");
82
83    rtems_test_exit(0);
84  }
85
86  sc = rtems_timer_reset(timer [TIMER_TRIGGER]);
87  directive_failed(sc, "rtems_timer_reset");
88}
89
90rtems_task Init( rtems_task_argument ignored )
91{
92  rtems_status_code sc = RTEMS_SUCCESSFUL;
93  size_t i = 0;
94
95  puts("\n\n*** TEST INTERRUPT CRITICAL SECTION 17 ***");
96
97  build_time(&tod, 4, 12, 2009, 9, 34, 11, 0);
98  sc = rtems_clock_set(&tod);
99  directive_failed(sc, "rtems_clock_set");
100
101  ++tod.year;
102
103  for (i = 0; i < TIMER_COUNT; ++i) {
104    sc = rtems_timer_create(
105      rtems_build_name('T', 'I', 'M', '0' + i),
106      &timer [i]
107    );
108    directive_failed(sc, "rtems_timer_create");
109  }
110
111  sc = rtems_timer_initiate_server(
112    RTEMS_MINIMUM_PRIORITY,
113    RTEMS_MINIMUM_STACK_SIZE,
114    RTEMS_DEFAULT_ATTRIBUTES
115  );
116  directive_failed(sc, "rtems_timer_initiate_server");
117
118  sc = rtems_timer_server_fire_after(
119    timer [TIMER_NEVER_INTERVAL],
120    2,
121    never_callback,
122    NULL
123  );
124  directive_failed(sc, "rtems_timer_server_fire_after");
125
126  reset_tod_timer();
127
128  sc = rtems_timer_fire_after(
129    timer [TIMER_RESET],
130    1,
131    reset_callback,
132    NULL
133  );
134  directive_failed(sc, "rtems_timer_fire_after");
135
136  sc = rtems_timer_server_fire_after(
137    timer [TIMER_TRIGGER],
138    1,
139    trigger_callback,
140    NULL
141  );
142  directive_failed(sc, "rtems_timer_server_fire_after");
143
144  interrupt_critical_section_test_support_initialize(NULL);
145
146  rtems_task_delete(RTEMS_SELF);
147}
148
149#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
150#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
151
152#define CONFIGURE_MICROSECONDS_PER_TICK 1000
153
154#define CONFIGURE_MAXIMUM_TASKS 2
155#define CONFIGURE_MAXIMUM_TIMERS 4
156
157#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
158
159#define CONFIGURE_INIT
160
161#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.