source: rtems/cpukit/include/rtems/score/protectedheap.h @ 5803f37

5
Last change on this file since 5803f37 was 1e6a7c7a, checked in by Andreas Dachsberger <andreas.dachsberger@…>, on 04/11/19 at 07:36:03

doxygen: score: adjust doc in protectedheap.h to doxygen guidelines

Update #3706.

  • Property mode set to 100644
File size: 8.9 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup RTEMSScoreProtHeap
5 *
6 * @brief Protected Heap Handler API
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2007.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#ifndef _RTEMS_SCORE_PROTECTED_HEAP_H
19#define _RTEMS_SCORE_PROTECTED_HEAP_H
20
21#include <rtems/score/heapimpl.h>
22#include <rtems/score/apimutex.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/**
29 * @defgroup RTEMSScoreProtHeap Protected Heap Handler
30 *
31 * @ingroup RTEMSScoreHeap
32 *
33 * @brief Provides protected heap services.
34 *
35 * The @ref ScoreAllocatorMutex is used to protect the heap accesses.
36 *
37 * @{
38 */
39
40/**
41 * @brief Initializes the protected heap.
42 *
43 * @param[out] heap The heap to initialize.
44 * @param area_begin The starting address of the heap area.
45 * @param area_size The size of the heap area.
46 * @param page_size The page size for the heap.
47 */
48RTEMS_INLINE_ROUTINE uintptr_t _Protected_heap_Initialize(
49  Heap_Control *heap,
50  void *area_begin,
51  uintptr_t area_size,
52  uintptr_t page_size
53)
54{
55  return _Heap_Initialize( heap, area_begin, area_size, page_size );
56}
57
58/**
59 * @brief Extends the protected heap.
60 *
61 * @param[in, out] heap The heap to extend.
62 * @param area_begin The starting addres of the area to extend @a heap with.
63 * @param area_size The size of the heap area.
64 *
65 * @retval true The operation succeeded.
66 * @retval false The operation failed.
67 */
68bool _Protected_heap_Extend(
69  Heap_Control *heap,
70  void *area_begin,
71  uintptr_t area_size
72);
73
74/**
75 * @brief Allocates an aligned memory area with boundary constraint for the protected heap.
76 *
77 * A size value of zero will return a unique address which may be freed with
78 * _Heap_Free().  This method first locks the allocator and after the allocation of the memory
79 * area, unlocks it again.
80 *
81 * @param[in, out] heap The heap to allocate a memory are from.
82 * @param size The size of the desired memory are in bytes.
83 * @param alignment The allocated memory area will begin at an address aligned by this value.
84 * @param boundary The allocated memory area will fulfill a boundary constraint,
85 *      if this value is not equal to zero.  The boundary value specifies
86 *      the set of addresses which are aligned by the boundary value.  The
87 *      interior of the allocated memory area will not contain an element of this
88 *      set.  The begin or end address of the area may be a member of the set.
89 *
90 * @retval pointer The starting address of the allocated memory area.
91 * @retval NULL No memory is available of the parameters are inconsistent.
92 */
93void *_Protected_heap_Allocate_aligned_with_boundary(
94  Heap_Control *heap,
95  uintptr_t size,
96  uintptr_t alignment,
97  uintptr_t boundary
98);
99
100/**
101 * @brief Allocates an aligned memory area.
102 *
103 * A size value of zero will return a unique address which may be freed with
104 * _Heap_Free().  This method first locks the allocator and after the allocation of the memory
105 * area, unlocks it again.
106 *
107 * @param[in, out] heap The heap to allocate a memory are from.
108 * @param size The size of the desired memory are in bytes.
109 * @param alignment The allocated memory area will begin at an address aligned by this value.
110 *
111 * @retval pointer The starting address of the allocated memory area.
112 * @retval NULL No memory is available of the parameters are inconsistent.
113 */
114RTEMS_INLINE_ROUTINE void *_Protected_heap_Allocate_aligned(
115  Heap_Control *heap,
116  uintptr_t size,
117  uintptr_t alignment
118)
119{
120  return
121    _Protected_heap_Allocate_aligned_with_boundary( heap, size, alignment, 0 );
122}
123
124/**
125 * @brief Allocates a memory area.
126 *
127 * A size value of zero will return a unique address which may be freed with
128 * _Heap_Free().  This method first locks the allocator and after the allocation of the memory
129 * area, unlocks it again.
130 *
131 * @param[in, out] heap The heap to allocate a memory are from.
132 * @param size The size of the desired memory are in bytes.
133 *
134 * @retval pointer The starting address of the allocated memory area.
135 * @retval NULL No memory is available of the parameters are inconsistent.
136 */
137RTEMS_INLINE_ROUTINE void *_Protected_heap_Allocate(
138  Heap_Control *heap,
139  uintptr_t size
140)
141{
142  return _Protected_heap_Allocate_aligned_with_boundary( heap, size, 0, 0 );
143}
144
145/**
146 * @brief Returns the size of the allocatable memory area.
147 *
148 * The size value may be greater than the initially requested size in
149 * _Heap_Allocate_aligned_with_boundary().
150 *
151 * Inappropriate values for @a addr will not corrupt the heap, but may yield
152 * invalid size values.
153 *
154 * This method first locks the allocator and after the operation, unlocks it again.
155 *
156 * @param heap The heap to operate upon.
157 * @param addr The starting address of the allocatable memory area.
158 * @param[out] size Stores the size of the allocatable memory area after the method call.
159 *
160 * @retval true The operation was successful.
161 * @retval false The operation was not successful.
162 */
163bool _Protected_heap_Get_block_size(
164  Heap_Control *heap,
165  void *addr,
166  uintptr_t *size
167);
168
169/**
170 * @brief Resizes the block of the allocated memory area.
171 *
172 * Inappropriate values for @a addr may corrupt the heap.
173 *
174 * This method first locks the allocator and after the resize, unlocks it again.
175 *
176 * @param[in, out] heap The heap to operate upon.
177 * @param addr The starting address of the allocated memory area to be resized.
178 * @param size The least possible size for the new memory area.  Resize may be
179 *      impossible and depends on the current heap usage.
180 * @param[out] old_size Stores the size available for allocation in the current
181 *      block before the resize after the method call.
182 * @param[out] new_size Stores the size available for allocation in the resized
183 *      block after the method call.  In the case of an unsuccessful resize,
184 *      zero is returned in this parameter
185 *
186 * @retval HEAP_RESIZE_SUCCESSFUL The resize was successful.
187 * @retval HEAP_RESIZE_UNSATISFIED The least possible size @a size was too big.
188 *      Resize not possible.
189 * @retval HEAP_RESIZE_FATAL_ERROR The block starting at @a addr is not part of
190 *      the heap.
191 */
192bool _Protected_heap_Resize_block(
193  Heap_Control *heap,
194  void *addr,
195  uintptr_t size
196);
197
198/**
199 * @brief Frees the allocated memory area.
200 *
201 * Inappropriate values for @a addr may corrupt the heap.  This method first locks
202 * the allocator and after the free operation, unlocks it again.
203 *
204 * @param[in, out] heap The heap of the allocated memory area.
205 * @param addr The starting address of the memory area to be freed.
206 *
207 * @retval true The allocated memory area was successfully freed.
208 * @retval false The method failed.
209 */
210bool _Protected_heap_Free( Heap_Control *heap, void *addr );
211
212/**
213 * @brief Verifies the integrity of the heap.
214 *
215 * Walks the heap to verify its integrity.  This method first locks
216 * the allocator and after the operation, unlocks it again, if the thread dispatch is enabled.
217 *
218 * @param heap The heap whose integrity is to be verified.
219 * @param source If @a dump is @c true, this is used to mark the output lines.
220 * @param dump Indicates whether diagnostic messages will be printed to standard output.
221 *
222 * @retval true No errors occured, the heapÂŽs integrity is not violated.
223 * @retval false The heap is corrupt.
224 */
225bool _Protected_heap_Walk( Heap_Control *heap, int source, bool dump );
226
227/**
228 * @brief Iterates over all blocks of the heap.
229 *
230 * This method first locks the allocator and after the operation, unlocks it again.
231 *
232 * @param[in, out] heap The heap to iterate over.
233 * @param visitor This will be called for each heap block with
234 *      the argument @a visitor_arg.
235 * @param[in, out] visitor_arg The argument for all calls of @a visitor.
236 */
237void _Protected_heap_Iterate(
238  Heap_Control *heap,
239  Heap_Block_visitor visitor,
240  void *visitor_arg
241);
242
243/**
244 * @brief Returns information about used and free blocks for the heap.
245 *
246 * This method first locks the allocator and after the operation, unlocks it again.
247 *
248 * @param heap The heap to get the information from.
249 * @param[out] info Stores the information of the @a heap after the method call.
250 */
251bool _Protected_heap_Get_information(
252  Heap_Control *heap,
253  Heap_Information_block *info
254);
255
256/**
257 * @brief Returns information about free blocks for the heap.
258 *
259 * This method first locks the allocator and after the operation, unlocks it again.
260 *
261 * @param heap The heap to get the information from.
262 * @param[out] info Stores the information about free blocks of @a heap after the
263 *      method call.
264 */
265bool _Protected_heap_Get_free_information(
266  Heap_Control *heap,
267  Heap_Information *info
268);
269
270/**
271 * @brief Returns the size of the allocatable area in bytes.
272 *
273 * This value is an integral multiple of the page size.
274 *
275 * @param heap The heap to get the allocatable area from.
276 *
277 * @return The size of the allocatable area in @a heap in bytes.
278 */
279uintptr_t _Protected_heap_Get_size( Heap_Control *heap );
280
281/** @} */
282
283#ifdef __cplusplus
284}
285#endif
286
287#endif
288/* end of include file */
Note: See TracBrowser for help on using the repository browser.