source:
rtems/cpukit/rtems/src/regionextend.c
@
17bbadd
Last change on this file since 17bbadd was 17bbadd, checked in by Joel Sherrill <joel.sherrill@…>, on 05/06/04 at 19:20:04 | |
---|---|
|
|
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 | #include <rtems/system.h> |
16 | #include <rtems/rtems/status.h> |
17 | #include <rtems/rtems/support.h> |
18 | #include <rtems/score/object.h> |
19 | #include <rtems/rtems/options.h> |
20 | #include <rtems/rtems/region.h> |
21 | #include <rtems/score/states.h> |
22 | #include <rtems/score/thread.h> |
23 | #include <rtems/score/apimutex.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 | |
42 | rtems_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 | if ( !starting_address ) |
55 | return RTEMS_INVALID_ADDRESS; |
56 | |
57 | status = RTEMS_SUCCESSFUL; |
58 | |
59 | _RTEMS_Lock_allocator(); /* to prevent deletion */ |
60 | the_region = _Region_Get( id, &location ); |
61 | switch ( location ) { |
62 | case OBJECTS_REMOTE: /* this error cannot be returned */ |
63 | _RTEMS_Unlock_allocator(); |
64 | return RTEMS_INTERNAL_ERROR; |
65 | |
66 | case OBJECTS_ERROR: |
67 | _RTEMS_Unlock_allocator(); |
68 | return RTEMS_INVALID_ID; |
69 | |
70 | case OBJECTS_LOCAL: |
71 | |
72 | heap_status = _Heap_Extend( |
73 | &the_region->Memory, |
74 | starting_address, |
75 | length, |
76 | &amount_extended |
77 | ); |
78 | |
79 | switch ( heap_status ) { |
80 | case HEAP_EXTEND_SUCCESSFUL: |
81 | the_region->length += amount_extended; |
82 | the_region->maximum_segment_size += amount_extended; |
83 | break; |
84 | case HEAP_EXTEND_ERROR: |
85 | status = RTEMS_INVALID_ADDRESS; |
86 | break; |
87 | case HEAP_EXTEND_NOT_IMPLEMENTED: |
88 | status = RTEMS_NOT_IMPLEMENTED; |
89 | break; |
90 | } |
91 | _RTEMS_Unlock_allocator(); |
92 | return( status ); |
93 | } |
94 | |
95 | return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ |
96 | } |
Note: See TracBrowser
for help on using the repository browser.