1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief RTEMS Get Partition Buffer |
---|
5 | * @ingroup ClassicPart |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2014. |
---|
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.org/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/address.h> |
---|
25 | #include <rtems/rtems/partimpl.h> |
---|
26 | #include <rtems/score/thread.h> |
---|
27 | |
---|
28 | rtems_status_code rtems_partition_get_buffer( |
---|
29 | rtems_id id, |
---|
30 | void **buffer |
---|
31 | ) |
---|
32 | { |
---|
33 | Partition_Control *the_partition; |
---|
34 | Objects_Locations location; |
---|
35 | void *the_buffer; |
---|
36 | |
---|
37 | if ( !buffer ) |
---|
38 | return RTEMS_INVALID_ADDRESS; |
---|
39 | |
---|
40 | the_partition = _Partition_Get( id, &location ); |
---|
41 | switch ( location ) { |
---|
42 | |
---|
43 | case OBJECTS_LOCAL: |
---|
44 | the_buffer = _Partition_Allocate_buffer( the_partition ); |
---|
45 | if ( the_buffer ) { |
---|
46 | the_partition->number_of_used_blocks += 1; |
---|
47 | _Objects_Put( &the_partition->Object ); |
---|
48 | *buffer = the_buffer; |
---|
49 | return RTEMS_SUCCESSFUL; |
---|
50 | } |
---|
51 | _Objects_Put( &the_partition->Object ); |
---|
52 | return RTEMS_UNSATISFIED; |
---|
53 | |
---|
54 | #if defined(RTEMS_MULTIPROCESSING) |
---|
55 | case OBJECTS_REMOTE: |
---|
56 | _Thread_Executing->Wait.return_argument = buffer; |
---|
57 | return( |
---|
58 | _Partition_MP_Send_request_packet( |
---|
59 | PARTITION_MP_GET_BUFFER_REQUEST, |
---|
60 | id, |
---|
61 | 0 /* Not used */ |
---|
62 | ) |
---|
63 | ); |
---|
64 | #endif |
---|
65 | |
---|
66 | case OBJECTS_ERROR: |
---|
67 | break; |
---|
68 | } |
---|
69 | |
---|
70 | return RTEMS_INVALID_ID; |
---|
71 | } |
---|