RTEMS
partgetbuffer.c
Go to the documentation of this file.
1 
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 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif
20 
21 #include <rtems/rtems/partimpl.h>
22 
24  rtems_id id,
25  void **buffer
26 )
27 {
28  Partition_Control *the_partition;
29  ISR_lock_Context lock_context;
30  void *the_buffer;
31 
32  if ( buffer == NULL ) {
33  return RTEMS_INVALID_ADDRESS;
34  }
35 
36  the_partition = _Partition_Get( id, &lock_context );
37 
38  if ( the_partition == NULL ) {
39 #if defined(RTEMS_MULTIPROCESSING)
40  return _Partition_MP_Get_buffer( id, buffer );
41 #else
42  return RTEMS_INVALID_ID;
43 #endif
44  }
45 
46  _Partition_Acquire_critical( the_partition, &lock_context );
47  the_buffer = _Partition_Allocate_buffer( the_partition );
48 
49  if ( the_buffer == NULL ) {
50  _Partition_Release( the_partition, &lock_context );
51  return RTEMS_UNSATISFIED;
52  }
53 
54  the_partition->number_of_used_blocks += 1;
55  _Partition_Release( the_partition, &lock_context );
56  *buffer = the_buffer;
57  return RTEMS_SUCCESSFUL;
58 }
rtems_status_code rtems_partition_get_buffer(rtems_id id, void **buffer)
Tries to get a buffer from the specified partition.
Definition: partgetbuffer.c:23
This status code indicates that the request was not satisfied.
Definition: status.h:154
This status code indicates successful completion.
Definition: status.h:86
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:82
uintptr_t number_of_used_blocks
Definition: partdata.h:51
This status code indicates that a specified address was invalid.
Definition: status.h:133
This status code indicates that an object identifier was invalid.
Definition: status.h:106
Objects_Id rtems_id
Values of this type identify an RTEMS object.
Definition: types.h:99
Classic Partition Manager Implementation.
static __inline__ void * _Partition_Allocate_buffer(Partition_Control *the_partition)
Allocate a buffer from the_partition.
Definition: partimpl.h:44
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65