mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-16 09:34:18 +00:00
feat(lib): add EXTRACT_FIELD macro for field extraction
Introduce a new EXTRACT_FIELD macro to simplify the extraction of specific fields from a value by shifting the value right and applying the mask. Change-Id: Iae9573d6d23067bbde13253e264e4f6f18b806c2 Signed-off-by: Manish V Badarkhe <Manish.Badarkhe@arm.com>
This commit is contained in:
parent
7aa73612d7
commit
af1dd6e1a5
1 changed files with 14 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved.
|
||||
* Copyright (c) 2016-2025, Arm Limited and Contributors. All rights reserved.
|
||||
* Copyright (c) 2020, NVIDIA Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
|
@ -218,4 +218,17 @@
|
|||
*/
|
||||
#define KHZ_TICKS_PER_SEC U(1000)
|
||||
|
||||
/**
|
||||
* EXTRACT_FIELD - Extracts a specific bit field from a value.
|
||||
*
|
||||
* @val: The input value containing the field.
|
||||
* @mask: A bitmask representing the maximum value of the field
|
||||
* @shift: The starting bit position of the field.
|
||||
*
|
||||
* This macro shifts the input value (@val) to the right by @shift bits,
|
||||
* aligning the target field to the least significant bits (LSB).
|
||||
* It then applies @mask to extract only the relevant bits.
|
||||
*/
|
||||
#define EXTRACT_FIELD(val, mask, shift) (((val) >> (shift)) & (mask))
|
||||
|
||||
#endif /* UTILS_DEF_H */
|
||||
|
|
Loading…
Add table
Reference in a new issue