1 /* 2 * =========================================================================================== 3 * 4 * Filename: hal_atomic.c 5 * 6 * Description: atomic impl. for hal layer. 7 * 8 * Version: Melis3.0 9 * Create: 2019-11-26 15:16:41 10 * Revision: none 11 * Compiler: GCC:version 7.2.1 20170904 (release),ARM/embedded-7-branch revision 255204 12 * 13 * Author: caozilong@allwinnertech.com 14 * Organization: BU1-PSW 15 * Last Modified: 2020-04-02 17:10:48 16 * 17 * =========================================================================================== 18 */ 19 20 #include <hal_atomic.h> 21 #include <rthw.h> 22 #include <rtthread.h> 23 24 /* TODO: handle lock */ hal_spin_lock(hal_spinlock_t * lock)25void hal_spin_lock(hal_spinlock_t *lock) 26 { 27 rt_enter_critical(); 28 return; 29 } 30 31 /* TODO: handle lock */ hal_spin_unlock(hal_spinlock_t * lock)32void hal_spin_unlock(hal_spinlock_t *lock) 33 { 34 rt_exit_critical(); 35 return; 36 } 37 38 /* TODO: handle lock */ hal_spin_lock_irqsave(hal_spinlock_t * lock)39uint32_t hal_spin_lock_irqsave(hal_spinlock_t *lock) 40 { 41 uint32_t ret; 42 // CPSR_ALLOC(); 43 44 // MELIS_CPU_CRITICAL_ENTER(); 45 rt_enter_critical(); 46 ret = rt_hw_interrupt_disable(); 47 48 return ret; 49 } 50 51 /* TODO: handle lock */ hal_spin_unlock_irqrestore(hal_spinlock_t * lock,uint32_t __cpsr)52void hal_spin_unlock_irqrestore(hal_spinlock_t *lock, uint32_t __cpsr) 53 { 54 rt_hw_interrupt_enable(__cpsr); 55 rt_exit_critical(); 56 57 // MELIS_CPU_CRITICAL_LEAVE(); 58 } 59