// SPDX-License-Identifier: GPL-2.0-only #include "img_osal.h" #include "umac_debugs.h" #include "img_module_iface.h" void img_mac80211_timer_func(KRN_TIMER_T *meos_timer, void *timerPar) { int err; struct timer_list *timer = (struct timer_list *)timerPar; if(!timer->function) { return; } if(timer->task == 0xFFFF) { /* handling reorder timer in rx task*/ IMG_RX_DBG_PARAM_INCR(timer_mbox_post, 1); rx_task_post(IMG_MODULE_IFACE_TIMER_RX_PORT, timerPar, sizeof(void *)); } else { IMG_RX_DBG_PARAM_INCR(timer_mbox_post ,1); umac_task_post(IMG_MODULE_IFACE_TIMER_PORT, timerPar, sizeof(void *)); } } void add_timer(struct timer_list *timer) { int timer_value; timer_value = timer->expires - jiffies; timer_value = (timer_value > 0) ? timer_value : 0; if (timer_value == 0) { timer_value = 1; } if (timer_value > 2000) { timer_value =2000; } KRN_setTimer((KRN_TIMER_T *)&timer->timer, img_mac80211_timer_func, timer, timer_value*1000); timer->timer_pending = 1; } int del_timer(struct timer_list *timer) { KRN_cancelTimer((KRN_TIMER_T *)&timer->timer); timer->timer_pending = 0; return 0; } int del_timer_sync(struct timer_list *timer) { return del_timer(timer); } void timer_setup(struct timer_list *timer, void (*func)(struct timer_list *), unsigned int flags) { timer->function = func; timer->data = (unsigned long)timer; } void mod_timer(struct timer_list *timer, unsigned long expires) { del_timer(timer); timer->expires = expires; add_timer(timer); } int timer_pending(const struct timer_list * timer) { return timer->timer_pending; } void init_timer(struct timer_list * timer) { (void) timer; TIMER_DBG_INFO("%s:%d timer: %p\n", __FUNCTION__, __LINE__, timer); } void mutex_lock(spinlock_t *lock) { int ret; ret = KRN_lock(((KRN_LOCK_T *)(lock)), -1); if(ret == 0) { LOCKS_ERR_LOG("llf: %s:%d test lock failed\n", __FUNCTION__, __LINE__); } return; } void mutex_unlock(spinlock_t *lock) { KRN_unlock(((KRN_LOCK_T *)(lock))); return; } void spin_lock_irqsave(spinlock_t *ipl, unsigned long flags) { *((KRN_IPL_T *)(ipl)) = KRN_raiseIPL(); (void) flags; return; } void spin_unlock_irqrestore(spinlock_t *ipl, unsigned long flags) { KRN_restoreIPL(*((KRN_IPL_T *)(ipl))); (void) flags; return; } void update_jiffie() { curr_jiffies = (mips_getcount()/clock_ticks_usec)/1000; if(curr_jiffies > prev_jiffies) { jiffies = jiffies + (curr_jiffies - prev_jiffies); } prev_jiffies = curr_jiffies; meos_sec = jiffies/1000; }