xref: /openbmc/linux/arch/arm64/include/asm/sysreg.h (revision 588b48ca)
1 /*
2  * Macros for accessing system registers with older binutils.
3  *
4  * Copyright (C) 2014 ARM Ltd.
5  * Author: Catalin Marinas <catalin.marinas@arm.com>
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef __ASM_SYSREG_H
21 #define __ASM_SYSREG_H
22 
23 #define sys_reg(op0, op1, crn, crm, op2) \
24 	((((op0)-2)<<19)|((op1)<<16)|((crn)<<12)|((crm)<<8)|((op2)<<5))
25 
26 #ifdef __ASSEMBLY__
27 
28 	.irp	num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30
29 	.equ	__reg_num_x\num, \num
30 	.endr
31 	.equ	__reg_num_xzr, 31
32 
33 	.macro	mrs_s, rt, sreg
34 	.inst	0xd5300000|(\sreg)|(__reg_num_\rt)
35 	.endm
36 
37 	.macro	msr_s, sreg, rt
38 	.inst	0xd5100000|(\sreg)|(__reg_num_\rt)
39 	.endm
40 
41 #else
42 
43 asm(
44 "	.irp	num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30\n"
45 "	.equ	__reg_num_x\\num, \\num\n"
46 "	.endr\n"
47 "	.equ	__reg_num_xzr, 31\n"
48 "\n"
49 "	.macro	mrs_s, rt, sreg\n"
50 "	.inst	0xd5300000|(\\sreg)|(__reg_num_\\rt)\n"
51 "	.endm\n"
52 "\n"
53 "	.macro	msr_s, sreg, rt\n"
54 "	.inst	0xd5100000|(\\sreg)|(__reg_num_\\rt)\n"
55 "	.endm\n"
56 );
57 
58 #endif
59 
60 #endif	/* __ASM_SYSREG_H */
61