1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief RTEMS Get Region Segment Size |
---|
5 | * @ingroup ClassicRegion |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2007. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/system.h> |
---|
22 | #include <rtems/rtems/status.h> |
---|
23 | #include <rtems/rtems/support.h> |
---|
24 | #include <rtems/score/object.h> |
---|
25 | #include <rtems/rtems/options.h> |
---|
26 | #include <rtems/rtems/regionimpl.h> |
---|
27 | #include <rtems/score/apimutex.h> |
---|
28 | |
---|
29 | rtems_status_code rtems_region_get_segment_size( |
---|
30 | rtems_id id, |
---|
31 | void *segment, |
---|
32 | uintptr_t *size |
---|
33 | ) |
---|
34 | { |
---|
35 | Objects_Locations location; |
---|
36 | rtems_status_code return_status = RTEMS_SUCCESSFUL; |
---|
37 | register Region_Control *the_region; |
---|
38 | |
---|
39 | if ( !segment ) |
---|
40 | return RTEMS_INVALID_ADDRESS; |
---|
41 | |
---|
42 | if ( !size ) |
---|
43 | return RTEMS_INVALID_ADDRESS; |
---|
44 | |
---|
45 | _RTEMS_Lock_allocator(); |
---|
46 | |
---|
47 | the_region = _Region_Get( id, &location ); |
---|
48 | switch ( location ) { |
---|
49 | |
---|
50 | case OBJECTS_LOCAL: |
---|
51 | if ( !_Heap_Size_of_alloc_area( &the_region->Memory, segment, size ) ) |
---|
52 | return_status = RTEMS_INVALID_ADDRESS; |
---|
53 | break; |
---|
54 | |
---|
55 | #if defined(RTEMS_MULTIPROCESSING) |
---|
56 | case OBJECTS_REMOTE: /* this error cannot be returned */ |
---|
57 | break; |
---|
58 | #endif |
---|
59 | |
---|
60 | case OBJECTS_ERROR: |
---|
61 | return_status = RTEMS_INVALID_ID; |
---|
62 | break; |
---|
63 | } |
---|
64 | |
---|
65 | _RTEMS_Unlock_allocator(); |
---|
66 | return return_status; |
---|
67 | } |
---|