source: rtems/c/src/exec/rtems/src/partreturnbuffer.c @ 842db5f3

4.104.114.84.95
Last change on this file since 842db5f3 was 842db5f3, checked in by Joel Sherrill <joel.sherrill@…>, on 05/17/99 at 23:15:20

Split Partition Manager into one routine per file.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 *  Partition Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-1998.
6 *  On-Line Applications Research Corporation (OAR).
7 *  Copyright assigned to U.S. Government, 1994.
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#include <rtems/system.h>
17#include <rtems/rtems/status.h>
18#include <rtems/rtems/support.h>
19#include <rtems/score/address.h>
20#include <rtems/score/object.h>
21#include <rtems/rtems/part.h>
22#include <rtems/score/thread.h>
23#include <rtems/score/sysstate.h>
24
25/*PAGE
26 *
27 *  rtems_partition_return_buffer
28 *
29 *  This directive will return the given buffer to the specified
30 *  buffer partition.
31 *
32 *  Input parameters:
33 *    id     - partition id
34 *    buffer - pointer to buffer address
35 *
36 *  Output parameters:
37 *    RTEMS_SUCCESSFUL - if successful
38 *    error code - if unsuccessful
39 */
40
41rtems_status_code rtems_partition_return_buffer(
42  Objects_Id  id,
43  void       *buffer
44)
45{
46  register Partition_Control *the_partition;
47  Objects_Locations           location;
48
49  the_partition = _Partition_Get( id, &location );
50  switch ( location ) {
51
52    case OBJECTS_REMOTE:
53#if defined(RTEMS_MULTIPROCESSING)
54      return _Partition_MP_Send_request_packet(
55          PARTITION_MP_RETURN_BUFFER_REQUEST,
56          id,
57          buffer
58        );
59#endif
60
61    case OBJECTS_ERROR:
62      return RTEMS_INVALID_ID;
63
64    case OBJECTS_LOCAL:
65      if ( _Partition_Is_buffer_valid( buffer, the_partition ) ) {
66        _Partition_Free_buffer( the_partition, buffer );
67        the_partition->number_of_used_blocks -= 1;
68        _Thread_Enable_dispatch();
69        return RTEMS_SUCCESSFUL;
70      }
71      _Thread_Enable_dispatch();
72      return RTEMS_INVALID_ADDRESS;
73  }
74
75  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
76}
Note: See TracBrowser for help on using the repository browser.