source: rtems/testsuites/sptests/spintrcritical06/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.5 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2012.
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#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ 1
15#include <tmacros.h>
16#include <intrcritical.h>
17
18/* forward declarations to avoid warnings */
19rtems_task Init(rtems_task_argument argument);
20rtems_timer_service_routine test_release_from_isr(rtems_id  timer, void *arg);
21rtems_task Secondary_task(rtems_task_argument arg);
22
23/* common parameters */
24#define SEMAPHORE_ATTRIBUTES     RTEMS_PRIORITY
25
26#if defined(PRIORITY_NO_TIMEOUT_FORWARD)
27  #define TEST_NAME          "06"
28  #define TEST_STRING        "Priority/Restart Search Task (Forward)"
29
30  #define INIT_PRIORITY      2
31  #define BLOCKER_PRIORITY   1
32  #define SEMAPHORE_OBTAIN_TIMEOUT 2
33
34#elif defined(PRIORITY_NO_TIMEOUT_REVERSE)
35  #define TEST_NAME          "07"
36  #define TEST_STRING        "Priority/Restart Search Task (Backward)"
37  #define INIT_PRIORITY      126
38  #define BLOCKER_PRIORITY   127
39  #define SEMAPHORE_OBTAIN_TIMEOUT 0
40
41#else
42
43  #error "Test Mode not defined"
44#endif
45
46rtems_id Secondary_task_id;
47rtems_id Semaphore;
48
49rtems_timer_service_routine test_release_from_isr(
50  rtems_id  timer,
51  void     *arg
52)
53{
54  (void) rtems_task_restart( Secondary_task_id, 1 );
55}
56
57rtems_task Secondary_task(
58  rtems_task_argument arg
59)
60{
61  if ( arg )
62    (void) rtems_semaphore_flush( Semaphore );
63
64  (void) rtems_semaphore_obtain(
65    Semaphore,
66    RTEMS_DEFAULT_OPTIONS,
67    RTEMS_NO_TIMEOUT
68  );
69
70  rtems_test_assert(0);
71}
72
73rtems_task Init(
74  rtems_task_argument ignored
75)
76{
77  rtems_status_code     status;
78  int                   resets;
79
80  puts( "\n\n*** TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" );
81
82  puts( "Init - Trying to generate semaphore release from ISR while blocking" );
83  puts( "Init - There is no way for the test to know if it hits the case" );
84  puts( "Init - Variation is: " TEST_STRING );
85  status = rtems_semaphore_create(
86    rtems_build_name( 'S', 'M', '1', ' ' ),
87    0,
88    SEMAPHORE_ATTRIBUTES,
89    RTEMS_NO_PRIORITY,
90    &Semaphore
91  );
92  directive_failed( status, "rtems_semaphore_create of SM1" );
93
94  status = rtems_task_create(
95    rtems_build_name( 'B', 'L', 'C', 'K' ),
96    BLOCKER_PRIORITY,
97    RTEMS_MINIMUM_STACK_SIZE,
98    RTEMS_NO_PREEMPT,
99    RTEMS_DEFAULT_ATTRIBUTES,
100    &Secondary_task_id
101  );
102  directive_failed( status, "rtems_task_create" );
103
104  status = rtems_task_start( Secondary_task_id, Secondary_task, 0 );
105  directive_failed( status, "rtems_task_start" );
106
107  interrupt_critical_section_test_support_initialize( test_release_from_isr );
108
109  for (resets=0 ; resets< 2 ;) {
110    if ( interrupt_critical_section_test_support_delay() )
111      resets++;
112
113    status = rtems_semaphore_obtain(
114      Semaphore,
115      RTEMS_DEFAULT_OPTIONS,
116      SEMAPHORE_OBTAIN_TIMEOUT
117    );
118  }
119
120  puts( "*** END OF TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" );
121  rtems_test_exit(0);
122}
123
124/* configuration information */
125
126#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
127#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
128
129#define CONFIGURE_MAXIMUM_TASKS       2
130#define CONFIGURE_MAXIMUM_TIMERS      1
131#define CONFIGURE_MAXIMUM_SEMAPHORES  1
132#define CONFIGURE_INIT_TASK_PRIORITY  INIT_PRIORITY
133#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_PREEMPT
134#define CONFIGURE_MICROSECONDS_PER_TICK  2000
135#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
136
137#define CONFIGURE_INIT
138#include <rtems/confdefs.h>
139
140/* global variables */
Note: See TracBrowser for help on using the repository browser.