[eecd655] | 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 | #define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ 1 |
---|
| 13 | #include <tmacros.h> |
---|
| 14 | #include <intrcritical.h> |
---|
| 15 | |
---|
| 16 | /* common parameters */ |
---|
| 17 | #define SEMAPHORE_ATTRIBUTES RTEMS_PRIORITY |
---|
| 18 | #define SEMAPHORE_OBTAIN_TIMEOUT 0 |
---|
| 19 | |
---|
| 20 | #if defined(PRIORITY_NO_TIMEOUT_FORWARD) |
---|
| 21 | #define TEST_NAME "06" |
---|
| 22 | #define TEST_STRING "Priority/Restart Search Task (Forward)" |
---|
| 23 | |
---|
| 24 | #define INIT_PRIORITY 2 |
---|
| 25 | #define BLOCKER_PRIORITY 1 |
---|
| 26 | |
---|
| 27 | #elif defined(PRIORITY_NO_TIMEOUT_REVERSE) |
---|
| 28 | #define TEST_NAME "07" |
---|
| 29 | #define TEST_STRING "Priority/Restart Search Task (Backward)" |
---|
| 30 | #define INIT_PRIORITY 126 |
---|
| 31 | #define BLOCKER_PRIORITY 127 |
---|
| 32 | |
---|
| 33 | #else |
---|
| 34 | |
---|
| 35 | #error "Test Mode not defined" |
---|
| 36 | #endif |
---|
| 37 | |
---|
| 38 | rtems_id Main_task; |
---|
| 39 | rtems_id Secondary_task_id; |
---|
| 40 | rtems_id Semaphore; |
---|
| 41 | volatile bool case_hit; |
---|
| 42 | |
---|
| 43 | Thread_blocking_operation_States getState(void) |
---|
| 44 | { |
---|
| 45 | Objects_Locations location; |
---|
| 46 | Semaphore_Control *sem; |
---|
| 47 | |
---|
| 48 | sem = (Semaphore_Control *)_Objects_Get( |
---|
| 49 | &_Semaphore_Information, Semaphore, &location ); |
---|
| 50 | if ( location != OBJECTS_LOCAL ) { |
---|
| 51 | puts( "Bad object lookup" ); |
---|
| 52 | rtems_test_exit(0); |
---|
| 53 | } |
---|
| 54 | _Thread_Unnest_dispatch(); |
---|
| 55 | |
---|
| 56 | return sem->Core_control.semaphore.Wait_queue.sync_state; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | rtems_timer_service_routine test_release_from_isr( |
---|
| 60 | rtems_id timer, |
---|
| 61 | void *arg |
---|
| 62 | ) |
---|
| 63 | { |
---|
| 64 | (void) rtems_task_restart( Secondary_task_id, 1 ); |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | rtems_task Secondary_task( |
---|
| 68 | rtems_task_argument arg |
---|
| 69 | ) |
---|
| 70 | { |
---|
| 71 | rtems_status_code status; |
---|
| 72 | |
---|
[99fbb608] | 73 | if ( arg ) |
---|
[eecd655] | 74 | (void) rtems_semaphore_flush( Semaphore ); |
---|
| 75 | |
---|
[99fbb608] | 76 | #if defined(PRIORITY_NO_TIMEOUT_REVERSE) |
---|
[ceb3cb3] | 77 | status = rtems_task_resume( Main_task ); |
---|
| 78 | directive_failed( status, "rtems_task_resume" ); |
---|
| 79 | #endif |
---|
| 80 | |
---|
[eecd655] | 81 | status = rtems_semaphore_obtain( |
---|
| 82 | Semaphore, |
---|
| 83 | RTEMS_DEFAULT_OPTIONS, |
---|
| 84 | SEMAPHORE_OBTAIN_TIMEOUT |
---|
| 85 | ); |
---|
| 86 | directive_failed( status, "rtems_semaphore_obtain" ); |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | rtems_task Init( |
---|
| 90 | rtems_task_argument ignored |
---|
| 91 | ) |
---|
| 92 | { |
---|
| 93 | rtems_status_code status; |
---|
| 94 | int resets; |
---|
| 95 | |
---|
| 96 | puts( "\n\n*** TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" ); |
---|
| 97 | |
---|
[bbebcd2c] | 98 | #if defined(PRIORITY_NO_TIMEOUT_REVERSE) |
---|
| 99 | puts( "WARNING!!! TEST IS NOT COMPLETE!!!" ); |
---|
| 100 | puts( "WARNING!!! TEST IS NOT COMPLETE!!!" ); |
---|
| 101 | puts( "WARNING!!! TEST IS NOT COMPLETE!!!" ); |
---|
| 102 | puts( "WARNING!!! TEST IS NOT COMPLETE!!!" ); |
---|
| 103 | #endif |
---|
| 104 | |
---|
[eecd655] | 105 | puts( "Init - Trying to generate semaphore release from ISR while blocking" ); |
---|
| 106 | puts( "Init - Variation is: " TEST_STRING ); |
---|
| 107 | status = rtems_semaphore_create( |
---|
| 108 | rtems_build_name( 'S', 'M', '1', ' ' ), |
---|
| 109 | 0, |
---|
| 110 | SEMAPHORE_ATTRIBUTES, |
---|
| 111 | RTEMS_NO_PRIORITY, |
---|
| 112 | &Semaphore |
---|
| 113 | ); |
---|
| 114 | directive_failed( status, "rtems_semaphore_create of SM1" ); |
---|
| 115 | |
---|
| 116 | Main_task = rtems_task_self(); |
---|
| 117 | |
---|
| 118 | status = rtems_task_create( |
---|
| 119 | rtems_build_name( 'B', 'L', 'C', 'K' ), |
---|
| 120 | 1, |
---|
| 121 | RTEMS_MINIMUM_STACK_SIZE, |
---|
| 122 | RTEMS_NO_PREEMPT, |
---|
| 123 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 124 | &Secondary_task_id |
---|
| 125 | ); |
---|
| 126 | directive_failed( status, "rtems_task_create" ); |
---|
| 127 | |
---|
| 128 | status = rtems_task_start( Secondary_task_id, Secondary_task, 0 ); |
---|
| 129 | directive_failed( status, "rtems_task_start" ); |
---|
| 130 | |
---|
| 131 | interrupt_critical_section_test_support_initialize( test_release_from_isr ); |
---|
| 132 | |
---|
| 133 | for (resets=0 ; resets< 2 ;) { |
---|
| 134 | if ( interrupt_critical_section_test_support_delay() ) |
---|
| 135 | resets++; |
---|
[ceb3cb3] | 136 | #if defined(PRIORITY_NO_TIMEOUT_REVERSE) |
---|
| 137 | status = rtems_task_suspend( RTEMS_SELF ); |
---|
| 138 | directive_failed( status, "rtems_task_suspend" ); |
---|
| 139 | #endif |
---|
[eecd655] | 140 | |
---|
| 141 | status = rtems_semaphore_obtain( |
---|
| 142 | Semaphore, |
---|
| 143 | RTEMS_DEFAULT_OPTIONS, |
---|
| 144 | SEMAPHORE_OBTAIN_TIMEOUT |
---|
| 145 | ); |
---|
| 146 | fatal_directive_status(status, RTEMS_UNSATISFIED, "rtems_semaphore_obtain"); |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | puts( "*** END OF TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" ); |
---|
| 150 | rtems_test_exit(0); |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | /* configuration information */ |
---|
| 154 | |
---|
| 155 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
| 156 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
| 157 | |
---|
| 158 | #define CONFIGURE_MAXIMUM_TASKS 2 |
---|
| 159 | #define CONFIGURE_MAXIMUM_TIMERS 1 |
---|
| 160 | #define CONFIGURE_MAXIMUM_SEMAPHORES 1 |
---|
| 161 | #define CONFIGURE_INIT_TASK_PRIORITY INIT_PRIORITY |
---|
| 162 | #define CONFIGURE_INIT_TASK_MODE RTEMS_PREEMPT |
---|
| 163 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
| 164 | |
---|
| 165 | #define CONFIGURE_INIT |
---|
| 166 | #include <rtems/confdefs.h> |
---|
| 167 | |
---|
| 168 | /* global variables */ |
---|