WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
los_memory.h
浏览该文件的文档.
1/* ----------------------------------------------------------------------------
2 * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved.
3 * Description: LiteOS Mem Module 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
34#ifndef _LOS_MEMORY_H
35#define _LOS_MEMORY_H
36
37#include "los_config.h"
38#include "los_base.h"
39#include "los_toolchain.h"
40#include "los_membox.h"
41
42#ifdef __cplusplus
43extern "C" {
44#endif /* __cplusplus */
45
46#define OS_MEM_ALIGN(p, alignSize) (((UINTPTR)(p) + (alignSize) - 1) & ~((UINTPTR)((alignSize) - 1)))
47#define OS_MEM_ALIGN_SIZE (sizeof(UINTPTR))
48
67typedef VOID (*MALLOC_HOOK)(VOID);
68
74
80extern UINT8 *m_aucSysMem0;
81
86extern UINT8 *m_aucSysMem1;
87
93#define MEM_MODULE_MAX 0x20
94
122extern VOID *LOS_MemMalloc(VOID *pool, UINT32 size, UINT32 moduleId);
123
152extern VOID *LOS_MemMallocAlign(VOID *pool, UINT32 size, UINT32 boundary, UINT32 moduleId);
153
179extern UINT32 LOS_MemMfree(VOID *pool, VOID *ptr, UINT32 moduleId);
180
215extern VOID *LOS_MemMrealloc(VOID *pool, VOID *ptr, UINT32 size, UINT32 moduleId);
216
234
254
274
279typedef struct {
285#ifdef LOSCFG_MEM_TASK_STAT
286 UINT32 uwUsageWaterLine;
287#endif
289
296#define LOS_MEM_INIT_ATTR_SLAB_POS 0U
297#define LOS_MEM_INIT_ATTR_SLAB_MSK 1U /* << LOS_MEM_INIT_ATTR_SLAB_POS */
298
327extern UINT32 LOS_MemPoolInit(VOID *pool, UINT32 size, UINT32 attr);
328
356extern UINT32 LOS_MemInit(VOID *pool, UINT32 size);
357
383extern VOID *LOS_MemAlloc(VOID *pool, UINT32 size);
384
408extern UINT32 LOS_MemFree(VOID *pool, VOID *ptr);
409
447extern VOID *LOS_MemRealloc(VOID *pool, VOID *ptr, UINT32 size);
448
475extern VOID *LOS_MemAllocAlign(VOID *pool, UINT32 size, UINT32 boundary);
476
494extern UINT32 LOS_MemPoolSizeGet(const VOID *pool);
495
514
533
552
576extern UINT32 LOS_MemTaskIdGet(const VOID *ptr);
577
599
619
638
662
663#ifdef LOSCFG_BASE_MEM_NODE_SIZE_CHECK
695extern UINT32 LOS_MemNodeSizeCheck(VOID *pool, VOID *ptr, UINT32 *totalSize, UINT32 *availSize);
696
718extern UINT32 LOS_MemCheckLevelSet(UINT8 checkLevel);
719
736extern UINT8 LOS_MemCheckLevelGet(VOID);
737#endif
738
745#define LOS_MEM_CHECK_LEVEL_LOW 0
746
753#define LOS_MEM_CHECK_LEVEL_HIGH 1
754
761#define LOS_MEM_CHECK_LEVEL_DISABLE 0xff
762
769#define LOS_MEM_CHECK_LEVEL_DEFAULT LOS_MEM_CHECK_LEVEL_DISABLE
770
779#define LOS_ERRNO_MEMCHECK_PARA_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x1)
780
789#define LOS_ERRNO_MEMCHECK_OUTSIDE LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x2)
790
799#define LOS_ERRNO_MEMCHECK_NO_HEAD LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x3)
800
809#define LOS_ERRNO_MEMCHECK_WRONG_LEVEL LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x4)
810
819#define LOS_ERRNO_MEMCHECK_DISABLED LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x5)
820
821#ifdef __cplusplus
822}
823#endif /* __cplusplus */
824
825#endif /* _LOS_MEMORY_H */
UINT32 LOS_MemTaskIdGet(const void *ptr)
Get the task ID of a used memory node.
void * LOS_MemMalloc(void *pool, UINT32 size, UINT32 moduleId)
Allocate dynamic memory.
void * LOS_MemAlloc(void *pool, UINT32 size)
Allocate dynamic memory.
UINT32 LOS_MemDeInit(void *pool)
Deinitialize dynamic memory.
UINT32 LOS_MemMfree(void *pool, void *ptr, UINT32 moduleId)
Free dynamic memory.
UINT32 LOS_MemPoolInit(void *pool, UINT32 size, UINT32 attr)
Initialize dynamic memory.
UINT32 LOS_MemMusedGet(UINT32 moduleId)
get the used memory size of the specified module.
UINT32 LOS_MemInit(void *pool, UINT32 size)
Initialize dynamic memory.
UINT32 LOS_MemIntegrityCheck(const void *pool)
Check the memory pool integrity.
UINT8 * m_aucSysMem1
UINT32 LOS_MemFree(void *pool, void *ptr)
Free dynamic memory.
UINT32 LOS_MemTotalUsedGet(void *pool)
Get the size of memory totally used.
void * LOS_MemMallocAlign(void *pool, UINT32 size, UINT32 boundary, UINT32 moduleId)
Allocate aligned memory.
void * LOS_MemMrealloc(void *pool, void *ptr, UINT32 size, UINT32 moduleId)
Re-allocate a memory block.
UINT32 LOS_MemPoolSizeGet(const void *pool)
Get the size of memory pool's size.
UINT32 LOS_MemInfoGet(void *pool, LOS_MEM_POOL_STATUS *poolStatus)
Get the information of memory pool.
UINTPTR LOS_MemLastUsedGet(void *pool)
Get the address of the next byte of the last used byte.
UINT32 LOS_MemFreeBlksGet(void *pool)
Get the number of free memory nodes.
void(* MALLOC_HOOK)(void)
Define the type of the customized tuning function when calling the API LOS_MemAlloc to allocate memor...
Definition los_memory.h:67
UINT32 LOS_MemFreeNodeShow(void *pool)
Get the number of free node in every size.
void * LOS_MemRealloc(void *pool, void *ptr, UINT32 size)
Re-allocate a memory block.
UINT8 * m_aucSysMem0
MALLOC_HOOK g_MALLOC_HOOK
UINT32 LOS_MemPoolList(void)
Print information about all pools.
UINT32 LOS_MemUsedBlksGet(void *pool)
Get the number of used memory nodes.
void * LOS_MemAllocAlign(void *pool, UINT32 size, UINT32 boundary)
Allocate aligned memory.
#define VOID
Definition los_typedef.h:88
unsigned char UINT8
Definition los_typedef.h:50
unsigned int UINTPTR
Definition los_typedef.h:74
unsigned int UINT32
Definition los_typedef.h:52
Definition los_memory.h:279
UINT32 uwUsedNodeNum
Definition los_memory.h:283
UINT32 uwTotalUsedSize
Definition los_memory.h:280
UINT32 uwTotalFreeSize
Definition los_memory.h:281
UINT32 uwFreeNodeNum
Definition los_memory.h:284
UINT32 uwMaxFreeNodeSize
Definition los_memory.h:282