source: rtems/cpukit/rtems/src/partdelete.c @ a29d2e7

4.104.114.84.95
Last change on this file since a29d2e7 was 1095ec1, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/18/05 at 09:03:45

Include config.h.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 *  Partition Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/rtems/status.h>
21#include <rtems/rtems/support.h>
22#include <rtems/score/address.h>
23#include <rtems/score/object.h>
24#include <rtems/rtems/part.h>
25#include <rtems/score/thread.h>
26#include <rtems/score/sysstate.h>
27
28/*PAGE
29 *
30 *  rtems_partition_delete
31 *
32 *  This directive allows a thread to delete a partition specified by
33 *  the partition identifier, provided that none of its buffers are
34 *  still allocated.
35 *
36 *  Input parameters:
37 *    id - partition id
38 *
39 *  Output parameters:
40 *    RTEMS_SUCCESSFUL - if successful
41 *    error code       - if unsuccessful
42 */
43
44rtems_status_code rtems_partition_delete(
45  Objects_Id id
46)
47{
48  register Partition_Control *the_partition;
49  Objects_Locations           location;
50
51  the_partition = _Partition_Get( id, &location );
52  switch ( location ) {
53    case OBJECTS_REMOTE:
54#if defined(RTEMS_MULTIPROCESSING)
55      _Thread_Dispatch();
56      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
57#endif
58
59    case OBJECTS_ERROR:
60      return RTEMS_INVALID_ID;
61
62    case OBJECTS_LOCAL:
63      if ( the_partition->number_of_used_blocks == 0 ) {
64        _Objects_Close( &_Partition_Information, &the_partition->Object );
65        _Partition_Free( the_partition );
66#if defined(RTEMS_MULTIPROCESSING)
67        if ( _Attributes_Is_global( the_partition->attribute_set ) ) {
68
69          _Objects_MP_Close(
70            &_Partition_Information,
71            the_partition->Object.id
72          );
73
74          _Partition_MP_Send_process_packet(
75            PARTITION_MP_ANNOUNCE_DELETE,
76            the_partition->Object.id,
77            0,                         /* Not used */
78            0                          /* Not used */
79          );
80        }
81#endif
82
83        _Thread_Enable_dispatch();
84        return RTEMS_SUCCESSFUL;
85      }
86      _Thread_Enable_dispatch();
87      return RTEMS_RESOURCE_IN_USE;
88  }
89
90  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
91}
Note: See TracBrowser for help on using the repository browser.