1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief RTEMS Delete Partition |
---|
5 | * @ingroup ClassicPart |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2014. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/rtems/partimpl.h> |
---|
22 | #include <rtems/rtems/attrimpl.h> |
---|
23 | #include <rtems/score/threaddispatch.h> |
---|
24 | |
---|
25 | rtems_status_code rtems_partition_delete( |
---|
26 | rtems_id id |
---|
27 | ) |
---|
28 | { |
---|
29 | Partition_Control *the_partition; |
---|
30 | Objects_Locations location; |
---|
31 | |
---|
32 | the_partition = _Partition_Get( id, &location ); |
---|
33 | switch ( location ) { |
---|
34 | |
---|
35 | case OBJECTS_LOCAL: |
---|
36 | if ( the_partition->number_of_used_blocks == 0 ) { |
---|
37 | _Objects_Close( &_Partition_Information, &the_partition->Object ); |
---|
38 | _Partition_Free( the_partition ); |
---|
39 | #if defined(RTEMS_MULTIPROCESSING) |
---|
40 | if ( _Attributes_Is_global( the_partition->attribute_set ) ) { |
---|
41 | |
---|
42 | _Objects_MP_Close( |
---|
43 | &_Partition_Information, |
---|
44 | the_partition->Object.id |
---|
45 | ); |
---|
46 | |
---|
47 | _Partition_MP_Send_process_packet( |
---|
48 | PARTITION_MP_ANNOUNCE_DELETE, |
---|
49 | the_partition->Object.id, |
---|
50 | 0, /* Not used */ |
---|
51 | 0 /* Not used */ |
---|
52 | ); |
---|
53 | } |
---|
54 | #endif |
---|
55 | |
---|
56 | _Objects_Put( &the_partition->Object ); |
---|
57 | return RTEMS_SUCCESSFUL; |
---|
58 | } |
---|
59 | _Objects_Put( &the_partition->Object ); |
---|
60 | return RTEMS_RESOURCE_IN_USE; |
---|
61 | |
---|
62 | #if defined(RTEMS_MULTIPROCESSING) |
---|
63 | case OBJECTS_REMOTE: |
---|
64 | _Thread_Dispatch(); |
---|
65 | return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; |
---|
66 | #endif |
---|
67 | |
---|
68 | case OBJECTS_ERROR: |
---|
69 | break; |
---|
70 | } |
---|
71 | |
---|
72 | return RTEMS_INVALID_ID; |
---|
73 | } |
---|