WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
los_memory_pri.h
浏览该文件的文档.
1/* ----------------------------------------------------------------------------
2 * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved.
3 * Description: LiteOS Memory Module Private HeadFile
4 * Author: Huawei LiteOS Team
5 * Create: 2013-01-01
6 * Redistribution and use in source and binary forms, with or without modification,
7 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
14 * to endorse or promote products derived from this software without specific prior written
15 * permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * --------------------------------------------------------------------------- */
28
29#ifndef _LOS_MEMORY_PRI_H
30#define _LOS_MEMORY_PRI_H
31
32#include "los_memory.h"
33#include "los_memstat_pri.h"
34#include "los_slab_pri.h"
35#include "los_spinlock.h"
36#include "los_misc_pri.h"
37
38#ifdef __cplusplus
39extern "C" {
40#endif /* __cplusplus */
41
42/* Memory pool information structure */
43#if defined(LOSCFG_KERNEL_MEM_BESTFIT)
44
45typedef struct {
46 VOID *pool; /* Starting address of a memory pool */
47 UINT32 poolSize; /* Memory pool size */
48
49#ifdef LOSCFG_MEM_TASK_STAT
50 Memstat stat;
51#endif
52
53#ifdef LOSCFG_MEM_MUL_POOL
54 VOID *nextPool;
55#endif
56
57#ifdef LOSCFG_KERNEL_MEM_SLAB_EXTENTION
58 struct LosSlabControlHeader slabCtrlHdr;
59#endif
60} LosMemPoolInfo;
61
62#elif defined(LOSCFG_KERNEL_MEM_BESTFIT_LITTLE)
63
64typedef struct LosHeapManager {
65 struct LosHeapNode *head;
66 struct LosHeapNode *tail;
67 UINT32 size;
68
69#ifdef LOSCFG_MEM_TASK_STAT
70 Memstat stat;
71#endif
72
73#ifdef LOSCFG_MEM_MUL_POOL
74 VOID *nextPool;
75#endif
76
77#ifdef LOSCFG_KERNEL_MEM_SLAB_EXTENTION
78 struct LosSlabControlHeader slabCtrlHdr;
79#endif
80} LosMemPoolInfo;
81
82#endif
83
84#define IS_ALIGNED(value, alignSize) ((((UINTPTR)(value)) & ((UINTPTR)((alignSize) - 1))) == 0)
85
86/* spinlock for mem module, only available on SMP mode */
88#define MEM_LOCK(state) LOS_SpinLockSave(&g_memSpin, &(state))
89#define MEM_UNLOCK(state) LOS_SpinUnlockRestore(&g_memSpin, (state))
90
93
94/* SLAB extention needs memory algorithms provide following internal apis */
95#ifdef LOSCFG_KERNEL_MEM_SLAB_EXTENTION
96extern VOID* OsMemAlloc(VOID *pool, UINT32 size);
97extern UINT32 OsMemFree(VOID *pool, const VOID *ptr);
98#endif /* LOSCFG_KERNEL_MEM_SLAB_EXTENTION */
99
100#ifdef LOSCFG_MEM_MUL_POOL
101extern UINT32 OsMemMulPoolInit(VOID *pool, UINT32 size);
102extern UINT32 OsMemMulPoolDeinit(const VOID *pool);
103extern VOID *OsMemMulPoolHeadGet(VOID);
104#else /* LOSCFG_MEM_MUL_POOL */
106{
107 (VOID)pool;
108 (VOID)size;
109 return LOS_OK;
110}
111
113{
114 (VOID)pool;
115 return LOS_OK;
116}
117#endif /* LOSCFG_MEM_MUL_POOL */
118
119#ifdef LOSCFG_EXC_INTERACTION
120extern UINT32 OsMemExcInteractionInit(UINTPTR memStart);
121#endif
122
123#ifdef LOSCFG_MEM_LEAKCHECK
124extern VOID OsMemUsedNodeShow(VOID *pool);
125#endif
126
127extern VOID OsMemResetEndNode(VOID *pool, UINTPTR preAddr);
128extern VOID OsMemInfoPrint(const VOID *pool);
129extern UINT32 OsShellCmdMemCheck(INT32 argc, const CHAR *argv[]);
131
132#ifdef __cplusplus
133}
134#endif /* __cplusplus */
135
136#endif /* _LOS_MEMORY_PRI_H */
#define STATIC
Definition common_def.h:57
#define INLINE
Definition common_def.h:65
STATIC INLINE UINT32 OsMemMulPoolDeinit(const VOID *pool)
Definition los_memory_pri.h:112
UINTPTR g_sys_mem_addr_end
UINT32 OsShellCmdMemCheck(INT32 argc, const CHAR *argv[])
VOID OsMemIntegrityMultiCheck(VOID)
SPIN_LOCK_S g_memSpin
VOID OsMemResetEndNode(VOID *pool, UINTPTR preAddr)
VOID OsMemInfoPrint(const VOID *pool)
STATIC INLINE UINT32 OsMemMulPoolInit(VOID *pool, UINT32 size)
Definition los_memory_pri.h:105
UINT32 OsMemSystemInit(UINTPTR memStart)
signed int INT32
Definition los_typedef.h:55
#define VOID
Definition los_typedef.h:88
#define LOS_OK
Definition los_typedef.h:122
unsigned int UINTPTR
Definition los_typedef.h:74
unsigned int UINT32
Definition los_typedef.h:52
char CHAR
Definition los_typedef.h:58
Definition los_memory_internal.h:63
Definition los_spinlock.h:78