source: rtems/testsuites/mptests/mp12/initimpl.h @ a00dff42

5
Last change on this file since a00dff42 was a00dff42, checked in by Sebastian Huber <sebastian.huber@…>, on 12/12/19 at 05:37:01

rtems: Add and use rtems_object_get_local_node()

Update #3841.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*  Init
2 *
3 *  This routine is the initialization routine and test code for
4 *  global partitions.  It creates a global partition, obtains and
5 *  releases a buffer, and deletes the partition.  The partition
6 *  is created on node one, and an attempt is made to delete it
7 *  by node two.
8 *  This routine is the initialization task for this test program.
9 *  It is a user initialization task and has the responsibility for creating
10 *  and starting the tasks that make up the test.  If the time of day
11 *  clock is required for the test, it should also be set to a known
12 *  value by this function.
13 *
14 *  Input parameters:
15 *    argument - task argument
16 *
17 *  Output parameters:  NONE
18 *
19 *  COPYRIGHT (c) 1989-2009.
20 *  On-Line Applications Research Corporation (OAR).
21 *
22 *  The license and distribution terms for this file may be
23 *  found in the file LICENSE in this distribution or at
24 *  http://www.rtems.org/license/LICENSE.
25 */
26
27#ifdef HAVE_CONFIG_H
28#include "config.h"
29#endif
30
31#define CONFIGURE_INIT
32#include "system.h"
33
34uint8_t   Partition_area[ 1024 ] CPU_STRUCTURE_ALIGNMENT;
35
36rtems_task Init(
37  rtems_task_argument argument
38)
39{
40  rtems_status_code  status;
41  void              *bufaddr;
42
43  printf(
44    "\n\n*** TEST 12 -- NODE %" PRId32 " ***\n",
45    rtems_object_get_local_node()
46   );
47
48  Task_name[ 1 ] = rtems_build_name( '1', '1', '1', ' ' );
49  Task_name[ 2 ] = rtems_build_name( '2', '2', '2', ' ' );
50
51  Partition_name[ 1 ] = rtems_build_name( 'P', 'A', 'R', ' ' );
52
53  puts( "Got to initialization task" );
54
55  if ( rtems_object_get_local_node() == 2 )  {
56    status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
57    directive_failed( status, "rtems_task_wake_after" );
58
59    puts( "Getting ID of remote Partition (Global)" );
60
61    do {
62      status = rtems_partition_ident(
63        Partition_name[ 1 ],
64        RTEMS_SEARCH_ALL_NODES,
65        &Partition_id[ 1 ]
66      );
67    } while ( !rtems_is_status_successful( status ) );
68
69    puts( "Attempting to delete remote Partition (Global)" );
70    status = rtems_partition_delete( Partition_id[ 1 ] );
71    fatal_directive_status(
72      status,
73      RTEMS_ILLEGAL_ON_REMOTE_OBJECT,
74      "rtems_partition_delete"
75    );
76    puts(
77     "rtems_partition_delete correctly returned RTEMS_ILLEGAL_ON_REMOTE_OBJECT"
78    );
79
80    puts( "Obtaining a buffer from the global partition" );
81    status = rtems_partition_get_buffer( Partition_id[ 1 ], &bufaddr );
82    directive_failed( status, "rtems_partition_get_buffer" );
83    printf( "Address returned was : 0x%p\n", bufaddr );
84
85    puts( "Releasing a buffer to the global partition" );
86    status = rtems_partition_return_buffer( Partition_id[ 1 ], bufaddr );
87    directive_failed( status, "rtems_partition_return_buffer" );
88
89    status = rtems_task_wake_after( 2 * rtems_clock_get_ticks_per_second() );
90    directive_failed( status, "rtems_task_wake_after" );
91  }
92  else {
93    puts( "Creating Partition (Global)" );
94    status = rtems_partition_create(
95      Partition_name[ 1 ],
96      Partition_area,
97      128,
98      64,
99      RTEMS_GLOBAL,
100      &Partition_id[ 1 ]
101    );
102    directive_failed( status, "rtems_partition_create" );
103
104    puts( "Sleeping for two seconds" );
105    status = rtems_task_wake_after( 2 * rtems_clock_get_ticks_per_second() );
106    directive_failed( status, "rtems_task_wake_after" );
107
108    puts( "Deleting Partition (Global)" );
109    status = rtems_partition_delete( Partition_id[ 1 ] );
110    directive_failed( status, "rtems_partition_delete" );
111 }
112 puts( "*** END OF TEST 12 ***" );
113 rtems_test_exit( 0 );
114}
Note: See TracBrowser for help on using the repository browser.