Macros to help dealing with register fields.
More...
#include <sys/cdefs.h>
Go to the source code of this file.
|
#define | BIT(bit) |
| Create a mask with a bit set.
|
|
#define | GENMASK(h, l) |
| Create a mask with a range of bits set.
|
|
#define | FIELD_GET(var, field) |
| Extract a field value from a variable.
|
|
#define | FIELD_PREP(field, value) |
| Prepare a field with a given value.
|
|
Macros to help dealing with register fields.
- Author
- Paul Cercueil
◆ BIT
Value:
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 ) |
Value: (((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: (((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
Value:((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