RTEMS CPU Kit with SuperCore  4.11.3
partimpl.h
Go to the documentation of this file.
1 
9 /* COPYRIGHT (c) 1989-2008.
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 #ifndef _RTEMS_RTEMS_PARTIMPL_H
18 #define _RTEMS_RTEMS_PARTIMPL_H
19 
20 #include <rtems/rtems/part.h>
21 #include <rtems/score/chainimpl.h>
22 #include <rtems/score/objectimpl.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
44 #ifndef RTEMS_PART_EXTERN
45 #define RTEMS_PART_EXTERN extern
46 #endif
47 
53 
60 
69  Partition_Control *the_partition
70 )
71 {
72  return _Chain_Get( &the_partition->Memory );
73 }
74 
81  Partition_Control *the_partition,
82  Chain_Node *the_buffer
83 )
84 {
85  _Chain_Append( &the_partition->Memory, the_buffer );
86 }
87 
95  void *the_buffer,
96  Partition_Control *the_partition
97 )
98 {
99  uint32_t offset;
100 
101  offset = (uint32_t) _Addresses_Subtract(
102  the_buffer,
103  the_partition->starting_address
104  );
105 
106  return ((offset % the_partition->buffer_size) == 0);
107 }
108 
116  Chain_Node *the_buffer,
117  Partition_Control *the_partition
118 )
119 {
120  void *starting;
121  void *ending;
122 
123  starting = the_partition->starting_address;
124  ending = _Addresses_Add_offset( starting, the_partition->length );
125 
126  return (
127  _Addresses_Is_in_range( the_buffer, starting, ending ) &&
128  _Partition_Is_buffer_on_boundary( the_buffer, the_partition )
129  );
130 }
131 
140  uint32_t buffer_size
141 )
142 {
143  return ((buffer_size % CPU_PARTITION_ALIGNMENT) == 0);
144 }
145 
154 {
155  return (Partition_Control *) _Objects_Allocate( &_Partition_Information );
156 }
157 
166  Partition_Control *the_partition
167 )
168 {
169  _Objects_Free( &_Partition_Information, &the_partition->Object );
170 }
171 
184  Objects_Id id,
185  Objects_Locations *location
186 )
187 {
188  return (Partition_Control *)
189  _Objects_Get( &_Partition_Information, id, location );
190 }
191 
194 #ifdef __cplusplus
195 }
196 #endif
197 
198 #if defined(RTEMS_MULTIPROCESSING)
199 #include <rtems/rtems/partmp.h>
200 #endif
201 
202 #endif
203 /* end of include file */
void _Objects_Free(Objects_Information *information, Objects_Control *the_object)
Frees an object.
Definition: objectfree.c:25
This is used to manage each element (node) which is placed on a chain.
Definition: chain.h:65
RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_size_aligned(uint32_t buffer_size)
Checks if partition is buffer size aligned.
Definition: partimpl.h:139
RTEMS_INLINE_ROUTINE Partition_Control * _Partition_Allocate(void)
Allocates a partition control block from the inactive chain of free partition control blocks...
Definition: partimpl.h:153
Objects_Control Object
This field is the object management portion of a Partition instance.
Definition: part.h:57
Chain_Node * _Chain_Get(Chain_Control *the_chain)
Obtain the first node on a chain.
Definition: chainget.c:26
Objects_Control * _Objects_Allocate(Objects_Information *information)
Allocates an object.
Definition: objectallocate.c:101
RTEMS_INLINE_ROUTINE int32_t _Addresses_Subtract(const void *left, const void *right)
Subtract two offsets.
Definition: address.h:93
#define RTEMS_INLINE_ROUTINE
The following (in conjunction with compiler arguments) are used to choose between the use of static i...
Definition: basedefs.h:135
RTEMS_INLINE_ROUTINE Partition_Control * _Partition_Get(Objects_Id id, Objects_Locations *location)
Maps partition IDs to partition control blocks.
Definition: partimpl.h:183
RTEMS_INLINE_ROUTINE void * _Addresses_Add_offset(const void *base, uintptr_t offset)
Add offset to an address.
Definition: address.h:50
void * starting_address
This field is the physical starting address of the Partition.
Definition: part.h:59
#define RTEMS_PART_EXTERN
This constant is defined to extern most of the time when using this header file.
Definition: partimpl.h:45
RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_valid(Chain_Node *the_buffer, Partition_Control *the_partition)
Checks whether the_buffer is a valid buffer from the_partition.
Definition: partimpl.h:115
RTEMS_INLINE_ROUTINE bool _Addresses_Is_in_range(const void *address, const void *base, const void *limit)
Is address in range.
Definition: address.h:140
Objects_Control * _Objects_Get(Objects_Information *information, Objects_Id id, Objects_Locations *location)
Maps object ids to object control blocks.
Definition: objectget.c:23
intptr_t length
This field is the size of the Partition in bytes.
Definition: part.h:61
void _Partition_Manager_initialization(void)
Partition Manager Initialization.
Definition: part.c:29
The following defines the structure for the information used to manage each class of objects...
Definition: objectimpl.h:136
Chain Handler API.
MP Support in Partition Manager.
The following defines the control block used to manage each partition.
Definition: part.h:55
void _Chain_Append(Chain_Control *the_chain, Chain_Node *the_node)
Append a node on the end of a chain.
Definition: chainappend.c:41
Objects_Locations
This enumerated type lists the locations which may be returned by _Objects_Get.
Definition: objectimpl.h:117
RTEMS_PART_EXTERN Objects_Information _Partition_Information
The following defines the information control block used to manage this class of objects.
Definition: partimpl.h:52
RTEMS_INLINE_ROUTINE void _Partition_Free(Partition_Control *the_partition)
Frees a partition control block to the inactive chain of free partition control blocks.
Definition: partimpl.h:165
Chain_Control Memory
This field is the chain used to manage unallocated buffers.
Definition: part.h:69
uint32_t buffer_size
This field is the size of each buffer in bytes.
Definition: part.h:63
Inlined Routines in the Object Handler.
uint32_t Objects_Id
The following type defines the control block used to manage object IDs.
Definition: object.h:122
RTEMS_INLINE_ROUTINE void _Partition_Free_buffer(Partition_Control *the_partition, Chain_Node *the_buffer)
Frees the_buffer to the_partition.
Definition: partimpl.h:80
RTEMS_INLINE_ROUTINE void * _Partition_Allocate_buffer(Partition_Control *the_partition)
Allocate a buffer from the_partition.
Definition: partimpl.h:68
RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_on_boundary(void *the_buffer, Partition_Control *the_partition)
Checks whether is on a valid buffer boundary for the_partition.
Definition: partimpl.h:94