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-1997. |
---|
20 | * On-Line Applications Research Corporation (OAR). |
---|
21 | * Copyright assigned to U.S. Government, 1994. |
---|
22 | * |
---|
23 | * The license and distribution terms for this file may in |
---|
24 | * the file LICENSE in this distribution or at |
---|
25 | * http://www.OARcorp.com/rtems/license.html. |
---|
26 | * |
---|
27 | * $Id$ |
---|
28 | */ |
---|
29 | |
---|
30 | #define TEST_INIT |
---|
31 | #include "system.h" |
---|
32 | |
---|
33 | rtems_unsigned8 Partition_area[ 1024 ] CPU_STRUCTURE_ALIGNMENT; |
---|
34 | |
---|
35 | rtems_task Init( |
---|
36 | rtems_task_argument argument |
---|
37 | ) |
---|
38 | { |
---|
39 | rtems_status_code status; |
---|
40 | void *bufaddr; |
---|
41 | |
---|
42 | printf( |
---|
43 | "\n\n*** TEST 12 -- NODE %d ***\n", |
---|
44 | Multiprocessing_configuration.node |
---|
45 | ); |
---|
46 | |
---|
47 | Task_name[ 1 ] = rtems_build_name( '1', '1', '1', ' ' ); |
---|
48 | Task_name[ 2 ] = rtems_build_name( '2', '2', '2', ' ' ); |
---|
49 | |
---|
50 | Partition_name[ 1 ] = rtems_build_name( 'P', 'A', 'R', ' ' ); |
---|
51 | |
---|
52 | puts( "Got to initialization task" ); |
---|
53 | |
---|
54 | if ( Multiprocessing_configuration.node == 2 ) { |
---|
55 | status = rtems_task_wake_after( 1 * TICKS_PER_SECOND ); |
---|
56 | directive_failed( status, "rtems_task_wake_after" ); |
---|
57 | |
---|
58 | puts( "Getting ID of remote Partition (Global)" ); |
---|
59 | |
---|
60 | do { |
---|
61 | status = rtems_partition_ident( |
---|
62 | Partition_name[ 1 ], |
---|
63 | RTEMS_SEARCH_ALL_NODES, |
---|
64 | &Partition_id[ 1 ] |
---|
65 | ); |
---|
66 | } while ( !rtems_is_status_successful( status ) ); |
---|
67 | |
---|
68 | puts( "Attempting to delete remote Partition (Global)" ); |
---|
69 | status = rtems_partition_delete( Partition_id[ 1 ] ); |
---|
70 | fatal_directive_status( |
---|
71 | status, |
---|
72 | RTEMS_ILLEGAL_ON_REMOTE_OBJECT, |
---|
73 | "rtems_partition_delete" |
---|
74 | ); |
---|
75 | puts( |
---|
76 | "rtems_partition_delete correctly returned RTEMS_ILLEGAL_ON_REMOTE_OBJECT" |
---|
77 | ); |
---|
78 | |
---|
79 | puts( "Obtaining a buffer from the global partition" ); |
---|
80 | status = rtems_partition_get_buffer( Partition_id[ 1 ], &bufaddr ); |
---|
81 | directive_failed( status, "rtems_partition_get_buffer" ); |
---|
82 | printf( "Address returned was : 0x%p\n", bufaddr ); |
---|
83 | |
---|
84 | puts( "Releasing a buffer to the global partition" ); |
---|
85 | status = rtems_partition_return_buffer( Partition_id[ 1 ], bufaddr ); |
---|
86 | directive_failed( status, "rtems_partition_return_buffer" ); |
---|
87 | |
---|
88 | status = rtems_task_wake_after( 2 * TICKS_PER_SECOND ); |
---|
89 | directive_failed( status, "rtems_task_wake_after" ); |
---|
90 | } |
---|
91 | else { |
---|
92 | puts( "Creating Partition (Global)" ); |
---|
93 | status = rtems_partition_create( |
---|
94 | Partition_name[ 1 ], |
---|
95 | Partition_area, |
---|
96 | 128, |
---|
97 | 64, |
---|
98 | RTEMS_GLOBAL, |
---|
99 | &Partition_id[ 1 ] |
---|
100 | ); |
---|
101 | directive_failed( status, "rtems_partition_create" ); |
---|
102 | |
---|
103 | puts( "Sleeping for two seconds" ); |
---|
104 | status = rtems_task_wake_after( 2 * TICKS_PER_SECOND ); |
---|
105 | directive_failed( status, "rtems_task_wake_after" ); |
---|
106 | |
---|
107 | puts( "Deleting Partition (Global)" ); |
---|
108 | status = rtems_partition_delete( Partition_id[ 1 ] ); |
---|
109 | directive_failed( status, "rtems_partition_delete" ); |
---|
110 | } |
---|
111 | puts( "*** END OF TEST 12 ***" ); |
---|
112 | exit( 0 ); |
---|
113 | } |
---|