RTEMS: cpukit/include/rtems/rtems/partimpl.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
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/partdata.h>
21#include <rtems/score/address.h>
22#include <rtems/score/chainimpl.h>
23#include <rtems/score/objectimpl.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
44 RTEMS_INLINE_ROUTINE void *_Partition_Allocate_buffer (
45 Partition_Control *the_partition
46)
47{
48 return _Chain_Get_unprotected( &the_partition->Memory );
49}
50
56 RTEMS_INLINE_ROUTINE void _Partition_Free_buffer (
57 Partition_Control *the_partition,
58 Chain_Node *the_buffer
59)
60{
61 _Chain_Append_unprotected( &the_partition->Memory, the_buffer );
62}
63
70 RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_on_boundary (
71 void *the_buffer,
72 Partition_Control *the_partition
73)
74{
75 intptr_t offset;
76
77 offset = _Addresses_Subtract(
78 the_buffer,
79 the_partition->starting_address
80 );
81
82 return ((offset % the_partition->buffer_size) == 0);
83}
84
91 RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_valid (
92 Chain_Node *the_buffer,
93 Partition_Control *the_partition
94)
95{
96 void *starting;
97 void *ending;
98
99 starting = the_partition->starting_address;
100 ending = _Addresses_Add_offset( starting, the_partition->length );
101
102 return (
103 _Addresses_Is_in_range( the_buffer, starting, ending ) &&
104 _Partition_Is_buffer_on_boundary( the_buffer, the_partition )
105 );
106}
107
108 RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_size_aligned(
109 uint32_t buffer_size
110)
111{
112 return (buffer_size % CPU_SIZEOF_POINTER) == 0;
113}
114
115 RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_area_aligned(
116 const void *starting_address
117)
118{
119 return (((uintptr_t) starting_address) % CPU_SIZEOF_POINTER) == 0;
120}
121
129 RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Allocate ( void )
130{
131 return (Partition_Control *) _Objects_Allocate( &_Partition_Information );
132}
133
134 RTEMS_INLINE_ROUTINE void _Partition_Initialize(
135 Partition_Control *the_partition,
136 void *starting_address,
137 uint32_t length,
138 uint32_t buffer_size,
139 rtems_attribute attribute_set
140)
141{
142 the_partition->starting_address = starting_address;
143 the_partition->length = length;
144 the_partition->buffer_size = buffer_size;
145 the_partition->attribute_set = attribute_set;
146 the_partition->number_of_used_blocks = 0;
147
148 _Chain_Initialize(
149 &the_partition->Memory,
150 starting_address,
151 length / buffer_size,
152 buffer_size
153 );
154
155 _ISR_lock_Initialize( &the_partition->Lock, "Partition" );
156}
157
158 RTEMS_INLINE_ROUTINE void _Partition_Destroy(
159 Partition_Control *the_partition
160)
161{
162 _ISR_lock_Destroy( &the_partition->Lock );
163}
164
172 RTEMS_INLINE_ROUTINE void _Partition_Free (
173 Partition_Control *the_partition
174)
175{
176 _Objects_Free( &_Partition_Information, &the_partition->Object );
177}
178
179 RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Get(
180 Objects_Id id,
181 ISR_lock_Context *lock_context
182)
183{
184 return (Partition_Control *) _Objects_Get(
185 id,
186 lock_context,
187 &_Partition_Information
188 );
189}
190
191 RTEMS_INLINE_ROUTINE void _Partition_Acquire_critical(
192 Partition_Control *the_partition,
193 ISR_lock_Context *lock_context
194)
195{
196 _ISR_lock_Acquire( &the_partition->Lock, lock_context );
197}
198
199 RTEMS_INLINE_ROUTINE void _Partition_Release(
200 Partition_Control *the_partition,
201 ISR_lock_Context *lock_context
202)
203{
204 _ISR_lock_Release_and_ISR_enable( &the_partition->Lock, lock_context );
205}
206
209#ifdef __cplusplus
210}
211#endif
212
213#if defined(RTEMS_MULTIPROCESSING)
214#include <rtems/rtems/partmp.h>
215#endif
216
217#endif
218/* end of include file */
address.h
Information Required to Manipulate Physical Addresses.
chainimpl.h
Chain Handler API.
rtems_attribute
uint32_t rtems_attribute
Definition: attr.h:41
_Partition_Allocate
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:129
_Partition_Free
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:172
_Partition_Information
Objects_Information _Partition_Information
The Classic Partition objects information.
_Partition_Allocate_buffer
RTEMS_INLINE_ROUTINE void * _Partition_Allocate_buffer(Partition_Control *the_partition)
Allocate a buffer from the_partition.
Definition: partimpl.h:44
_Partition_Is_buffer_valid
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:91
_Partition_Free_buffer
RTEMS_INLINE_ROUTINE void _Partition_Free_buffer(Partition_Control *the_partition, Chain_Node *the_buffer)
Frees the_buffer to the_partition.
Definition: partimpl.h:56
_Partition_Is_buffer_on_boundary
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:70
_Addresses_Add_offset
RTEMS_INLINE_ROUTINE void * _Addresses_Add_offset(const void *base, uintptr_t offset)
Adds offset to an address.
Definition: address.h:55
_Addresses_Subtract
RTEMS_INLINE_ROUTINE intptr_t _Addresses_Subtract(const void *left, const void *right)
Subtracts two addresses.
Definition: address.h:95
_Addresses_Is_in_range
RTEMS_INLINE_ROUTINE bool _Addresses_Is_in_range(const void *address, const void *base, const void *limit)
Checks if address is in range.
Definition: address.h:138
RTEMS_INLINE_ROUTINE
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
_Chain_Get_unprotected
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Get_unprotected(Chain_Control *the_chain)
Gets the first node (unprotected).
Definition: chainimpl.h:630
_Chain_Initialize
void _Chain_Initialize(Chain_Control *the_chain, void *starting_address, size_t number_nodes, size_t node_size)
Initializes a chain header.
Definition: chain.c:26
_Chain_Append_unprotected
RTEMS_INLINE_ROUTINE void _Chain_Append_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Appends a node (unprotected).
Definition: chainimpl.h:680
_ISR_lock_Acquire
#define _ISR_lock_Acquire(_lock, _context)
Acquires an ISR lock inside an ISR disabled section.
Definition: isrlock.h:293
_ISR_lock_Release_and_ISR_enable
#define _ISR_lock_Release_and_ISR_enable(_lock, _context)
Releases an ISR lock.
Definition: isrlock.h:263
_ISR_lock_Destroy
#define _ISR_lock_Destroy(_lock)
Destroys an ISR lock.
Definition: isrlock.h:199
_ISR_lock_Initialize
#define _ISR_lock_Initialize(_lock, _name)
Initializes an ISR lock.
Definition: isrlock.h:185
_Objects_Free
RTEMS_INLINE_ROUTINE void _Objects_Free(Objects_Information *information, Objects_Control *the_object)
Frees an object.
Definition: objectimpl.h:930
_Objects_Allocate
Objects_Control * _Objects_Allocate(Objects_Information *information)
Allocates an object.
Definition: objectallocate.c:42
Objects_Id
uint32_t Objects_Id
Definition: object.h:80
_Objects_Get
Objects_Control * _Objects_Get(Objects_Id id, ISR_lock_Context *lock_context, const Objects_Information *information)
Maps the specified object identifier to the associated local object control block.
Definition: objectgetlocal.c:28
objectimpl.h
Inlined Routines in the Object Handler.
partdata.h
Classic Partition Manager Data Structures.
partmp.h
MP Support in Partition Manager.
Chain_Node_struct
Definition: chain.h:68
ISR_lock_Context
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
Partition_Control
Definition: partdata.h:37
Partition_Control::attribute_set
rtems_attribute attribute_set
Definition: partdata.h:49
Partition_Control::number_of_used_blocks
uintptr_t number_of_used_blocks
Definition: partdata.h:51
Partition_Control::length
uintptr_t length
Definition: partdata.h:45
Partition_Control::buffer_size
size_t buffer_size
Definition: partdata.h:47
Partition_Control::Memory
Chain_Control Memory
Definition: partdata.h:53
Partition_Control::starting_address
void * starting_address
Definition: partdata.h:43
Partition_Control::Object
Objects_Control Object
Definition: partdata.h:39