source: rtems/cpukit/rtems/src/regionextend.c @ 5c7c1ec

4.104.115
Last change on this file since 5c7c1ec was 5c7c1ec, checked in by Joel Sherrill <joel.sherrill@…>, on 07/22/09 at 16:00:21

2009-07-22 Joel Sherrill <joel.sherrill@…>

  • rtems/src/regionextend.c: Remove warning.
  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 *  Region Manager - Extend (add memory to) a Region
3 *
4 *  COPYRIGHT (c) 1989-2009.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/system.h>
19#include <rtems/rtems/status.h>
20#include <rtems/rtems/support.h>
21#include <rtems/score/object.h>
22#include <rtems/rtems/options.h>
23#include <rtems/rtems/region.h>
24#include <rtems/score/states.h>
25#include <rtems/score/thread.h>
26#include <rtems/score/apimutex.h>
27
28/*PAGE
29 *
30 *  rtems_region_extend
31 *
32 *  This directive attempts to grow a region of physical contiguous memory area
33 *  from which variable sized segments can be allocated.
34 *
35 *  Input parameters:
36 *    id         - id of region to grow
37 *    start      - starting address of memory area for extension
38 *    length     - physical length in bytes to grow the region
39 *
40 *  Output parameters:
41 *    RTEMS_SUCCESSFUL - if successful
42 *    error code       - if unsuccessful
43 */
44
45rtems_status_code rtems_region_extend(
46  Objects_Id          id,
47  void               *starting_address,
48  intptr_t            length
49)
50{
51  intptr_t            amount_extended;
52  Heap_Extend_status  heap_status;
53  Objects_Locations   location;
54  rtems_status_code   return_status;
55  Region_Control     *the_region;
56
57  if ( !starting_address )
58    return RTEMS_INVALID_ADDRESS;
59
60  return_status = RTEMS_SUCCESSFUL;
61
62  _RTEMS_Lock_allocator();                      /* to prevent deletion */
63
64    the_region = _Region_Get( id, &location );
65    switch ( location ) {
66
67      case OBJECTS_LOCAL:
68
69        heap_status = _Heap_Extend(
70          &the_region->Memory,
71          starting_address,
72          length,
73          &amount_extended
74        );
75
76        if ( heap_status == HEAP_EXTEND_SUCCESSFUL ) {
77          the_region->length                += amount_extended;
78          the_region->maximum_segment_size  += amount_extended;
79        } else if ( heap_status == HEAP_EXTEND_ERROR ) {
80          return_status = RTEMS_INVALID_ADDRESS;
81        } else if ( heap_status ==  HEAP_EXTEND_NOT_IMPLEMENTED ) {
82          return_status = RTEMS_NOT_IMPLEMENTED;
83        }
84        break;
85
86#if defined(RTEMS_MULTIPROCESSING)
87      case OBJECTS_REMOTE:        /* this error cannot be returned */
88        break;
89#endif
90
91      case OBJECTS_ERROR:
92      default:
93        return_status = RTEMS_INVALID_ID;
94        break;
95    }
96
97  _RTEMS_Unlock_allocator();
98  return return_status;
99}
Note: See TracBrowser for help on using the repository browser.