更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
vid_api.h 文件参考

浏览源代码.

函数

UINT32 VidMapListInit (LosProcessCB *processCB)
 
VOID VidMapDestroy (LosProcessCB *processCB)
 销毁虚拟ID映射 更多...
 
UINT16 AddNodeByRid (UINT16 rid)
 
UINT16 GetRidByVid (UINT16 vid)
 
VOID RemoveNodeByVid (UINT16 vid)
 

函数说明

◆ AddNodeByRid()

UINT16 AddNodeByRid ( UINT16  rid)

在文件 vid.c178 行定义.

179{
180 TimerIdMapNode *tmp = NULL;
181 LosProcessCB *processCB = OsCurrProcessGet();
182 UINT16 vid;
183
184 tmp = FindListNodeByRid(rid);
185 if (tmp) {
186 return tmp->vid;
187 }
188
189 LOS_MuxLock(&processCB->timerIdMap.vidMapLock, LOS_WAIT_FOREVER);
190 vid = GetFreeVid();
191 if (vid == MAX_INVALID_TIMER_VID) {
193 errno = ENOMEM;
194 return MAX_INVALID_TIMER_VID;
195 }
197 if (tmp == NULL) {
198 PRINT_ERR("%s %d, alloc memory failed\n", __FUNCTION__, __LINE__);
200 errno = ENOMEM;
201 return MAX_INVALID_TIMER_VID;
202 }
203 tmp->rid = rid;
204 tmp->vid = vid;
205
206 LOS_ListTailInsert(&processCB->timerIdMap.head, &tmp->node);
208
209 return vid;
210}
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListTailInsert(LOS_DL_LIST *list, LOS_DL_LIST *node)
Insert a node to the tail of a doubly linked list.
Definition: los_list.h:244
VOID * LOS_MemAlloc(VOID *pool, UINT32 size)
从指定内存池中申请size长度的内存,注意这可不是从内核堆空间中申请内存
Definition: los_memory.c:1123
UINT8 * m_aucSysMem0
异常交互动态内存池地址的起始地址,当不支持异常交互特性时,m_aucSysMem0等于m_aucSysMem1。
Definition: los_memory.c:107
LITE_OS_SEC_TEXT UINT32 LOS_MuxUnlock(LosMux *mutex)
释放锁
Definition: los_mux.c:559
LITE_OS_SEC_TEXT UINT32 LOS_MuxLock(LosMux *mutex, UINT32 timeout)
拿互斥锁,
Definition: los_mux.c:437
STATIC INLINE LosProcessCB * OsCurrProcessGet(VOID)
unsigned short UINT16
Definition: los_typedef.h:56
TimerIdMap timerIdMap
LOS_DL_LIST head
Definition: vid_type.h:38
LosMux vidMapLock
Definition: vid_type.h:37
UINT16 rid
Definition: vid_type.h:45
LOS_DL_LIST node
Definition: vid_type.h:44
UINT16 vid
Definition: vid_type.h:46
static TimerIdMapNode * FindListNodeByRid(UINT32 rid)
Definition: vid.c:90
static UINT16 GetFreeVid(VOID)
Definition: vid.c:107
函数调用图:
这是这个函数的调用关系图:

◆ GetRidByVid()

UINT16 GetRidByVid ( UINT16  vid)

在文件 vid.c212 行定义.

213{
215 if (tmp) {
216 return tmp->rid;
217 }
218 return 0xffff;
219}
static TimerIdMapNode * FindListNodeByVid(UINT16 vid)
Definition: vid.c:73
函数调用图:
这是这个函数的调用关系图:

◆ RemoveNodeByVid()

VOID RemoveNodeByVid ( UINT16  vid)

在文件 vid.c221 行定义.

222{
223 TimerIdMapNode *tmp = NULL;
224 LosProcessCB *processCB = OsCurrProcessGet();
225
226 tmp = FindListNodeByVid(vid);
227 if (tmp == NULL) {
228 return;
229 }
230
231 LOS_MuxLock(&processCB->timerIdMap.vidMapLock, LOS_WAIT_FOREVER);
232 LOS_ListDelete(&tmp->node);
233 ReleaseVid(tmp->vid);
236
237 return;
238}
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListDelete(LOS_DL_LIST *node)
Definition: los_list.h:292
UINT32 LOS_MemFree(VOID *pool, VOID *ptr)
释放从指定动态内存中申请的内存
Definition: los_memory.c:1369
static VOID ReleaseVid(UINT16 vid)
Definition: vid.c:148
函数调用图:
这是这个函数的调用关系图:

◆ VidMapDestroy()

VOID VidMapDestroy ( LosProcessCB processCB)

销毁虚拟ID映射

在文件 vid.c57 行定义.

58{
59 TimerIdMapNode *idNode = NULL;
60 TimerIdMapNode *idNodeNext = NULL;
61
62 LOS_MuxLock(&processCB->timerIdMap.vidMapLock, LOS_WAIT_FOREVER);
63 LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(idNode, idNodeNext, &processCB->timerIdMap.head, TimerIdMapNode, node) {
64 LOS_ListDelete(&idNode->node);
66 }
67
71}
LITE_OS_SEC_TEXT UINT32 LOS_MuxDestroy(LosMux *mutex)
销毁互斥锁
Definition: los_mux.c:289
UINT32 * bitMap
Definition: vid_type.h:40
函数调用图:
这是这个函数的调用关系图:

◆ VidMapListInit()

UINT32 VidMapListInit ( LosProcessCB processCB)

在文件 vid.c36 行定义.

37{
38 (void)memset_s(&processCB->timerIdMap, sizeof(TimerIdMap), 0, sizeof(TimerIdMap));
39 LOS_ListInit(&processCB->timerIdMap.head);
40 processCB->timerIdMap.bitMap = (UINT32*)LOS_MemAlloc(m_aucSysMem0, sizeof(UINT32));
41 if (processCB->timerIdMap.bitMap == NULL) {
42 PRINT_ERR("%s %d, alloc memory failed\n", __FUNCTION__, __LINE__);
43 return LOS_NOK;
44 }
45
46 processCB->timerIdMap.mapCount = 1;
47 (void)memset_s(processCB->timerIdMap.bitMap, sizeof(UINT32), 0, sizeof(UINT32));
48 if (LOS_MuxInit(&processCB->timerIdMap.vidMapLock, NULL) != LOS_OK) {
49 PRINT_ERR("%s %d, Create mutex for vmm failed\n", __FUNCTION__, __LINE__);
51 processCB->timerIdMap.bitMap = NULL;
52 return LOS_NOK;
53 }
54 return LOS_OK;
55}
LITE_OS_SEC_ALW_INLINE STATIC INLINE VOID LOS_ListInit(LOS_DL_LIST *list)
Definition: los_list.h:104
LITE_OS_SEC_TEXT UINT32 LOS_MuxInit(LosMux *mutex, const LosMuxAttr *attr)
初始化互斥锁
Definition: los_mux.c:262
unsigned int UINT32
Definition: los_typedef.h:57
UINT16 mapCount
Definition: vid_type.h:39
ARG_NUM_3 ARG_NUM_1 ARG_NUM_2 ARG_NUM_2 ARG_NUM_3 ARG_NUM_1 ARG_NUM_4 ARG_NUM_2 ARG_NUM_2 ARG_NUM_5 ARG_NUM_2 void
函数调用图:
这是这个函数的调用关系图: