WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
los_dynshm.h
浏览该文件的文档.
1/* ----------------------------------------------------------------------------
2 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
3 * Description: Basic definitions
4 * Author: Huawei LiteOS Team
5 * Create: 2022-07-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_DYN_SHM_H
35#define _LOS_DYN_SHM_H
36
37#include "los_typedef.h"
38#include "los_errno.h"
39
40#ifdef __cplusplus
41extern "C" {
42#endif /* __cplusplus */
43
52#define LOS_ERRNO_DYN_SHM_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x00)
53
62#define LOS_ERRNO_DYN_SHM_INPUT_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x01)
63
72#define LOS_ERRNO_DYN_SHM_INIT_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x02)
73
82#define LOS_ERRNO_DYN_SHM_ALREADY_MAPPED LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x03)
83
92#define LOS_ERRNO_DYN_SHM_INIT_REPEATEDLY LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x04)
93
102#define LOS_ERRNO_DYN_SHM_IN_ISR LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x05)
103
113#define LOS_ERRNO_DYN_SHM_NOT_READY LOS_ERRNO_OS_ERROR(LOS_MOD_DYN_SHM, 0x06)
114
115typedef UINT64 UADDR;
116
117#define SHM_CACHE_MASK 0b001
118#define SHM_SEC_MASK 0b010
119#define SHM_MMZ_MASK 0b100
120
121#define LOS_SHM_IS_CACHE(x) ((UINT32)(x) & SHM_CACHE_MASK)
122#define LOS_SHM_IS_SEC(x) ((UINT32)(x) & SHM_SEC_MASK)
123#define LOS_SHM_IS_MMZ(x) ((UINT32)(x) & SHM_MMZ_MASK)
124
125#define SHM_ALIGN_UP(val, align) (((val) + (align) - 1) & (~((UADDR)(align) - 1)))
126#define SHM_ALIGN_DN(val, align) ((val) & (~((UADDR)(align) - 1)))
127#define SHM_ALIGN_OFFSET(val, align) ((val) & ((UADDR)(align) - 1))
128
141
146
151
160
161typedef struct {
162 UADDR dmaBuf; /* It's output param when allocation, while input param when free */
163 UINTPTR virAddr; /* It's output param when allocation, while input param when free */
164 UADDR phyAddr; /* It's input param whenever allocation or free */
165 UINT32 size; /* It's input param whenever allocation or free */
166 UINT32 type; /* It's input param whenever allocation or free */
170
174
188
209
238extern UINT32 LOS_DynShmMap(UADDR inAddr, UINT32 size, DynShmMemType memType, UINTPTR *outAddr);
239
262extern UINT32 LOS_DynShmUnmap(UINTPTR virAddr, UINT32 size);
263
264/*
265 * INNER_VA means LiteOS running core's virtual address.
266 * OUTER_VA means another device's virtual address, instead of LiteOS running core.
267 * MEM_PA means real memory's physical address.
268 */
276
302extern UINT32 LOS_DynShmAddrTranslate(UADDR inAddr, UADDR *outAddr, DynShmTransType optType);
303
329
355
356#ifdef __cplusplus
357}
358#endif /* __cplusplus */
359
360#endif /* _LOS_DYN_SHM_H */
UINT32 LOS_DynShmBulkFree(DynShmBulkMem *mem)
Malloc memory in bulk.
void * LOS_DynShmBulkMalloc(DynShmBulkMem *mem)
Malloc memory in bulk.
UINT32 LOS_DynShmUnmap(UINTPTR virAddr, UINT32 size)
Destroy Mapping from input address to output address.
UINT32 LOS_DynShmInit(DynShmConfig *config)
Init dynamic shared memory module.
UINT32 LOS_DynShmAddrTranslate(UADDR inAddr, UADDR *outAddr, DynShmTransType optType)
Translate address from input to output.
UINT32 LOS_DynShmMap(UADDR inAddr, UINT32 size, DynShmMemType memType, UINTPTR *outAddr)
Setup Mapping from input address to output address.
DynShmMemType
Definition los_dynshm.h:129
@ LOS_VA_SPACE_NOSEC_CACHE
Definition los_dynshm.h:131
@ LOS_MMZ_SPACE_SEC_CACHE
Definition los_dynshm.h:138
@ LOS_SHM_TYPE_MAX
Definition los_dynshm.h:139
@ LOS_VA_SPACE_NOSEC_NOCACHE
Definition los_dynshm.h:130
@ LOS_VA_SPACE_TYPE_MAX
Definition los_dynshm.h:134
@ LOS_VA_SPACE_SEC_NOCACHE
Definition los_dynshm.h:132
@ LOS_MMZ_SPACE_SEC_NOCACHE
Definition los_dynshm.h:137
@ LOS_MMZ_SPACE_NOSEC_CACHE
Definition los_dynshm.h:136
@ LOS_MMZ_SPACE_NOSEC_NOCACHE
Definition los_dynshm.h:135
@ LOS_VA_SPACE_SEC_CACHE
Definition los_dynshm.h:133
DynShmTransType
Definition los_dynshm.h:269
@ INNER_VA_TO_OUTER_VA
Definition los_dynshm.h:270
@ INNER_VA_TO_MEM_PA
Definition los_dynshm.h:272
@ SHM_ADDR_TRANS_TYPE_MAX
Definition los_dynshm.h:274
@ OUTER_VA_TO_INNER_VA
Definition los_dynshm.h:271
@ OUTER_VA_TO_MEM_PA
Definition los_dynshm.h:273
UINT32(* DynShmFlushIoMmuTlbHandler)(BOOL flushCache)
Definition los_dynshm.h:171
UINT64 UADDR
Definition los_dynshm.h:115
UINT32(* DynShmBulkFreeHandler)(DynShmBulkMem *mem)
Definition los_dynshm.h:173
#define DYN_SHM_RGN_MAX
Definition los_dynshm.h:185
UINT32(* DynShmBulkAllocHandler)(DynShmBulkMem *mem)
Definition los_dynshm.h:172
unsigned long long UINT64
Definition los_typedef.h:72
#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
char CHAR
Definition los_typedef.h:58
size_t BOOL
Definition los_typedef.h:83
Definition los_dynshm.h:161
CHAR * name
Definition los_dynshm.h:167
UADDR dmaBuf
Definition los_dynshm.h:162
BOOL noNeedMap
Definition los_dynshm.h:168
UINT32 type
Definition los_dynshm.h:166
UINT32 size
Definition los_dynshm.h:165
UADDR phyAddr
Definition los_dynshm.h:164
UINTPTR virAddr
Definition los_dynshm.h:163
Definition los_dynshm.h:175
DynShmFlushIoMmuTlbHandler flushTlbHandler
Definition los_dynshm.h:180
UINT32 pageSize
Definition los_dynshm.h:178
DynShmBulkAllocHandler bulkAllocHandler
Definition los_dynshm.h:181
UINT8 regionCnt
Definition los_dynshm.h:184
SysPageTable innerPageTable
Definition los_dynshm.h:177
DynShmBulkFreeHandler bulkFreeHandler
Definition los_dynshm.h:182
SysPageTable outerPageTable
Definition los_dynshm.h:176
Definition los_dynshm.h:152
UINT32 size
Definition los_dynshm.h:154
UINT32 startAddr
Definition los_dynshm.h:153
UINT32 type
Definition los_dynshm.h:156
UINT32 nextRgnIdx
Definition los_dynshm.h:157
Definition los_dynshm.h:142
UINT32 baseAddr
Definition los_dynshm.h:143
UINT32 tableSize
Definition los_dynshm.h:144
Definition los_dynshm.h:147
PageTableConfig sec
Definition los_dynshm.h:149
PageTableConfig nonsec
Definition los_dynshm.h:148