source: rtems/testsuites/sptests/spintrcritical01/init.c @ 7d3f9c6

4.115
Last change on this file since 7d3f9c6 was 7d3f9c6, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/22/11 at 07:37:03

Add HAVE_CONFIG_H.

  • Property mode set to 100644
File size: 3.9 KB
Line 
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 *  $Id$
10 */
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ 1
17#include <tmacros.h>
18#include <intrcritical.h>
19
20#if defined(FIFO_NO_TIMEOUT)
21  #define TEST_NAME                "01"
22  #define TEST_STRING              "FIFO/Without Timeout"
23  #define SEMAPHORE_OBTAIN_TIMEOUT 0
24  #define SEMAPHORE_ATTRIBUTES     RTEMS_DEFAULT_ATTRIBUTES
25
26#elif defined(FIFO_WITH_TIMEOUT)
27  #define TEST_NAME                "02"
28  #define TEST_STRING              "FIFO/With Timeout"
29  #define SEMAPHORE_OBTAIN_TIMEOUT 10
30  #define SEMAPHORE_ATTRIBUTES     RTEMS_DEFAULT_ATTRIBUTES
31
32#elif defined(PRIORITY_NO_TIMEOUT)
33  #define TEST_NAME                "03"
34  #define TEST_STRING              "Priority/Without Timeout"
35  #define SEMAPHORE_OBTAIN_TIMEOUT 0
36  #define SEMAPHORE_ATTRIBUTES     RTEMS_PRIORITY
37
38#elif defined(PRIORITY_WITH_TIMEOUT)
39  #define TEST_NAME                "04"
40  #define TEST_STRING              "Priority/With Timeout"
41  #define SEMAPHORE_OBTAIN_TIMEOUT 10
42  #define SEMAPHORE_ATTRIBUTES     RTEMS_PRIORITY
43
44#elif defined(PRIORITY_NO_TIMEOUT_REVERSE)
45  #define TEST_NAME                "05"
46  #define TEST_STRING              "Priority/Without Timeout (Reverse)"
47  #define SEMAPHORE_OBTAIN_TIMEOUT 0
48  #define SEMAPHORE_ATTRIBUTES     RTEMS_PRIORITY
49
50#else
51
52  #error "Test Mode not defined"
53#endif
54
55rtems_id Main_task;
56rtems_id Semaphore;
57volatile bool case_hit;
58
59Thread_blocking_operation_States getState(void)
60{
61  Objects_Locations  location;
62  Semaphore_Control *sem;
63
64  sem = (Semaphore_Control *)_Objects_Get(
65    &_Semaphore_Information, Semaphore, &location );
66  if ( location != OBJECTS_LOCAL ) {
67    puts( "Bad object lookup" );
68    rtems_test_exit(0);
69  }
70  _Thread_Unnest_dispatch();
71
72  return sem->Core_control.semaphore.Wait_queue.sync_state;
73}
74
75rtems_timer_service_routine test_release_from_isr(
76  rtems_id  timer,
77  void     *arg
78)
79{
80  rtems_status_code     status;
81
82  if ( getState() == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) {
83    case_hit = true;
84  }
85  status = rtems_semaphore_release( Semaphore );
86}
87
88
89
90rtems_task Init(
91  rtems_task_argument ignored
92)
93{
94  rtems_status_code     status;
95
96  puts( "\n\n*** TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" );
97
98  puts( "Init - Trying to generate semaphore release from ISR while blocking" );
99  puts( "Init - Variation is: " TEST_STRING );
100  status = rtems_semaphore_create(
101    rtems_build_name( 'S', 'M', '1', ' ' ),
102    1,
103    SEMAPHORE_ATTRIBUTES,
104    RTEMS_NO_PRIORITY,
105    &Semaphore
106  );
107  directive_failed( status, "rtems_semaphore_create of SM1" );
108
109  Main_task = rtems_task_self();
110
111  interrupt_critical_section_test_support_initialize( test_release_from_isr );
112
113  case_hit = false;
114
115  while (!case_hit) {
116    interrupt_critical_section_test_support_delay();
117
118    status = rtems_semaphore_obtain(
119      Semaphore,
120      RTEMS_DEFAULT_OPTIONS,
121      SEMAPHORE_OBTAIN_TIMEOUT
122    );
123    directive_failed( status, "rtems_semaphore_obtain" );
124  }
125
126  if ( case_hit ) {
127    puts( "Init - Case hit" );
128    puts( "*** END OF TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" );
129  } else
130    puts( "Init - Case not hit - ran too long" );
131
132  rtems_test_exit(0);
133}
134
135/* configuration information */
136
137#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
138#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
139
140#define CONFIGURE_MAXIMUM_TASKS       1
141#define CONFIGURE_MAXIMUM_TIMERS      1
142#define CONFIGURE_MAXIMUM_SEMAPHORES  1
143#define CONFIGURE_MICROSECONDS_PER_TICK  1000
144#if defined(PRIORITY_NO_TIMEOUT_REVERSE)
145  #define CONFIGURE_INIT_TASK_PRIORITY   250
146#endif
147#define CONFIGURE_MICROSECONDS_PER_TICK  1000
148#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
149
150#define CONFIGURE_INIT
151#include <rtems/confdefs.h>
152
153/* global variables */
Note: See TracBrowser for help on using the repository browser.