Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:44

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  COPYRIGHT (c) 1989-2011.
0005  *  On-Line Applications Research Corporation (OAR).
0006  *
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted provided that the following conditions
0009  * are met:
0010  * 1. Redistributions of source code must retain the above copyright
0011  *    notice, this list of conditions and the following disclaimer.
0012  * 2. Redistributions in binary form must reproduce the above copyright
0013  *    notice, this list of conditions and the following disclaimer in the
0014  *    documentation and/or other materials provided with the distribution.
0015  *
0016  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0017  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0019  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0020  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0021  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0022  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0023  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0024  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0025  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0026  * POSSIBILITY OF SUCH DAMAGE.
0027  */
0028 
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032 
0033 #include "system.h"
0034 
0035 rtems_timer_service_routine Signal_3_to_task_1(
0036   rtems_id  id,
0037   void     *pointer
0038 )
0039 {
0040   rtems_status_code status;
0041 
0042   status = rtems_signal_send( Task_id[ 1 ], RTEMS_SIGNAL_3 );
0043   directive_failed_with_level( status, "rtems_signal_send of 3", 1 );
0044 
0045   Timer_got_this_id  = id;
0046   Timer_got_this_pointer = pointer;
0047 
0048   Signals_sent = TRUE;
0049 }
0050 
0051 rtems_task Task_1(
0052   rtems_task_argument argument
0053 )
0054 {
0055   rtems_mode        previous_mode;
0056   rtems_status_code status;
0057 
0058 #if defined(RTEMS_SMP) || CPU_ENABLE_ROBUST_THREAD_DISPATCH == TRUE
0059   puts( "TA1 - rtems_signal_catch - RTEMS_INTERRUPT_LEVEL( 0 )" );
0060   status = rtems_signal_catch( Process_asr, RTEMS_INTERRUPT_LEVEL(0) );
0061 #else
0062   puts( "TA1 - rtems_signal_catch - RTEMS_INTERRUPT_LEVEL( 3 )" );
0063   status = rtems_signal_catch( Process_asr, RTEMS_INTERRUPT_LEVEL(3) );
0064 #endif
0065   directive_failed( status, "rtems_signal_catch" );
0066 
0067   puts( "TA1 - rtems_signal_send - RTEMS_SIGNAL_16 to self" );
0068   status = rtems_signal_send( RTEMS_SELF, RTEMS_SIGNAL_16 );
0069   directive_failed( status, "rtems_signal_send" );
0070 
0071   puts( "TA1 - rtems_signal_send - RTEMS_SIGNAL_0 to self" );
0072   status = rtems_signal_send( RTEMS_SELF, RTEMS_SIGNAL_0 );
0073   directive_failed( status, "rtems_signal_send" );
0074 
0075   puts( "TA1 - rtems_signal_catch - RTEMS_NO_ASR" );
0076   status = rtems_signal_catch( Process_asr, RTEMS_NO_ASR );
0077   directive_failed( status, "rtems_signal_catch" );
0078 
0079   puts( "TA1 - rtems_signal_send - RTEMS_SIGNAL_1 to self" );
0080   status = rtems_signal_send( RTEMS_SELF, RTEMS_SIGNAL_1 );
0081   directive_failed( status, "rtems_signal_send" );
0082 
0083   puts( "TA1 - rtems_task_mode - disable ASRs" );
0084   status = rtems_task_mode( RTEMS_NO_ASR, RTEMS_ASR_MASK, &previous_mode );
0085   directive_failed( status, "rtems_task_mode" );
0086 
0087   Timer_got_this_id = 0;
0088   Timer_got_this_pointer = NULL;
0089 
0090   puts( "TA1 - sending signal to RTEMS_SELF from timer" );
0091   status = rtems_timer_fire_after(
0092     Timer_id[ 1 ],
0093     rtems_clock_get_ticks_per_second() / 2,
0094     Signal_3_to_task_1,
0095     (void *) Task_1
0096   );
0097   directive_failed( status, "rtems_timer_fire_after" );
0098 
0099   puts( "TA1 - waiting for signal to arrive" );
0100 
0101   Signals_sent = FALSE;
0102   Asr_fired    = FALSE;
0103 
0104   while ( Signals_sent == FALSE )
0105     ;
0106 
0107   if ( Timer_got_this_id == Timer_id[ 1 ] &&
0108        Timer_got_this_pointer == Task_1 )
0109     puts( "TA1 - timer routine got the correct arguments" );
0110   else
0111     printf(
0112       "TA1 - timer got (0x%" PRIxrtems_id ", %p) instead of (0x%"
0113         PRIxrtems_id ", %p)!!!!\n",
0114       Timer_got_this_id,
0115       Timer_got_this_pointer,
0116       Timer_id[ 1 ],
0117       Task_1
0118     );
0119 
0120   puts( "TA1 - rtems_task_mode - enable ASRs" );
0121   status = rtems_task_mode( RTEMS_ASR, RTEMS_ASR_MASK, &previous_mode );
0122   directive_failed( status, "rtems_task_mode" );
0123 
0124   status = rtems_task_wake_after(2 * rtems_clock_get_ticks_per_second());
0125   directive_failed( status, "rtems_task_wake_after" );
0126 
0127   puts( "TA1 - rtems_signal_catch - asraddr of NULL" );
0128   status = rtems_signal_catch( NULL, RTEMS_DEFAULT_MODES );
0129   directive_failed( status, "rtems_signal_catch" );
0130 
0131   puts( "TA1 - rtems_task_exit" );
0132   rtems_task_exit();
0133 }