Sound Open Firmware
Loading...
Searching...
No Matches
bit.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2018 Intel Corporation. All rights reserved.
4 *
5 * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
6 */
7
8#ifndef __XTOS_RTOS_BIT_H__
9#define __XTOS_RTOS_BIT_H__
10
11#if ASSEMBLY
12#define BIT(b) (1 << (b))
13#else
14#define BIT(b) (1UL << (b))
15#endif
16
17#define MASK(b_hi, b_lo) \
18 (((1ULL << ((b_hi) - (b_lo) + 1ULL)) - 1ULL) << (b_lo))
19#define SET_BIT(b, x) (((x) & 1) << (b))
20#define SET_BITS(b_hi, b_lo, x) \
21 (((x) & ((1ULL << ((b_hi) - (b_lo) + 1ULL)) - 1ULL)) << (b_lo))
22#define GET_BIT(b, x) \
23 (((x) & (1ULL << (b))) >> (b))
24#define GET_BITS(b_hi, b_lo, x) \
25 (((x) & MASK(b_hi, b_lo)) >> (b_lo))
26
27#endif /* __XTOS_RTOS_BIT_H__ */