source: rtems/cpukit/rtems/src/regionextend.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.5 KB
Line 
1/*
2 *  Region 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/object.h>
23#include <rtems/rtems/options.h>
24#include <rtems/rtems/region.h>
25#include <rtems/score/states.h>
26#include <rtems/score/thread.h>
27#include <rtems/score/apimutex.h>
28
29/*PAGE
30 *
31 *  rtems_region_extend
32 *
33 *  This directive attempts to grow a region of physical contiguous memory area
34 *  from which variable sized segments can be allocated.
35 *
36 *  Input parameters:
37 *    id         - id of region to grow
38 *    start      - starting address of memory area for extension
39 *    length     - physical length in bytes to grow the region
40 *
41 *  Output parameters:
42 *    RTEMS_SUCCESSFUL - if successful
43 *    error code       - if unsuccessful
44 */
45
46rtems_status_code rtems_region_extend(
47  Objects_Id          id,
48  void               *starting_address,
49  uint32_t            length
50)
51{
52  Region_Control     *the_region;
53  Objects_Locations   location;
54  uint32_t            amount_extended;
55  Heap_Extend_status  heap_status;
56  rtems_status_code   status;
57
58  if ( !starting_address )
59    return RTEMS_INVALID_ADDRESS;
60
61  status = RTEMS_SUCCESSFUL;
62
63  _RTEMS_Lock_allocator();                      /* to prevent deletion */
64  the_region = _Region_Get( id, &location );
65  switch ( location ) {
66    case OBJECTS_REMOTE:        /* this error cannot be returned */
67      _RTEMS_Unlock_allocator();
68      return RTEMS_INTERNAL_ERROR;
69
70    case OBJECTS_ERROR:
71      _RTEMS_Unlock_allocator();
72      return RTEMS_INVALID_ID;
73
74    case OBJECTS_LOCAL:
75
76      heap_status = _Heap_Extend(
77        &the_region->Memory,
78        starting_address,
79        length,
80        &amount_extended
81      );
82
83      switch ( heap_status ) {
84        case HEAP_EXTEND_SUCCESSFUL:
85          the_region->length                += amount_extended;
86          the_region->maximum_segment_size  += amount_extended;
87          break;
88        case HEAP_EXTEND_ERROR:
89          status = RTEMS_INVALID_ADDRESS;
90          break;
91        case HEAP_EXTEND_NOT_IMPLEMENTED:
92          status = RTEMS_NOT_IMPLEMENTED;
93          break;
94      }
95      _RTEMS_Unlock_allocator();
96      return( status );
97  }
98
99  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
100}
Note: See TracBrowser for help on using the repository browser.