Back to home page

LXR

 
 

    


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

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*  Init
0004  *
0005  *  This routine is the initialization task for this test program.
0006  *  It is a user initialization task and has the responsibility for creating
0007  *  and starting the tasks that make up the test.  If the time of day
0008  *  clock is required for the test, it should also be set to a known
0009  *  value by this function.
0010  *
0011  *  Input parameters:
0012  *    argument - task argument
0013  *
0014  *  Output parameters:  NONE
0015  *
0016  *  COPYRIGHT (c) 1989-2009.
0017  *  On-Line Applications Research Corporation (OAR).
0018  *
0019  * Redistribution and use in source and binary forms, with or without
0020  * modification, are permitted provided that the following conditions
0021  * are met:
0022  * 1. Redistributions of source code must retain the above copyright
0023  *    notice, this list of conditions and the following disclaimer.
0024  * 2. Redistributions in binary form must reproduce the above copyright
0025  *    notice, this list of conditions and the following disclaimer in the
0026  *    documentation and/or other materials provided with the distribution.
0027  *
0028  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0029  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0030  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0031  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0032  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0033  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0034  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0035  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0036  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0037  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0038  * POSSIBILITY OF SUCH DAMAGE.
0039  */
0040 
0041 #ifdef HAVE_CONFIG_H
0042 #include "config.h"
0043 #endif
0044 
0045 #define CONFIGURE_INIT
0046 #include "system.h"
0047 
0048 /*
0049  * This used to be a configuration option.  If there is a real need, it can be
0050  * made a configuration option again.
0051  */
0052 #define MAX_LONG_TEST_DURATION 100
0053 
0054 uint8_t   my_partition[0x30000] CPU_STRUCTURE_ALIGNMENT;
0055 
0056 static rtems_timer_service_routine Stop_Test_TSR(
0057   rtems_id  ignored_id,
0058   void     *ignored_address
0059 )
0060 {
0061   Stop_Test = true;
0062 }
0063 
0064 rtems_task Init(
0065   rtems_task_argument argument
0066 )
0067 {
0068   rtems_status_code   status;
0069   rtems_task_priority previous_priority;
0070 
0071   printf(
0072     "\n\n*** TEST 14 -- NODE %" PRId32 " ***\n",
0073     rtems_object_get_local_node()
0074   );
0075 
0076   Stop_Test = false;
0077 
0078   status = rtems_timer_create(
0079     rtems_build_name('S', 'T', 'O', 'P'),
0080     &timer_id
0081   );
0082   directive_failed( status, "rtems_timer_create" );
0083 
0084   status = rtems_timer_fire_after(
0085     timer_id,
0086     MAX_LONG_TEST_DURATION * rtems_clock_get_ticks_per_second(),
0087     Stop_Test_TSR,
0088     NULL
0089   );
0090   directive_failed( status, "rtems_timer_fire_after" );
0091 
0092   Task_name[ 1 ] = rtems_build_name( '1', '1', '1', ' ' );
0093   Task_name[ 2 ] = rtems_build_name( '2', '2', '2', ' ' );
0094 
0095   Queue_task_name[ 1 ] = rtems_build_name( 'M', 'T', '1', ' ' );
0096   Queue_task_name[ 2 ] = rtems_build_name( 'M', 'T', '2', ' ' );
0097 
0098   Partition_task_name[ 1 ] = rtems_build_name( 'P', 'T', '1', ' ' );
0099   Partition_task_name[ 2 ] = rtems_build_name( 'P', 'T', '2', ' ' );
0100 
0101   Semaphore_task_name[ 1 ] = rtems_build_name( 'S', 'M', '1', ' ' );
0102   Semaphore_task_name[ 2 ] = rtems_build_name( 'S', 'M', '2', ' ' );
0103 
0104   Semaphore_name[ 1 ] =  rtems_build_name( 'S', 'E', 'M', ' ' );
0105 
0106   Queue_name[ 1 ] = rtems_build_name( 'M', 'S', 'G', ' ' );
0107 
0108   Partition_name[ 1 ] = rtems_build_name( 'P', 'A', 'R', ' ' );
0109 
0110   Timer_name[ 1 ] = rtems_build_name( 'T', 'M', 'R', ' ' );
0111 
0112   if ( rtems_object_get_local_node() == 1 ) {
0113     puts( "Creating Semaphore (Global)" );
0114     status = rtems_semaphore_create(
0115       Semaphore_name[ 1 ],
0116       1,
0117       RTEMS_GLOBAL,
0118       RTEMS_NO_PRIORITY,
0119       &Semaphore_id[ 1 ]
0120     );
0121     directive_failed( status, "rtems_semaphore_create" );
0122 
0123     puts( "Creating Message Queue (Global)" );
0124     status = rtems_message_queue_create(
0125       Queue_name[ 1 ],
0126       1,
0127       16,
0128       RTEMS_GLOBAL,
0129       &Queue_id[ 1 ]
0130     );
0131     directive_failed( status, "rtems_message_queue_create" );
0132 
0133     puts( "Creating Partition (Global)" );
0134     status = rtems_partition_create(
0135       Partition_name[ 1 ],
0136       (void *)my_partition,
0137       0x8000,
0138       0x3800,
0139       RTEMS_GLOBAL,
0140       &Partition_id[ 1 ]
0141     );
0142     directive_failed( status, "rtems_partition_create" );
0143   }
0144 
0145   puts( "Creating Event task (Global)" );
0146   status = rtems_task_create(
0147     Task_name[ rtems_object_get_local_node() ],
0148     2,
0149     RTEMS_MINIMUM_STACK_SIZE,
0150     RTEMS_TIMESLICE,
0151     RTEMS_GLOBAL,
0152     &Event_task_id[ 1 ]
0153   );
0154   directive_failed( status, "rtems_task_create" );
0155 
0156   puts( "Starting Event task (Global)" );
0157   status = rtems_task_start( Event_task_id[ 1 ], Test_task, 0 );
0158   directive_failed( status, "rtems_task_start" );
0159 
0160   puts( "Creating Semaphore task (Global)" );
0161   status = rtems_task_create(
0162     Semaphore_task_name[ rtems_object_get_local_node() ],
0163     2,
0164     RTEMS_MINIMUM_STACK_SIZE,
0165     RTEMS_TIMESLICE,
0166     RTEMS_GLOBAL,
0167     &Semaphore_task_id[ 1 ]
0168   );
0169   directive_failed( status, "rtems_task_create" );
0170 
0171   puts( "Starting Semaphore task (Global)" );
0172   status = rtems_task_start( Semaphore_task_id[ 1 ], Semaphore_task, 0 );
0173   directive_failed( status, "rtems_task_start" );
0174 
0175   puts( "Creating Message Queue task (Global)" );
0176   status = rtems_task_create(
0177     Queue_task_name[ rtems_object_get_local_node() ],
0178     2,
0179     RTEMS_MINIMUM_STACK_SIZE,
0180     RTEMS_TIMESLICE,
0181     RTEMS_GLOBAL,
0182     &Queue_task_id[ 1 ]
0183   );
0184   directive_failed( status, "rtems_task_create" );
0185 
0186   /* argument is index into Buffers */
0187   puts( "Starting Message Queue task (Global)" );
0188   status = rtems_task_start( Queue_task_id[ 1 ], Message_queue_task, 1 );
0189   directive_failed( status, "rtems_task_start" );
0190 
0191   puts( "Creating Partition task (Global)" );
0192   status = rtems_task_create(
0193     Partition_task_name[ rtems_object_get_local_node() ],
0194     2,
0195     RTEMS_MINIMUM_STACK_SIZE * 2,
0196     RTEMS_TIMESLICE,
0197     RTEMS_GLOBAL,
0198     &Partition_task_id[ 1 ]
0199   );
0200   directive_failed( status, "rtems_task_create" );
0201 
0202   puts( "Starting Partition task (Global)" );
0203   status = rtems_task_start( Partition_task_id[ 1 ], Partition_task, 0 );
0204   directive_failed( status, "rtems_task_start" );
0205 
0206   status = rtems_task_set_priority( RTEMS_SELF, 2, &previous_priority );
0207   directive_failed( status, "rtems_task_set_priority" );
0208 
0209   status = rtems_task_ident(
0210     RTEMS_SELF,
0211     RTEMS_SEARCH_ALL_NODES,
0212     &Task_id[ 1 ]
0213   );
0214   directive_failed( status, "rtems_task_ident" );
0215 
0216   Delayed_events_task( 1 );
0217 }