source: rtems/cpukit/rtems/src/regionextend.c @ 41eb1e4

4.104.115
Last change on this file since 41eb1e4 was 41eb1e4, checked in by Joel Sherrill <joel.sherrill@…>, on 12/14/08 at 22:48:54

2008-12-14 Joel Sherrill <joel.sherrill@…>

  • libcsupport/src/realloc.c, rtems/include/rtems/rtems/region.h, rtems/src/regioncreate.c, rtems/src/regionextend.c, rtems/src/regiongetsegment.c, rtems/src/regiongetsegmentsize.c, rtems/src/regionmp.c, rtems/src/regionresizesegment.c, sapi/include/rtems/config.h, score/include/rtems/score/heap.h, score/include/rtems/score/protectedheap.h, score/src/heap.c, score/src/heapallocate.c, score/src/heapallocatealigned.c, score/src/heapextend.c, score/src/heapresizeblock.c, score/src/heapsizeofuserarea.c, score/src/pheapallocate.c, score/src/pheapallocatealigned.c, score/src/pheapextend.c, score/src/pheapgetblocksize.c, score/src/pheapresizeblock.c: Change sizes of heap/region and allocated objects in heap to intptr_t so they can be larger than a single allocatable object (e.g. size_t).
  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 *  Region Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-2007.
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  intptr_t            length
50)
51{
52  intptr_t            amount_extended;
53  Heap_Extend_status  heap_status;
54  Objects_Locations   location;
55  rtems_status_code   return_status = RTEMS_INTERNAL_ERROR;
56  Region_Control     *the_region;
57
58  if ( !starting_address )
59    return RTEMS_INVALID_ADDRESS;
60
61  _RTEMS_Lock_allocator();                      /* to prevent deletion */
62
63    the_region = _Region_Get( id, &location );
64    switch ( location ) {
65
66      case OBJECTS_LOCAL:
67
68        heap_status = _Heap_Extend(
69          &the_region->Memory,
70          starting_address,
71          length,
72          &amount_extended
73        );
74
75        switch ( heap_status ) {
76          case HEAP_EXTEND_SUCCESSFUL:
77            the_region->length                += amount_extended;
78            the_region->maximum_segment_size  += amount_extended;
79            return_status = RTEMS_SUCCESSFUL;
80            break;
81          case HEAP_EXTEND_ERROR:
82            return_status = RTEMS_INVALID_ADDRESS;
83            break;
84          case HEAP_EXTEND_NOT_IMPLEMENTED:
85            return_status = RTEMS_NOT_IMPLEMENTED;
86            break;
87        }
88        break;
89
90#if defined(RTEMS_MULTIPROCESSING)
91      case OBJECTS_REMOTE:        /* this error cannot be returned */
92        break;
93#endif
94
95      case OBJECTS_ERROR:
96        return_status = RTEMS_INVALID_ID;
97        break;
98    }
99
100  _RTEMS_Unlock_allocator();
101  return return_status;
102}
Note: See TracBrowser for help on using the repository browser.