Developer World
Spresense Arduino Library v3.2.0-77d75a4
MemoryUtil.h
1/*
2 * MemoryUtil.h - Audio include file for the Spresense SDK
3 * Copyright 2018 Sony Semiconductor Solutions Corporation
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef MemoryUtil_h
21#define MemoryUtil_h
22
23/* Define the following: Reduce memory usage to 1 tile (128 kbytes). */
24
25//#define MEMORY_UTIL_TINY
26
27#ifdef SUBCORE
28#error "MemoryUtil library is NOT supported by SubCore."
29#endif
30
31#define _POSIX
32#define USE_MEMMGR_FENCE
33
34#include <memutils/memory_manager/MemHandle.h>
35#include <memutils/message/Message.h>
36
37#ifdef MEMORY_UTIL_TINY
38#include "memutil/tiny/msgq_id.h"
39#include "memutil/tiny/mem_layout.h"
40#include "memutil/tiny/memory_layout.h"
41#else
42#include "memutil/msgq_id.h"
43#include "memutil/mem_layout.h"
44#include "memutil/memory_layout.h"
45#endif
46
47using namespace MemMgrLite;
48
49/*--------------------------------------------------------------------------*/
56{
57public:
58
59 MemoryUtilClass():m_state(E_Inactive){}
60
68 int begin();
69
70
78 int setLayout(uint8_t sec_no, uint8_t layout_no);
79
86
92 int end();
93
101 const PoolSectionAttr* getLayout(uint8_t sec_no, int layout_no);
102
103private:
104 enum E_state{
105 E_Inactive=0,
106 E_Active,
107 STATE_NUM
108 };
109
110 E_state m_state;
111};
112
113/*--------------------------------------------------------------------------*/
114extern MemoryUtilClass MemoryUtil;
115
116/*--------------------------------------------------------------------------*/
117extern int initMemoryPools(void);
118extern int createStaticPools(uint8_t layout_no);
119extern int createStaticPools(uint8_t sec_no, uint8_t layout_no);
120extern int destroyStaticPools(void);
121extern int finalizeMemoryPools(void);
122extern const PoolSectionAttr *getPoolLayout(int layout_no);
123extern const PoolSectionAttr *getPoolLayout(uint8_t sec_no, int layout_no);
124
125
126#endif /* MemoryUtil_h */
127
MemoryManager Library Class Definitions.
Definition: MemoryUtil.h:56
int begin()
Initialize MemoryManager library.
int clearLayout()
Destroy the static memory pool.
const PoolSectionAttr * getLayout(uint8_t sec_no, int layout_no)
Get static memory pool information.
int setLayout(uint8_t sec_no, uint8_t layout_no)
Generate static memory pool group.
int end()
Finalize MemoryManager library.