1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2009. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #ifdef HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #include <tmacros.h> |
---|
15 | #include <intrcritical.h> |
---|
16 | |
---|
17 | #if defined(FIRE_AFTER) |
---|
18 | #define TEST_NAME "13" |
---|
19 | #define TEST_STRING "Timer Fire After" |
---|
20 | #define TEST_DIRECTIVE rtems_timer_fire_after |
---|
21 | |
---|
22 | #elif defined(SERVER_FIRE_AFTER) |
---|
23 | #define TEST_NAME "14" |
---|
24 | #define TEST_STRING "Timer Server Fire After" |
---|
25 | #define TEST_DIRECTIVE rtems_timer_server_fire_after |
---|
26 | |
---|
27 | #else |
---|
28 | #error "Test Mode not defined" |
---|
29 | |
---|
30 | #endif |
---|
31 | |
---|
32 | rtems_id Main_task; |
---|
33 | rtems_id Timer; |
---|
34 | |
---|
35 | rtems_timer_service_routine TimerMethod( |
---|
36 | rtems_id timer, |
---|
37 | void *arg |
---|
38 | ) |
---|
39 | { |
---|
40 | } |
---|
41 | |
---|
42 | rtems_timer_service_routine test_release_from_isr( |
---|
43 | rtems_id timer, |
---|
44 | void *arg |
---|
45 | ) |
---|
46 | { |
---|
47 | (void) rtems_timer_fire_after( Timer, 10, TimerMethod, NULL ); |
---|
48 | } |
---|
49 | |
---|
50 | rtems_task Init( |
---|
51 | rtems_task_argument ignored |
---|
52 | ) |
---|
53 | { |
---|
54 | rtems_status_code sc; |
---|
55 | int resets; |
---|
56 | |
---|
57 | puts( "\n\n*** TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" ); |
---|
58 | |
---|
59 | puts( "Init - Trying to generate timer fire from ISR while firing" ); |
---|
60 | puts( "Init - Variation is: " TEST_STRING ); |
---|
61 | |
---|
62 | puts( "Init - There is no way for the test to know if it hits the case" ); |
---|
63 | |
---|
64 | #if defined(SERVER_FIRE_AFTER) |
---|
65 | /* initiate timer server */ |
---|
66 | sc = rtems_timer_initiate_server( |
---|
67 | RTEMS_MINIMUM_PRIORITY, |
---|
68 | RTEMS_MINIMUM_STACK_SIZE, |
---|
69 | RTEMS_DEFAULT_ATTRIBUTES |
---|
70 | ); |
---|
71 | directive_failed( sc, "rtems_timer_initiate_server" ); |
---|
72 | #endif |
---|
73 | |
---|
74 | puts( "Init - rtems_timer_create - OK" ); |
---|
75 | sc = rtems_timer_create( rtems_build_name( 'P', 'E', 'R', '1' ), &Timer); |
---|
76 | directive_failed( sc, "rtems_timer_create" ); |
---|
77 | |
---|
78 | Main_task = rtems_task_self(); |
---|
79 | |
---|
80 | interrupt_critical_section_test_support_initialize( test_release_from_isr ); |
---|
81 | |
---|
82 | for (resets=0 ; resets<10 ;) { |
---|
83 | if ( interrupt_critical_section_test_support_delay() ) |
---|
84 | resets++; |
---|
85 | |
---|
86 | sc = TEST_DIRECTIVE( Timer, 10, TimerMethod, NULL ); |
---|
87 | directive_failed( sc, "rtems_timer_fire_after"); |
---|
88 | } |
---|
89 | |
---|
90 | puts( "*** END OF TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" ); |
---|
91 | rtems_test_exit(0); |
---|
92 | } |
---|
93 | |
---|
94 | /* configuration information */ |
---|
95 | |
---|
96 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
97 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
98 | |
---|
99 | #if defined(SERVER_FIRE_AFTER) |
---|
100 | #define CONFIGURE_MAXIMUM_TASKS 3 |
---|
101 | #else |
---|
102 | #define CONFIGURE_MAXIMUM_TASKS 2 |
---|
103 | #endif |
---|
104 | #define CONFIGURE_MAXIMUM_TIMERS 2 |
---|
105 | #define CONFIGURE_MICROSECONDS_PER_TICK 1000 |
---|
106 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
107 | |
---|
108 | #define CONFIGURE_INIT |
---|
109 | #include <rtems/confdefs.h> |
---|
110 | |
---|
111 | /* global variables */ |
---|