source: rtems/cpukit/rtems/src/regionextend.c @ 8f6b7b5

4.104.11
Last change on this file since 8f6b7b5 was 8f6b7b5, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 11, 2009 at 10:37:38 PM

2009-10-11 Joel Sherrill <joel.sherrill@…>

  • posix/src/alarm.c: If 0 seconds do not insert timer.
  • rtems/src/regionextend.c: Eliminate warning. Use default else.
  • 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  uintptr_t           length
49)
50{
51  uintptr_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  _RTEMS_Lock_allocator();                      /* to prevent deletion */
61
62    the_region = _Region_Get( id, &location );
63    switch ( location ) {
64
65      case OBJECTS_LOCAL:
66
67        heap_status = _Heap_Extend(
68          &the_region->Memory,
69          starting_address,
70          length,
71          &amount_extended
72        );
73
74        if ( heap_status == HEAP_EXTEND_SUCCESSFUL ) {
75          the_region->length                += amount_extended;
76          the_region->maximum_segment_size  += amount_extended;
77          return_status = RTEMS_SUCCESSFUL;
78        } else if ( heap_status == HEAP_EXTEND_ERROR ) {
79          return_status = RTEMS_INVALID_ADDRESS;
80        } else /* if ( heap_status ==  HEAP_EXTEND_NOT_IMPLEMENTED ) */ {
81          return_status = RTEMS_NOT_IMPLEMENTED;
82        }
83        break;
84
85#if defined(RTEMS_MULTIPROCESSING)
86      case OBJECTS_REMOTE:        /* this error cannot be returned */
87        break;
88#endif
89
90      case OBJECTS_ERROR:
91      default:
92        return_status = RTEMS_INVALID_ID;
93        break;
94    }
95
96  _RTEMS_Unlock_allocator();
97  return return_status;
98}
Note: See TracBrowser for help on using the repository browser.