source: rtems/cpukit/rtems/src/partreturnbuffer.c @ e7541849

4.104.114.84.95
Last change on this file since e7541849 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: 1.8 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_return_buffer
31 *
32 *  This directive will return the given buffer to the specified
33 *  buffer partition.
34 *
35 *  Input parameters:
36 *    id     - partition id
37 *    buffer - pointer to buffer address
38 *
39 *  Output parameters:
40 *    RTEMS_SUCCESSFUL - if successful
41 *    error code - if unsuccessful
42 */
43
44rtems_status_code rtems_partition_return_buffer(
45  Objects_Id  id,
46  void       *buffer
47)
48{
49  register Partition_Control *the_partition;
50  Objects_Locations           location;
51
52  the_partition = _Partition_Get( id, &location );
53  switch ( location ) {
54
55    case OBJECTS_REMOTE:
56#if defined(RTEMS_MULTIPROCESSING)
57      return _Partition_MP_Send_request_packet(
58          PARTITION_MP_RETURN_BUFFER_REQUEST,
59          id,
60          buffer
61        );
62#endif
63
64    case OBJECTS_ERROR:
65      return RTEMS_INVALID_ID;
66
67    case OBJECTS_LOCAL:
68      if ( _Partition_Is_buffer_valid( buffer, the_partition ) ) {
69        _Partition_Free_buffer( the_partition, buffer );
70        the_partition->number_of_used_blocks -= 1;
71        _Thread_Enable_dispatch();
72        return RTEMS_SUCCESSFUL;
73      }
74      _Thread_Enable_dispatch();
75      return RTEMS_INVALID_ADDRESS;
76  }
77
78  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
79}
Note: See TracBrowser for help on using the repository browser.