source:
rtems/cpukit/rtems/src/partgetbuffer.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.0 KB |
Line | |
---|---|
1 | /* |
2 | * Partition 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/address.h> |
19 | #include <rtems/score/object.h> |
20 | #include <rtems/rtems/part.h> |
21 | #include <rtems/score/thread.h> |
22 | #include <rtems/score/sysstate.h> |
23 | |
24 | /*PAGE |
25 | * |
26 | * rtems_partition_get_buffer |
27 | * |
28 | * This directive will obtain a buffer from a buffer partition. |
29 | * |
30 | * Input parameters: |
31 | * id - partition id |
32 | * buffer - pointer to buffer address |
33 | * |
34 | * Output parameters: |
35 | * buffer - pointer to buffer address filled in |
36 | * RTEMS_SUCCESSFUL - if successful |
37 | * error code - if unsuccessful |
38 | */ |
39 | |
40 | rtems_status_code rtems_partition_get_buffer( |
41 | Objects_Id id, |
42 | void **buffer |
43 | ) |
44 | { |
45 | register Partition_Control *the_partition; |
46 | Objects_Locations location; |
47 | void *the_buffer; |
48 | |
49 | if ( !buffer ) |
50 | return RTEMS_INVALID_ADDRESS; |
51 | |
52 | the_partition = _Partition_Get( id, &location ); |
53 | switch ( location ) { |
54 | case OBJECTS_REMOTE: |
55 | #if defined(RTEMS_MULTIPROCESSING) |
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 | return RTEMS_INVALID_ID; |
68 | |
69 | case OBJECTS_LOCAL: |
70 | the_buffer = _Partition_Allocate_buffer( the_partition ); |
71 | if ( the_buffer ) { |
72 | the_partition->number_of_used_blocks += 1; |
73 | _Thread_Enable_dispatch(); |
74 | *buffer = the_buffer; |
75 | return RTEMS_SUCCESSFUL; |
76 | } |
77 | _Thread_Enable_dispatch(); |
78 | return RTEMS_UNSATISFIED; |
79 | } |
80 | |
81 | return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ |
82 | } |
Note: See TracBrowser
for help on using the repository browser.