1 /* 2 * Copyright (c) 2024 Synopsys. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_INCLUDE_ARCH_ARC_V2_VPX_ARC_VPX_H_ 8 #define ZEPHYR_INCLUDE_ARCH_ARC_V2_VPX_ARC_VPX_H_ 9 10 #include <zephyr/sys_clock.h> 11 12 /** 13 * @brief Obtain a cooperative lock on the VPX vector registers 14 * 15 * This function is used to obtain a cooperative lock on the current CPU's 16 * VPX vector registers before the calling thread uses them. Callers 17 * attempting to obtain the cooperative lock must be already restricted to 18 * executing on a single CPU, and continue to execute on that same CPU while 19 * both waiting and holding the lock. 20 * 21 * This routine is not callable from an ISR. 22 * 23 * @param timeout Waiting period to obtain the lock, or one of the special 24 * values K_NO_WAIT and K_FOREVER. 25 * 26 * @return Zero on success, otherwise error code 27 */ 28 int arc_vpx_lock(k_timeout_t timeout); 29 30 /** 31 * @brief Release cooperative lock on the VPX vector registers 32 * 33 * This function is used to release the cooperative lock on the current CPU's 34 * VPX vector registers. It is called after the current thread no longer needs 35 * to use the VPX vector registers, thereby allowing another thread to use them. 36 * 37 * This routine is not callable from an ISR. 38 */ 39 void arc_vpx_unlock(void); 40 41 /** 42 * @brief Release cooperative lock on a CPU's VPX vector registers 43 * 44 * This function is used to release the cooperative lock on the specified CPU's 45 * VPX vector registers. This routine should not be used except by a system 46 * monitor to release the cooperative lock in case the locking thread where it 47 * is known that the locking thread is unable to release it (e.g. it was 48 * aborted while holding the lock). 49 * 50 * @param cpu_id CPU ID of the VPX vector register set to be unlocked 51 */ 52 void arc_vpx_unlock_force(unsigned int cpu_id); 53 54 #endif /* ZEPHYR_INCLUDE_ARCH_ARC_V2_VPX_ARC_VPX_H_ */ 55