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

4.104.114.84.95
Last change on this file since 5aa64518 was 5aa64518, checked in by Joel Sherrill <joel.sherrill@…>, on 05/17/99 at 22:39:20

Split Region Manager into one routine per file.

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