94a42422e1a8b378c4af2d1933a1a726cfb695e5
1 /******************************************************************************
2 * Copyright (c) 2015, Texas Instruments Incorporated - http://www.ti.com
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of Texas Instruments Incorporated nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26 * THE POSSIBILITY OF SUCH DAMAGE.
27 *****************************************************************************/
28 #ifndef _LIBARCH_MEMMGT_H
29 #define _LIBARCH_MEMMGT_H
31 #include <stdlib.h>
33 /** @defgroup libarch_memmgt Memory Management API
34 * @{
35 */
36 /** @} */
38 /** @addtogroup libarch_memmgt
39 * @brief Error return codes of memory management functions.
40 * @{
41 */
42 /*@{*/
43 #define LIB_MEMMGT_SUCCESS (0) /**< Success. No error. */
44 #define LIB_MEMMGT_ERROR (-1) /**< Failure. */
45 /*@}*/
46 /** @} */
48 /**
49 * @ingroup libarch_memmgt
50 * @brief Memory types in terms of speed and volatility
51 */
52 enum {
53 LIB_SMEM_VFAST = 0, /**< Scratch memory, very fast */
54 LIB_SMEM_FAST, /**< Scratch memory, fast */
55 LIB_SMEM_MED, /**< Scratch memory, medium speed */
56 LIB_SMEM_SLOW, /**< Scratch memory, slow */
57 LIB_PMEM_MED, /**< Permanent memory, medium speed */
58 LIB_PMEM_SLOW, /**< Permanent memory, slow */
59 LIB_MEMTYPE_N /**< Total number of types */
60 };
62 typedef unsigned int lib_mem_type_t;
64 typedef struct {
65 size_t size; /**< heap size in number of bytes */
66 lib_mem_type_t type;
67 unsigned int alignment;
68 void *base; /**< base address of the heap */
69 } lib_mem_rec_t;
71 #define libChkAlign(base, l2a) \
72 (((uint_least32_t)(base)&((~0UL<<(l2a))))==0UL)
75 #endif /* _LIBARCH_MEMMGT_H */
77 /* nothing past this point */