WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
Dynload Share Memory Framework
Dynload Share Memory Framework 的协作图:

宏定义

#define LOS_ERRNO_DYN_SHM_NO_MEMORY   LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x00)
 
#define LOS_ERRNO_DYN_SHM_INPUT_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x01)
 
#define LOS_ERRNO_DYN_SHM_INIT_FAILED   LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x02)
 
#define LOS_ERRNO_DYN_SHM_ALREADY_MAPPED   LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x03)
 
#define LOS_ERRNO_DYN_SHM_INIT_REPEATEDLY   LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x04)
 
#define LOS_ERRNO_DYN_SHM_IN_ISR   LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x05)
 
#define LOS_ERRNO_DYN_SHM_NOT_READY   LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x06)
 

函数

UINT32 LOS_DynShmInit (DynShmConfig *config)
 Init dynamic shared memory module.
 
UINT32 LOS_DynShmMap (UADDR inAddr, UINT32 size, DynShmMemType memType, UINTPTR *outAddr)
 Setup Mapping from input address to output address.
 
UINT32 LOS_DynShmUnmap (UINTPTR virAddr, UINT32 size)
 Destroy Mapping from input address to output address.
 
UINT32 LOS_DynShmAddrTranslate (UADDR inAddr, UADDR *outAddr, DynShmTransType optType)
 Translate address from input to output.
 
void * LOS_DynShmBulkMalloc (DynShmBulkMem *mem)
 Malloc memory in bulk.
 
UINT32 LOS_DynShmBulkFree (DynShmBulkMem *mem)
 Malloc memory in bulk.
 

详细描述

宏定义说明

◆ LOS_ERRNO_DYN_SHM_ALREADY_MAPPED

#define LOS_ERRNO_DYN_SHM_ALREADY_MAPPED   LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x03)

Dynamic shared memory error code: The input addr is already mapped before.

Value: 0x02002303.

Solution: Check the addr, and unmap firstly, then map it again.

◆ LOS_ERRNO_DYN_SHM_IN_ISR

#define LOS_ERRNO_DYN_SHM_IN_ISR   LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x05)

Dynamic shared memory error code: The API is called in ISR.

Value: 0x02002305.

Solution: Check your code and make sure the API is only called in ISR.

◆ LOS_ERRNO_DYN_SHM_INIT_FAILED

#define LOS_ERRNO_DYN_SHM_INIT_FAILED   LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x02)

Dynamic shared memory error code: initialization failure.

Value: 0x02002302.

Solution: Check whether the mutex is created successfully.

◆ LOS_ERRNO_DYN_SHM_INIT_REPEATEDLY

#define LOS_ERRNO_DYN_SHM_INIT_REPEATEDLY   LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x04)

Dynamic shared memory error code: The module has been initialized more than once.

Value: 0x02002304.

Solution: Check your code and make sure LOS_DynShmInit is only called once.

◆ LOS_ERRNO_DYN_SHM_INPUT_INVALID

#define LOS_ERRNO_DYN_SHM_INPUT_INVALID   LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x01)

Dynamic shared memory error code: The input is invalid.

Value: 0x02002301.

Solution: Check the input.

◆ LOS_ERRNO_DYN_SHM_NO_MEMORY

#define LOS_ERRNO_DYN_SHM_NO_MEMORY   LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x00)

Dynamic shared memory error code: The request for memory fails.

Value: 0x02002300.

Solution: Increase the size of virtual space.

◆ LOS_ERRNO_DYN_SHM_NOT_READY

#define LOS_ERRNO_DYN_SHM_NOT_READY   LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x06)

Dynamic shared memory error code: The module has not been initialized well.

Value: 0x02002306.

Solution: Make sure APIs which starts with LOS_DynShm in the module are called after DynShm has been initialized well.

函数说明

◆ LOS_DynShmAddrTranslate()

UINT32 LOS_DynShmAddrTranslate ( UADDR  inAddr,
UADDR outAddr,
DynShmTransType  optType 
)
extern

Translate address from input to output.

Description:
This API is used to translate address from input to output. The translation has four directions, including INNER_VA_TO_OUTER_VA, OUTER_VA_TO_INNER_VA, INNER_VA_TO_MEM_PA and OUTER_VA_TO_MEM_PA. INNER_VA means LiteOS running core's virtual address. OUTER_VA means another device's virtual address, instead of LiteOS running core. MEM_PA means real memory's physical address.
注意
  • Do not call the API in ISR.
参数
inAddr[IN] The input address.
outAddr[OUT] The virtual address corresponding to inAddr. It must be 8-bytes aligned.
optType[OUT] Translation direction.
返回值
LOS_ERRNO_DYN_SHM_INPUT_INVALIDThe passed-in inAddr and optType is invalid.
LOS_OKThe address translation is done successfully.
Dependency:
los_dynshm.h: the header file that contains the API declaration.

◆ LOS_DynShmBulkFree()

UINT32 LOS_DynShmBulkFree ( DynShmBulkMem mem)
extern

Malloc memory in bulk.

Description:
This API is used to malloc memory in bulk. Request for allocation of physical memory firstly, and then mapping the range of physical address to virtual address by LiteOS.
注意
  • Do not call the API in ISR.
参数
dmaBuf[IN] The allocated physical buffer by request.
virAddr[IN] The mapped virtual address by LiteOS.
phyAddr[IN] The allocated physical address by request.
size[IN] The size of allocated memory.
type[IN] The type of allocated memory.
返回值
LOS_ERRNO_DYN_SHM_INPUT_INVALIDThe passed-in virAddr and size is invalid.
LOS_OKThe mapping is destroyed successfully.
Dependency:
los_dynshm.h: the header file that contains the API declaration.
参见
LOS_DynShmBulkMalloc

◆ LOS_DynShmBulkMalloc()

void * LOS_DynShmBulkMalloc ( DynShmBulkMem mem)
extern

Malloc memory in bulk.

Description:
This API is used to malloc memory in bulk. Request for allocation of physical memory firstly, and then mapping the range of physical address to virtual address by LiteOS.
注意
  • Do not call the API in ISR.
参数
dmaBuf[OUT] The allocated physical buffer by request.
virAddr[OUT] The mapped virtual address by LiteOS.
phyAddr[IN] The allocated physical address by request.
size[IN] The size of allocated memory.
type[IN] The type of allocated memory.
返回值
NULLThe allocation is fail.
#non-zeroThe allocation is successful.
Dependency:
los_dynshm.h: the header file that contains the API declaration.
参见
LOS_DynShmBulkFree

◆ LOS_DynShmInit()

UINT32 LOS_DynShmInit ( DynShmConfig config)
extern

Init dynamic shared memory module.

Description:
This API is used to initialize dynamic shared memory module.
注意
  • Do not initialize dynshm module repeatedly.
参数
config[IN] The user's configuration parameter.
返回值
LOS_ERRNO_DYN_SHM_INPUT_INVALIDThe passed-in config is invalid.
LOS_ERRNO_DYN_SHM_INIT_FAILEDThe mutex is created failed.
LOS_OKThe shm module is successfully inited.
Dependency:
los_dynshm.h: the header file that contains the API declaration.

◆ LOS_DynShmMap()

UINT32 LOS_DynShmMap ( UADDR  inAddr,
UINT32  size,
DynShmMemType  memType,
UINTPTR outAddr 
)
extern

Setup Mapping from input address to output address.

Description:
This API is used to Setup Mapping from input address to output address. The input address is from another device, like iommu. The output address is from LiteOS which is virtual.
注意
  • Do not call the API in ISR.
  • If [inAddr, inAddr + size) is overlapped with mapped areas before, API will return failure.
  • If [inAddr, inAddr + size) is fully covered by mapped areas before, API will return OK.
参数
inAddr[IN] The input address. 0 is legal parameter since it is not LiteOS virtual address.
size[IN] The mapping area size.
memType[IN] The type of mapping memory, including security and cache.
outAddr[OUT] The address is virtual and managed by LiteOS. It must be 4-bytes aligned.
返回值
LOS_ERRNO_DYN_SHM_INPUT_INVALIDThe passed-in config is invalid.
LOS_ERRNO_DYN_SHM_NO_MEMORYThe virtual space is not enough.
LOS_ERRNO_DYN_SHM_ALREADY_MAPPEDThe mapping is already setup, do not repeatedly map.
LOS_OKThe mapping is setup successfully.
Dependency:
los_dynshm.h: the header file that contains the API declaration.
参见
LOS_DynShmUnmap

◆ LOS_DynShmUnmap()

UINT32 LOS_DynShmUnmap ( UINTPTR  virAddr,
UINT32  size 
)
extern

Destroy Mapping from input address to output address.

Description:
This API is used to destroy Mapping from input address to output address. The input address is from LiteOS which is virtual.
注意
  • Do not call the API in ISR.
参数
virAddr[IN] The input address. Zero address will return failure since it cannot be found forever in virtual space.
size[IN] The unmapping area size.
返回值
LOS_ERRNO_DYN_SHM_INPUT_INVALIDThe passed-in virAddr and size is invalid.
LOS_OKThe mapping is destroyed successfully.
Dependency:
los_dynshm.h: the header file that contains the API declaration.
参见
LOS_DynShmMap