XilinxProcessorIPLib/drivers/aiengine/src/tile/xaietile_lock.c
u8 XAieTile_LockAcquire(XAieGbl_Tile *TileInstPtr, u8 LockId, u8 LockVal,
								u32 TimeOut)
{
	u64 RegAddr;
	u8 AcqDone = XAIETILE_LOCK_ACQ_FAILED;
	u8 Lsb;
	u32 Mask, Value;
	XAieGbl_RegLocks *RegPtr;

	XAie_AssertNonvoid(TileInstPtr != XAIE_NULL);
	XAie_AssertNonvoid(LockId < XAIEGBL_TILE_LOCK_NUM_MAX);
	XAie_AssertNonvoid(LockVal == XAIETILE_LOCK_ACQ_VAL0 ||
				LockVal == XAIETILE_LOCK_ACQ_VAL1 ||
				LockVal == XAIETILE_LOCK_ACQ_VALINVALID);

	if(TileInstPtr->TileType == XAIEGBL_TILE_TYPE_AIETILE) {
                RegPtr = &TileLockRegs[LockId];
        } else {
                RegPtr = &ShimLockRegs[LockId];
        }

	if(LockVal == XAIETILE_LOCK_ACQ_VAL0) {
		/* Acquire lock with value 0 register address */
		RegAddr = TileInstPtr->TileAddr + RegPtr->AcqV0Off;
		Lsb = RegPtr->AcqV0.Lsb;
		Mask = RegPtr->AcqV0.Mask;

	} else if(LockVal == XAIETILE_LOCK_ACQ_VAL1) {
		/* Acquire lock with value 1 register address */
		RegAddr = TileInstPtr->TileAddr + RegPtr->AcqV1Off;
		Lsb = RegPtr->AcqV1.Lsb;
		Mask = RegPtr->AcqV1.Mask;
	} else {
		/* LockVal == XAIETILE_LOCK_ACQ_VALINVALID */
		/* Acquire lock with no value register address */
		RegAddr = TileInstPtr->TileAddr + RegPtr->AcqNvOff;
		Lsb = RegPtr->AcqNv.Lsb;
		Mask = RegPtr->AcqNv.Mask;
	}

	Value = XAIETILE_LOCK_ACQ_SUCCESS << Lsb;

	if (XAieGbl_MaskPoll(RegAddr, Mask, Value, TimeOut) == XAIE_SUCCESS) {
		AcqDone = XAIETILE_LOCK_ACQ_SUCCESS;
	}

	return AcqDone;
}
/************************** Function Definitions *****************************/
/*****************************************************************************/
/**
*
* This API is used to acquire the specified lock with or without value. Lock
* acquired without value if LockVal==0xFF. This API can be blocking or non-
* blocking based on the TimeOut value. If TimeOut==0, then API behaves in a
* non-blocking fashion and returns immediately after the first read request.
* If TimeOut>0, then API becomes blocking and will issue the read request until
* the acquire is successful or time out happens, whichever occurs first.
*
* @param	TileInstPtr - Pointer to the Tile instance.
* @param	LockId - Lock value index, ranging from 0-15.
* @param	LockVal - Lock value used for acquire. If set to 0xFF, lock
*		acquired with no value.
* @param	TimeOut - Time-out value for which the read request needs to
*		be repeated. Value to be specified in usecs.
*
* @return	1 if acquire successful, else 0.
*
* @note		None.
*
*******************************************************************************/
Function Definitions
This API is used to acquire the specified lock with or without value. Lock
acquired without value if LockVal==0xFF. This API can be blocking or non
blocking based on the TimeOut value. If TimeOut==0, then API behaves in a
non-blocking fashion and returns immediately after the first read request.
If TimeOut>0, then API becomes blocking and will issue the read request until
the acquire is successful or time out happens, whichever occurs first.
Function Definitions This API is used to acquire the specified lock with or without value . Lock acquired without value if LockVal == 0xFF . This API can be blocking or non blocking based on the TimeOut value . If TimeOut == 0 then API behaves in a non - blocking fashion and returns immediately after the first read request . If TimeOut > 0 then API becomes blocking and will issue the read request until the acquire is successful or time out happens whichever occurs first .
u8 XAieTile_LockAcquire(XAieGbl_Tile *TileInstPtr, u8 LockId, u8 LockVal,
								u32 TimeOut)
{
	u64 RegAddr;
	u8 AcqDone = XAIETILE_LOCK_ACQ_FAILED;
	u8 Lsb;
	u32 Mask, Value;
	XAieGbl_RegLocks *RegPtr;
	XAie_AssertNonvoid(TileInstPtr != XAIE_NULL);
	XAie_AssertNonvoid(LockId < XAIEGBL_TILE_LOCK_NUM_MAX);
	XAie_AssertNonvoid(LockVal == XAIETILE_LOCK_ACQ_VAL0 ||
				LockVal == XAIETILE_LOCK_ACQ_VAL1 ||
				LockVal == XAIETILE_LOCK_ACQ_VALINVALID);
	if(TileInstPtr->TileType == XAIEGBL_TILE_TYPE_AIETILE) {
                RegPtr = &TileLockRegs[LockId];
        } else {
                RegPtr = &ShimLockRegs[LockId];
        }
	if(LockVal == XAIETILE_LOCK_ACQ_VAL0) {
		RegAddr = TileInstPtr->TileAddr + RegPtr->AcqV0Off;
		Lsb = RegPtr->AcqV0.Lsb;
		Mask = RegPtr->AcqV0.Mask;
	} else if(LockVal == XAIETILE_LOCK_ACQ_VAL1) {
		RegAddr = TileInstPtr->TileAddr + RegPtr->AcqV1Off;
		Lsb = RegPtr->AcqV1.Lsb;
		Mask = RegPtr->AcqV1.Mask;
	} else {
		RegAddr = TileInstPtr->TileAddr + RegPtr->AcqNvOff;
		Lsb = RegPtr->AcqNv.Lsb;
		Mask = RegPtr->AcqNv.Mask;
	}
	Value = XAIETILE_LOCK_ACQ_SUCCESS << Lsb;
	if (XAieGbl_MaskPoll(RegAddr, Mask, Value, TimeOut) == XAIE_SUCCESS) {
		AcqDone = XAIETILE_LOCK_ACQ_SUCCESS;
	}
	return AcqDone;
}
u8 XAieTile_LockAcquire ( XAieGbl_Tile * TileInstPtr , u8 LockId , u8 LockVal , u32 TimeOut ) { u64 RegAddr ; u8 AcqDone = XAIETILE_LOCK_ACQ_FAILED ; u8 Lsb ; u32 Mask , Value ; XAieGbl_RegLocks * RegPtr ; XAie_AssertNonvoid ( TileInstPtr != XAIE_NULL ) ; XAie_AssertNonvoid ( LockId < XAIEGBL_TILE_LOCK_NUM_MAX ) ; XAie_AssertNonvoid ( LockVal == XAIETILE_LOCK_ACQ_VAL0 || LockVal == XAIETILE_LOCK_ACQ_VAL1 || LockVal == XAIETILE_LOCK_ACQ_VALINVALID ) ; if ( TileInstPtr -> TileType == XAIEGBL_TILE_TYPE_AIETILE ) { RegPtr = & TileLockRegs [ LockId ] ; } else { RegPtr = & ShimLockRegs [ LockId ] ; } if ( LockVal == XAIETILE_LOCK_ACQ_VAL0 ) { RegAddr = TileInstPtr -> TileAddr + RegPtr -> AcqV0Off ; Lsb = RegPtr -> AcqV0 . Lsb ; Mask = RegPtr -> AcqV0 . Mask ; } else if ( LockVal == XAIETILE_LOCK_ACQ_VAL1 ) { RegAddr = TileInstPtr -> TileAddr + RegPtr -> AcqV1Off ; Lsb = RegPtr -> AcqV1 . Lsb ; Mask = RegPtr -> AcqV1 . Mask ; } else { RegAddr = TileInstPtr -> TileAddr + RegPtr -> AcqNvOff ; Lsb = RegPtr -> AcqNv . Lsb ; Mask = RegPtr -> AcqNv . Mask ; } Value = XAIETILE_LOCK_ACQ_SUCCESS << Lsb ; if ( XAieGbl_MaskPoll ( RegAddr , Mask , Value , TimeOut ) == XAIE_SUCCESS ) { AcqDone = XAIETILE_LOCK_ACQ_SUCCESS ; } return AcqDone ; }
Function Definitions
This API is used to acquire the specified lock with or without value.
Function Definitions This API is used to acquire the specified lock with or without value .
/* Acquire lock with value 0 register address */ /* Acquire lock with value 1 register address */ /* LockVal == XAIETILE_LOCK_ACQ_VALINVALID */ /* Acquire lock with no value register address */