Skip to content

Commit c9ee0f9

Browse files
Suzuki K Poulosewildea01
authored andcommitted
arm64: cpufeature: Define helpers for sys_reg id
Define helper macros to extract op0, op1, CRn, CRm & op2 for a given sys_reg id. While at it remove the explicit masking only used for Op0. Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Will Deacon <will.deacon@arm.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent 156e0d5 commit c9ee0f9

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

arch/arm64/include/asm/sysreg.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,27 @@
3232
* [11-8] : CRm
3333
* [7-5] : Op2
3434
*/
35+
#define Op0_shift 19
36+
#define Op0_mask 0x3
37+
#define Op1_shift 16
38+
#define Op1_mask 0x7
39+
#define CRn_shift 12
40+
#define CRn_mask 0xf
41+
#define CRm_shift 8
42+
#define CRm_mask 0xf
43+
#define Op2_shift 5
44+
#define Op2_mask 0x7
45+
3546
#define sys_reg(op0, op1, crn, crm, op2) \
36-
((((op0)&3)<<19)|((op1)<<16)|((crn)<<12)|((crm)<<8)|((op2)<<5))
47+
(((op0) << Op0_shift) | ((op1) << Op1_shift) | \
48+
((crn) << CRn_shift) | ((crm) << CRm_shift) | \
49+
((op2) << Op2_shift))
50+
51+
#define sys_reg_Op0(id) (((id) >> Op0_shift) & Op0_mask)
52+
#define sys_reg_Op1(id) (((id) >> Op1_shift) & Op1_mask)
53+
#define sys_reg_CRn(id) (((id) >> CRn_shift) & CRn_mask)
54+
#define sys_reg_CRm(id) (((id) >> CRm_shift) & CRm_mask)
55+
#define sys_reg_Op2(id) (((id) >> Op2_shift) & Op2_mask)
3756

3857
#ifndef CONFIG_BROKEN_GAS_INST
3958

0 commit comments

Comments
 (0)