source: rtems/cpukit/rtems/src/regionresizesegment.c @ dea3eccb

4.104.115
Last change on this file since dea3eccb was dea3eccb, checked in by Joel Sherrill <joel.sherrill@…>, on 09/06/09 at 15:24:08

2009-09-06 Sebastian Huber <Sebastian.Huber@…>

  • libcsupport/src/free.c, libmisc/stackchk/check.c, rtems/include/rtems/rtems/region.h, rtems/src/regioncreate.c, rtems/src/regionextend.c, rtems/src/regiongetinfo.c, rtems/src/regiongetsegment.c, rtems/src/regiongetsegmentsize.c, rtems/src/regionresizesegment.c, score/src/pheapallocate.c, score/src/pheapallocatealigned.c, score/src/pheapextend.c, score/src/pheapfree.c, score/src/pheapgetblocksize.c, score/src/pheapgetfreeinfo.c, score/src/pheapgetinfo.c, score/src/pheapgetsize.c, score/src/pheapinit.c, score/src/pheapresizeblock.c, score/src/pheapwalk.c: Update for heap API changes.
  • score/include/rtems/score/apimutex.h, score/include/rtems/score/object.h: Documentation.
  • score/include/rtems/score/heap.h, score/include/rtems/score/protectedheap.h, score/inline/rtems/score/heap.inl, score/src/heap.c, score/src/heapallocate.c, score/src/heapallocatealigned.c, score/src/heapextend.c, score/src/heapfree.c, score/src/heapgetfreeinfo.c, score/src/heapgetinfo.c, score/src/heapresizeblock.c, score/src/heapsizeofuserarea.c, score/src/heapwalk.c: Overall cleanup. Added boundary constraint to allocation function. More changes follow.
  • Property mode set to 100644
File size: 2.5 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_resize_segment
32 *
33 *  This directive will try to resize segment to the new size 'size'
34 *  "in place".
35 *
36 *  Input parameters:
37 *    id      - region id
38 *    segment - pointer to segment address
39 *    size    - new required size
40 *
41 *  Output parameters:
42 *    RTEMS_SUCCESSFUL - if successful
43 *    error code       - if unsuccessful
44 */
45
46rtems_status_code rtems_region_resize_segment(
47  Objects_Id  id,
48  void       *segment,
49  uintptr_t   size,
50  uintptr_t  *old_size
51)
52{
53  uintptr_t                avail_size;
54  Objects_Locations        location;
55  uintptr_t                osize;
56  rtems_status_code        return_status = RTEMS_INTERNAL_ERROR;
57  Heap_Resize_status       status;
58  register Region_Control *the_region;
59
60  if ( !old_size )
61    return RTEMS_INVALID_ADDRESS;
62
63  _RTEMS_Lock_allocator();
64
65    the_region = _Region_Get( id, &location );
66    switch ( location ) {
67
68      case OBJECTS_LOCAL:
69
70        _Region_Debug_Walk( the_region, 7 );
71
72        status = _Heap_Resize_block(
73          &the_region->Memory,
74          segment,
75          (uint32_t) size,
76          &osize,
77          &avail_size
78        );
79        *old_size = (uint32_t) osize;
80
81        _Region_Debug_Walk( the_region, 8 );
82
83        if ( status == HEAP_RESIZE_SUCCESSFUL && avail_size > 0 )
84          _Region_Process_queue( the_region );    /* unlocks allocator */
85        else
86          _RTEMS_Unlock_allocator();
87
88        return
89          (status == HEAP_RESIZE_SUCCESSFUL) ?  RTEMS_SUCCESSFUL :
90          (status == HEAP_RESIZE_UNSATISFIED) ? RTEMS_UNSATISFIED :
91          RTEMS_INVALID_ADDRESS;
92        break;
93
94#if defined(RTEMS_MULTIPROCESSING)
95      case OBJECTS_REMOTE:        /* this error cannot be returned */
96        break;
97#endif
98
99      case OBJECTS_ERROR:
100        return_status = RTEMS_INVALID_ID;
101        break;
102    }
103
104  _RTEMS_Unlock_allocator();
105  return return_status;
106}
Note: See TracBrowser for help on using the repository browser.