source: rtems/cpukit/include/rtems/score/protectedheap.h @ 63415655

Last change on this file since 63415655 was 63415655, checked in by Joel Sherrill <joel@…>, on 05/22/23 at 13:58:27

score/src/pheap*: Remove unreferenced methods

  • _Protected_heap_Get_block_size
  • _Protected_heap_Iterate
  • _Protected_heap_Resize_block

Closes #4909.

  • Property mode set to 100644
File size: 7.8 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSScoreProtHeap
7 *
8 * @brief This header file provides the interfaces of the
9 *   @ref RTEMSScoreProtHeap.
10 */
11
12/*
13 *  COPYRIGHT (c) 1989-2007.
14 *  On-Line Applications Research Corporation (OAR).
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 *    notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 *    notice, this list of conditions and the following disclaimer in the
23 *    documentation and/or other materials provided with the distribution.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef _RTEMS_SCORE_PROTECTED_HEAP_H
39#define _RTEMS_SCORE_PROTECTED_HEAP_H
40
41#include <rtems/score/heapimpl.h>
42#include <rtems/score/apimutex.h>
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48/**
49 * @defgroup RTEMSScoreProtHeap Protected Heap Handler
50 *
51 * @ingroup RTEMSScoreHeap
52 *
53 * @brief This group contains the Protected Heap Handler implementation.
54 *
55 * The @ref ScoreAllocatorMutex is used to protect the heap accesses.
56 *
57 * @{
58 */
59
60/**
61 * @brief Initializes the protected heap.
62 *
63 * @param[out] heap The heap to initialize.
64 * @param area_begin The starting address of the heap area.
65 * @param area_size The size of the heap area.
66 * @param page_size The page size for the heap.
67 */
68static inline uintptr_t _Protected_heap_Initialize(
69  Heap_Control *heap,
70  void *area_begin,
71  uintptr_t area_size,
72  uintptr_t page_size
73)
74{
75  return _Heap_Initialize( heap, area_begin, area_size, page_size );
76}
77
78/**
79 * @brief Extends the protected heap.
80 *
81 * @param[in, out] heap The heap to extend.
82 * @param area_begin The starting addres of the area to extend @a heap with.
83 * @param area_size The size of the heap area.
84 *
85 * @retval true The operation succeeded.
86 * @retval false The operation failed.
87 */
88bool _Protected_heap_Extend(
89  Heap_Control *heap,
90  void *area_begin,
91  uintptr_t area_size
92);
93
94/**
95 * @brief Allocates an aligned memory area with boundary constraint for the protected heap.
96 *
97 * A size value of zero will return a unique address which may be freed with
98 * _Heap_Free().  This method first locks the allocator and after the allocation of the memory
99 * area, unlocks it again.
100 *
101 * @param[in, out] heap The heap to allocate a memory are from.
102 * @param size The size of the desired memory are in bytes.
103 * @param alignment The allocated memory area will begin at an address aligned by this value.
104 * @param boundary The allocated memory area will fulfill a boundary constraint,
105 *      if this value is not equal to zero.  The boundary value specifies
106 *      the set of addresses which are aligned by the boundary value.  The
107 *      interior of the allocated memory area will not contain an element of this
108 *      set.  The begin or end address of the area may be a member of the set.
109 *
110 * @retval pointer The starting address of the allocated memory area.
111 * @retval NULL No memory is available of the parameters are inconsistent.
112 */
113void *_Protected_heap_Allocate_aligned_with_boundary(
114  Heap_Control *heap,
115  uintptr_t size,
116  uintptr_t alignment,
117  uintptr_t boundary
118);
119
120/**
121 * @brief Allocates an aligned memory area.
122 *
123 * A size value of zero will return a unique address which may be freed with
124 * _Heap_Free().  This method first locks the allocator and after the allocation of the memory
125 * area, unlocks it again.
126 *
127 * @param[in, out] heap The heap to allocate a memory are from.
128 * @param size The size of the desired memory are in bytes.
129 * @param alignment The allocated memory area will begin at an address aligned by this value.
130 *
131 * @retval pointer The starting address of the allocated memory area.
132 * @retval NULL No memory is available of the parameters are inconsistent.
133 */
134static inline void *_Protected_heap_Allocate_aligned(
135  Heap_Control *heap,
136  uintptr_t size,
137  uintptr_t alignment
138)
139{
140  return
141    _Protected_heap_Allocate_aligned_with_boundary( heap, size, alignment, 0 );
142}
143
144/**
145 * @brief Allocates a memory area.
146 *
147 * A size value of zero will return a unique address which may be freed with
148 * _Heap_Free().  This method first locks the allocator and after the allocation of the memory
149 * area, unlocks it again.
150 *
151 * @param[in, out] heap The heap to allocate a memory are from.
152 * @param size The size of the desired memory are in bytes.
153 *
154 * @retval pointer The starting address of the allocated memory area.
155 * @retval NULL No memory is available of the parameters are inconsistent.
156 */
157static inline void *_Protected_heap_Allocate(
158  Heap_Control *heap,
159  uintptr_t size
160)
161{
162  return _Protected_heap_Allocate_aligned_with_boundary( heap, size, 0, 0 );
163}
164
165/**
166 * @brief Frees the allocated memory area.
167 *
168 * Inappropriate values for @a addr may corrupt the heap.  This method first locks
169 * the allocator and after the free operation, unlocks it again.
170 *
171 * @param[in, out] heap The heap of the allocated memory area.
172 * @param addr The starting address of the memory area to be freed.
173 *
174 * @retval true The allocated memory area was successfully freed.
175 * @retval false The method failed.
176 */
177bool _Protected_heap_Free( Heap_Control *heap, void *addr );
178
179/**
180 * @brief Verifies the integrity of the heap.
181 *
182 * Walks the heap to verify its integrity.  This method first locks
183 * the allocator and after the operation, unlocks it again, if the thread dispatch is enabled.
184 *
185 * @param heap The heap whose integrity is to be verified.
186 * @param source If @a dump is @c true, this is used to mark the output lines.
187 * @param dump Indicates whether diagnostic messages will be printed to standard output.
188 *
189 * @retval true No errors occurred, the heapÂŽs integrity is not violated.
190 * @retval false The heap is corrupt.
191 */
192bool _Protected_heap_Walk( Heap_Control *heap, int source, bool dump );
193
194/**
195 * @brief Returns information about used and free blocks for the heap.
196 *
197 * This method first locks the allocator and after the operation, unlocks it again.
198 *
199 * @param heap The heap to get the information from.
200 * @param[out] info Stores the information of the @a heap after the method call.
201 */
202bool _Protected_heap_Get_information(
203  Heap_Control *heap,
204  Heap_Information_block *info
205);
206
207/**
208 * @brief Returns information about free blocks for the heap.
209 *
210 * This method first locks the allocator and after the operation, unlocks it again.
211 *
212 * @param heap The heap to get the information from.
213 * @param[out] info Stores the information about free blocks of @a heap after the
214 *      method call.
215 */
216bool _Protected_heap_Get_free_information(
217  Heap_Control *heap,
218  Heap_Information *info
219);
220
221/**
222 * @brief Returns the size of the allocatable area in bytes.
223 *
224 * This value is an integral multiple of the page size.
225 *
226 * @param heap The heap to get the allocatable area from.
227 *
228 * @return The size of the allocatable area in @a heap in bytes.
229 */
230uintptr_t _Protected_heap_Get_size( Heap_Control *heap );
231
232/** @} */
233
234#ifdef __cplusplus
235}
236#endif
237
238#endif
239/* end of include file */
Note: See TracBrowser for help on using the repository browser.