Lines Matching +full:memory +full:- +full:to +full:- +full:memory
4 * SPDX-License-Identifier: Apache-2.0
10 * @brief Memory Blocks Allocator
31 * @defgroup mem_blocks_apis Memory Blocks APIs
37 * @brief Memory Blocks Allocator
42 * @brief Multi Memory Blocks Allocator
49 * @brief Memory Blocks Allocator
56 * @brief Multi Memory Blocks Allocator
61 * @brief Multi memory blocks allocator choice function
63 * This is a user-provided functions whose responsibility is selecting
64 * a specific memory blocks allocator based on the opaque cfg value,
65 * which is specified by the user as an argument to
66 * sys_multi_mem_blocks_alloc(). The callback returns a pointer to
70 * allocation to fail and a -EINVAL reported to the calling code.
72 * @param group Multi memory blocks allocator structure.
73 * @param cfg An opaque user-provided value. It may be interpreted in
76 * @return A pointer to the chosen allocator, or NULL if none is chosen.
97 /* Memory block buffer */
104 /* Spinlock guarding access to memory block internals */
120 * @brief Create a memory block object with a providing backing buffer.
122 * @param name Name of the memory block object.
123 * @param blk_sz Size of each memory block (in bytes, power of 2).
124 * @param num_blks Total number of memory blocks.
126 * @param mbmod Modifier to the memory block struct
142 * @brief Create a memory block object with a new backing buffer.
144 * @param name Name of the memory block object.
145 * @param blk_sz Size of each memory block (in bytes, power of 2).
146 * @param num_blks Total number of memory blocks.
147 * @param balign Alignment of the memory block buffer (power of 2).
148 * @param mbmod Modifier to the memory block struct
163 * @brief Create a memory block object with a new backing buffer.
165 * @param name Name of the memory block object.
166 * @param blk_sz Size of each memory block (in bytes).
167 * @param num_blks Total number of memory blocks.
168 * @param buf_align Alignment of the memory block buffer (power of 2).
174 * @brief Create a static memory block object with a new backing buffer.
176 * @param name Name of the memory block object.
177 * @param blk_sz Size of each memory block (in bytes).
178 * @param num_blks Total number of memory blocks.
179 * @param buf_align Alignment of the memory block buffer (power of 2).
186 * @brief Create a memory block object with a providing backing buffer.
188 * @param name Name of the memory block object.
189 * @param blk_sz Size of each memory block (in bytes).
190 * @param num_blks Total number of memory blocks.
197 * @brief Create a static memory block object with a providing backing buffer.
199 * @param name Name of the memory block object.
200 * @param blk_sz Size of each memory block (in bytes).
201 * @param num_blks Total number of memory blocks.
208 * @brief Allocate multiple memory blocks
210 * Allocate multiple memory blocks, and place their pointers into
213 * @param[in] mem_block Pointer to memory block object.
214 * @param[in] count Number of blocks to allocate.
215 * @param[out] out_blocks Output array to be populated by pointers to
216 * the memory blocks. It must have at least
220 * @retval -EINVAL Invalid argument supplied.
221 * @retval -ENOMEM Not enough blocks for allocation.
227 * @brief Allocate a contiguous set of memory blocks
229 * Allocate multiple memory blocks, and place their pointers into
232 * @param[in] mem_block Pointer to memory block object.
233 * @param[in] count Number of blocks to allocate.
234 * @param[out] out_block Output pointer to the start of the allocated block set
237 * @retval -EINVAL Invalid argument supplied.
238 * @retval -ENOMEM Not enough contiguous blocks for allocation.
244 * @brief Force allocation of a specified blocks in a memory block object
246 * Allocate a specified blocks in a memory block object.
248 * allocation may take any of the free memory space
251 * @param[in] mem_block Pointer to memory block object.
252 * @param[in] in_block Address of the first required block to allocate
253 * @param[in] count Number of blocks to allocate.
256 * @retval -EINVAL Invalid argument supplied.
257 * @retval -ENOMEM Some of blocks are taken and cannot be allocated
264 * @param[in] mem_block Pointer to memory block object.
265 * @param[in] in_block Address of the first block to check
266 * @param[in] count Number of blocks to check.
268 * @retval 1 All memory blocks are free
269 * @retval 0 At least one of the memory blocks is taken
274 * @brief Free multiple memory blocks
276 * Free multiple memory blocks according to the array of memory
279 * @param[in] mem_block Pointer to memory block object.
280 * @param[in] count Number of blocks to free.
281 * @param[in] in_blocks Input array of pointers to the memory blocks.
284 * @retval -EINVAL Invalid argument supplied.
285 * @retval -EFAULT Invalid pointers supplied.
291 * @brief Free contiguous multiple memory blocks
293 * Free contiguous multiple memory blocks
295 * @param[in] mem_block Pointer to memory block object.
296 * @param[in] block Pointer to the first memory block
297 * @param[in] count Number of blocks to free.
300 * @retval -EINVAL Invalid argument supplied.
301 * @retval -EFAULT Invalid pointer supplied.
307 * @brief Get the runtime statistics of a memory block
309 * This function retrieves the runtime stats for the specified memory block
310 * @a mem_block and copies it into the memory pointed to by @a stats.
312 * @param mem_block Pointer to system memory block
313 * @param stats Pointer to struct to copy statistics into
315 * @return -EINVAL if NULL pointer was passed, otherwise 0
321 * @brief Reset the maximum memory block usage
323 * This routine resets the maximum memory usage in the specified memory
324 * block @a mem_block to match that block's current memory usage.
326 * @param mem_block Pointer to system memory block
328 * @return -EINVAL if NULL pointer was passed, otherwise 0
334 * @brief Initialize multi memory blocks allocator group
340 * @param group Multi memory blocks allocator structure.
341 * @param choice_fn A sys_multi_mem_blocks_choice_fn_t callback used to
342 * select the allocator to be used at allocation time
348 * @brief Add an allocator to an allocator group
350 * This adds a known allocator to an existing multi memory blocks
353 * @param group Multi memory blocks allocator structure.
354 * @param alloc Allocator to add
360 * @brief Allocate memory from multi memory blocks allocator group
363 * memory. Takes an opaque configuration pointer passed to the choice
364 * function, which is used by integration code to choose an allocator.
366 * @param[in] group Multi memory blocks allocator structure.
369 * @param[in] count Number of blocks to allocate
370 * @param[out] out_blocks Output array to be populated by pointers to
371 * the memory blocks. It must have at least
377 * @retval -EINVAL Invalid argument supplied, or no allocator chosen.
378 * @retval -ENOMEM Not enough blocks for allocation.
386 * @brief Free memory allocated from multi memory blocks allocator group
388 * Free previous allocated memory blocks from sys_multi_mem_blocks_alloc().
392 * @param[in] group Multi memory blocks allocator structure.
393 * @param[in] count Number of blocks to free.
394 * @param[in] in_blocks Input array of pointers to the memory blocks.
397 * @retval -EINVAL Invalid argument supplied, or no allocator chosen.
398 * @retval -EFAULT Invalid pointer(s) supplied.