2019-06-02 03:14:06 +08:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2018-07-04 22:49:22 +08:00
|
|
|
*
|
2019-06-02 03:14:06 +08:00
|
|
|
* Copyright(c) 2018 Intel Corporation. All rights reserved.
|
2018-07-04 22:49:22 +08:00
|
|
|
*
|
|
|
|
* Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
|
|
|
|
*/
|
|
|
|
|
2022-08-20 04:07:29 +08:00
|
|
|
#ifndef __ZEPHYR_RTOS_BIT_H__
|
|
|
|
#define __ZEPHYR_RTOS_BIT_H__
|
2018-07-04 22:49:22 +08:00
|
|
|
|
2022-08-20 04:07:29 +08:00
|
|
|
#include <zephyr/sys/util.h>
|
2020-04-15 18:05:46 +08:00
|
|
|
|
2022-08-20 04:07:29 +08:00
|
|
|
/* TODO: align with Zephyr BIT APIs */
|
2020-02-13 18:51:29 +08:00
|
|
|
|
2018-11-22 02:23:55 +08:00
|
|
|
#define MASK(b_hi, b_lo) \
|
|
|
|
(((1ULL << ((b_hi) - (b_lo) + 1ULL)) - 1ULL) << (b_lo))
|
2018-07-04 22:49:22 +08:00
|
|
|
#define SET_BIT(b, x) (((x) & 1) << (b))
|
|
|
|
#define SET_BITS(b_hi, b_lo, x) \
|
2018-11-22 02:23:55 +08:00
|
|
|
(((x) & ((1ULL << ((b_hi) - (b_lo) + 1ULL)) - 1ULL)) << (b_lo))
|
2021-04-16 23:53:08 +08:00
|
|
|
#define GET_BIT(b, x) \
|
|
|
|
(((x) & (1ULL << (b))) >> (b))
|
|
|
|
#define GET_BITS(b_hi, b_lo, x) \
|
|
|
|
(((x) & MASK(b_hi, b_lo)) >> (b_lo))
|
2018-07-04 22:49:22 +08:00
|
|
|
|
2022-08-20 04:07:29 +08:00
|
|
|
#endif /* __ZEPHYR_RTOS_BIT_H__ */
|