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

浏览源代码.

函数

STATUS_T OsAllocAsid (UINT32 *asid)
 
VOID OsFreeAsid (UINT32 asid)
 释放 asid 更多...
 

函数说明

◆ OsAllocAsid()

STATUS_T OsAllocAsid ( UINT32 asid)

在文件 los_asid.c78 行定义.

79{
80 UINT32 flags;
81 LOS_SpinLockSave(&g_cpuAsidLock, &flags);
82 UINT32 firstZeroBit = LOS_BitmapFfz(g_asidPool, 1UL << MMU_ARM_ASID_BITS);//找到第一个0位,即可分配位
83 if (firstZeroBit >= 0 && firstZeroBit < (1UL << MMU_ARM_ASID_BITS)) {
84 LOS_BitmapSetNBits(g_asidPool, firstZeroBit, 1);//设为已分配
85 *asid = firstZeroBit;//由参数带走
86 LOS_SpinUnlockRestore(&g_cpuAsidLock, flags);
87 return LOS_OK;
88 }
89
90 LOS_SpinUnlockRestore(&g_cpuAsidLock, flags);
91 return firstZeroBit;
92}
INT32 LOS_BitmapFfz(UINTPTR *bitmap, UINT32 numBits)
从numBits位置开始找到第一个0位
Definition: los_bitmap.c:146
VOID LOS_BitmapSetNBits(UINTPTR *bitmap, UINT32 start, UINT32 numsSet)
从start位置开始设置numsSet个bit位 置1
Definition: los_bitmap.c:106
STATIC UINTPTR g_asidPool[BITMAP_NUM_WORDS(1UL<< MMU_ARM_ASID_BITS)]
地址空间ID池 , 2^8 = 256 个
Definition: los_asid.c:75
VOID LOS_SpinUnlockRestore(SPIN_LOCK_S *lock, UINT32 intSave)
Definition: los_spinlock.c:108
VOID LOS_SpinLockSave(SPIN_LOCK_S *lock, UINT32 *intSave)
Definition: los_spinlock.c:98
unsigned int UINT32
Definition: los_typedef.h:57
函数调用图:
这是这个函数的调用关系图:

◆ OsFreeAsid()

VOID OsFreeAsid ( UINT32  asid)

释放 asid

在文件 los_asid.c96 行定义.

97{
98 UINT32 flags;
99 LOS_SpinLockSave(&g_cpuAsidLock, &flags);
100 LOS_BitmapClrNBits(g_asidPool, asid, 1);//清空对应位,可继续分配给其他进程
101 LOS_SpinUnlockRestore(&g_cpuAsidLock, flags);
102}
VOID LOS_BitmapClrNBits(UINTPTR *bitmap, UINT32 start, UINT32 numsClear)
从start位置开始 清除numsSet个bit位置0 ,对状态字的连续标志位进行清0操作
Definition: los_bitmap.c:126
函数调用图:
这是这个函数的调用关系图: