2 * @ingroup adf_os_public
4 * This file abstracts locking operations.
10 #include <adf_os_types.h>
11 #include <adf_os_lock_pvt.h>
14 * @brief Platform spinlock object
16 typedef __adf_os_spinlock_t adf_os_spinlock_t;
19 * @brief Platform mutex object
21 typedef __adf_os_mutex_t adf_os_mutex_t;
24 * @brief Initialize a mutex
26 * @param[in] m mutex to initialize
28 static inline void adf_os_init_mutex(adf_os_mutex_t *m)
30 __adf_os_init_mutex(m);
34 * @brief Take the mutex
36 * @param[in] m mutex to take
38 static inline int adf_os_mutex_acquire(adf_os_mutex_t *m)
40 return (__adf_os_mutex_acquire(m));
44 * @brief Give the mutex
46 * @param[in] m mutex to give
48 static inline void adf_os_mutex_release(adf_os_mutex_t *m)
50 __adf_os_mutex_release(m);
54 * @brief Initialize a spinlock
56 * @param[in] lock spinlock object pointer
59 adf_os_spinlock_init(adf_os_spinlock_t *lock)
61 __adf_os_spinlock_init(lock);
66 * @brief Acquire a spinlock by disabling the interrupts
68 * @param[in] lock spinlock object pointer
69 * @param[out] flags flags used to hold interrupt state
72 adf_os_spin_lock_irq(adf_os_spinlock_t *lock, a_uint32_t *flags)
74 __adf_os_spin_lock_irq(lock,flags);
79 * @brief Release a spinlock & restore the irq
81 * @param[in] lock spinlock object pointer
82 * @param[in] flags flags filled in by @ref adf_os_spin_lock_irq
85 adf_os_spin_unlock_irq(adf_os_spinlock_t *lock, a_uint32_t *flags)
87 __adf_os_spin_unlock_irq(lock,flags);
92 * @brief locks the spinlock mutex in soft irq context
94 * @param[in] lock spinlock object pointer
97 adf_os_spin_lock_bh(adf_os_spinlock_t *lock)
99 __adf_os_spin_lock_bh(lock);
104 * @brief unlocks the spinlock mutex in soft irq context
106 * @param[in] lock spinlock object pointer
109 adf_os_spin_unlock_bh(adf_os_spinlock_t *lock)
111 __adf_os_spin_unlock_bh(lock);
116 * @brief Execute the input function with spinlock held and interrupt disabled.
118 * @param[in] hdl OS handle
119 * @param[in] lock spinlock to be held for the critical region
120 * @param[in] func critical region function that to be executed
121 * @param[in] context context of the critical region function
123 * @return Boolean status returned by the critical region function
125 static inline a_bool_t
126 adf_os_spinlock_irq_exec(adf_os_handle_t hdl,
127 adf_os_spinlock_t *lock,
128 adf_os_irqlocked_func_t func,
131 return __adf_os_spinlock_irq_exec(hdl, lock, func, arg);