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