Various macros used throughout the codebase
More...
|
file | regfield.h |
| Macros to help dealing with register fields.
|
|
|
#define | BIT(bit) (1u << (bit)) |
| Create a mask with a bit set.
|
|
#define | GENMASK(h, l) ((0xffffffff << (l)) & (0xffffffff >> (31 - (h)))) |
| Create a mask with a range of bits set.
|
|
#define | FIELD_GET(var, field) (((var) & (field)) >> __builtin_ctz(field)) |
| Extract a field value from a variable.
|
|
#define | FIELD_PREP(field, value) (((value) << __builtin_ctz(field)) & (field)) |
| Prepare a field with a given value.
|
|
Various macros used throughout the codebase
◆ BIT
#define BIT |
( |
| bit | ) |
(1u << (bit)) |
Create a mask with a bit set.
- Parameters
-
bit | The bit to set (from 0 to 31) |
- Returns
- A 32-bit mask with the corresponding bit set
◆ FIELD_GET
#define FIELD_GET |
( |
| var, |
|
|
| field ) (((var) & (field)) >> __builtin_ctz(field)) |
Extract a field value from a variable.
- Parameters
-
var | The 32-bit variable containing the field |
field | A 32-bit mask that corresponds to the field |
- Returns
- The value of the field (shifted)
◆ FIELD_PREP
#define FIELD_PREP |
( |
| field, |
|
|
| value ) (((value) << __builtin_ctz(field)) & (field)) |
Prepare a field with a given value.
- Parameters
-
field | A 32-bit mask that corresponds to the field |
value | The value to be put in the field |
◆ GENMASK
#define GENMASK |
( |
| h, |
|
|
| l ) ((0xffffffff << (l)) & (0xffffffff >> (31 - (h)))) |
Create a mask with a range of bits set.
- Parameters
-
h | The high bit of the range to set, included |
l | The low bit of the range to set, included |
- Returns
- A 32-bit mask with the corresponding bits set