source: rtems/c/src/ada-tests/mptests/mp12/mptest.adb @ 8fbe2e6

4.115
Last change on this file since 8fbe2e6 was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 3.9 KB
Line 
1--
2--  MPTEST / BODY
3--
4--  DESCRIPTION:
5--
6--  This package is the implementation for Test 12 of the RTEMS
7--  Multiprocessor Test Suite.
8--
9--  DEPENDENCIES:
10--
11--
12--
13--  COPYRIGHT (c) 1989-2011.
14--  On-Line Applications Research Corporation (OAR).
15--
16--  The license and distribution terms for this file may in
17--  the file LICENSE in this distribution or at
18--  http://www.rtems.org/license/LICENSE.
19--
20
21with INTERFACES; use INTERFACES;
22with RTEMS;
23with RTEMS.PARTITION;
24with RTEMS.TASKS;
25with TEST_SUPPORT;
26with TEXT_IO;
27with UNSIGNED32_IO;
28
29package body MPTEST is
30
31--
32--  INIT
33--
34
35   procedure INIT (
36      ARGUMENT : in     RTEMS.TASKS.ARGUMENT
37   ) is
38      BUFFER_ADDRESS : RTEMS.ADDRESS;
39      STATUS         : RTEMS.STATUS_CODES;
40   begin
41
42      TEXT_IO.NEW_LINE( 2 );
43      TEXT_IO.PUT( "*** TEST 12 -- NODE " );
44      UNSIGNED32_IO.PUT(
45         TEST_SUPPORT.NODE,
46         WIDTH => 1
47      );
48      TEXT_IO.PUT_LINE( " ***" );
49
50      MPTEST.TASK_NAME( 1 ) := RTEMS.BUILD_NAME(  '1', '1', '1', ' ' );
51      MPTEST.TASK_NAME( 2 ) := RTEMS.BUILD_NAME(  '2', '2', '2', ' ' );
52
53      MPTEST.PARTITION_NAME( 1 ) := RTEMS.BUILD_NAME(  'P', 'A', 'R', ' ' );
54
55      TEXT_IO.PUT_LINE( "Got to the initialization task" );
56
57      if TEST_SUPPORT.NODE = 2 then
58
59         RTEMS.TASKS.WAKE_AFTER( 1 * TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
60         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
61
62         TEXT_IO.PUT_LINE( "Getting ID of remote Partition (Global)" );
63
64         loop
65
66            RTEMS.PARTITION.IDENT(
67               MPTEST.PARTITION_NAME( 1 ),
68               RTEMS.SEARCH_ALL_NODES,
69               MPTEST.PARTITION_ID( 1 ),
70               STATUS
71            );
72
73            exit when RTEMS.IS_STATUS_SUCCESSFUL( STATUS );
74
75         end loop;
76
77         TEXT_IO.PUT_LINE( 
78            "Attempting to delete remote Partition (Global)"
79         );
80
81         RTEMS.PARTITION.DELETE( MPTEST.PARTITION_ID( 1 ), STATUS ); 
82         TEST_SUPPORT.FATAL_DIRECTIVE_STATUS( 
83            STATUS, 
84            RTEMS.ILLEGAL_ON_REMOTE_OBJECT,
85            "PARTITION_DELETE" 
86         );
87
88         TEXT_IO.PUT_LINE( 
89            "partition_delete correctly returned ILLEGAL_ON_REMOTE_OBJECT!!"
90         );
91
92         TEXT_IO.PUT_LINE( "Obtaining a buffer from the global partition" );
93
94         RTEMS.PARTITION.GET_BUFFER(
95            MPTEST.PARTITION_ID( 1 ),
96            BUFFER_ADDRESS,
97            STATUS
98         ); 
99         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "PARTITION_GET_BUFFER" );
100         TEXT_IO.PUT( "Address returned was : " );
101         UNSIGNED32_IO.PUT(
102            RTEMS.SUBTRACT( BUFFER_ADDRESS, RTEMS.NULL_ADDRESS ),
103            WIDTH => 8,
104            BASE => 16
105         );
106         TEXT_IO.NEW_LINE;
107
108         RTEMS.PARTITION.RETURN_BUFFER(
109            MPTEST.PARTITION_ID( 1 ),
110            BUFFER_ADDRESS,
111            STATUS
112         ); 
113         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "PARTITION_RETURN_BUFFER" );
114
115         RTEMS.TASKS.WAKE_AFTER( 2 * TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
116         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
117
118      else
119
120         TEXT_IO.PUT_LINE( "Creating Partition (Global)" );
121         RTEMS.PARTITION.CREATE(
122            MPTEST.PARTITION_NAME( 1 ),
123            MPTEST.PARTITION_AREA( 0 )'ADDRESS,
124            128,
125            64,
126            RTEMS.GLOBAL,
127            MPTEST.PARTITION_ID( 1 ),
128            STATUS
129         );
130         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "PARTITION_CREATE" );
131
132         TEXT_IO.PUT_LINE( "Sleeping for three seconds" );
133         RTEMS.TASKS.WAKE_AFTER( 3 * TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
134         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
135
136         TEXT_IO.PUT_LINE( "Deleting Partition (Global)" );
137         RTEMS.PARTITION.DELETE( MPTEST.PARTITION_ID( 1 ), STATUS );
138         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "PARTITION_DELETE" );
139
140      end if;
141
142      TEXT_IO.PUT_LINE( "*** END OF TEST 12 ***" );
143
144      RTEMS.SHUTDOWN_EXECUTIVE( 0 );
145
146   end INIT;
147
148end MPTEST;
Note: See TracBrowser for help on using the repository browser.