2014-07-24 13:14:42 +00:00
|
|
|
/*
|
|
|
|
* Macros for accessing system registers with older binutils.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 ARM Ltd.
|
|
|
|
* Author: Catalin Marinas <catalin.marinas@arm.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ASM_SYSREG_H
|
|
|
|
#define __ASM_SYSREG_H
|
|
|
|
|
2015-07-22 18:05:54 +00:00
|
|
|
#include <asm/opcodes.h>
|
|
|
|
|
2015-07-21 12:23:27 +00:00
|
|
|
#define SCTLR_EL1_CP15BEN (0x1 << 5)
|
|
|
|
#define SCTLR_EL1_SED (0x1 << 8)
|
|
|
|
|
2015-07-22 10:38:14 +00:00
|
|
|
/*
|
|
|
|
* ARMv8 ARM reserves the following encoding for system registers:
|
|
|
|
* (Ref: ARMv8 ARM, Section: "System instruction class encoding overview",
|
|
|
|
* C5.2, version:ARM DDI 0487A.f)
|
|
|
|
* [20-19] : Op0
|
|
|
|
* [18-16] : Op1
|
|
|
|
* [15-12] : CRn
|
|
|
|
* [11-8] : CRm
|
|
|
|
* [7-5] : Op2
|
|
|
|
*/
|
2014-07-24 13:14:42 +00:00
|
|
|
#define sys_reg(op0, op1, crn, crm, op2) \
|
2015-07-22 10:38:14 +00:00
|
|
|
((((op0)&3)<<19)|((op1)<<16)|((crn)<<12)|((crm)<<8)|((op2)<<5))
|
2014-07-24 13:14:42 +00:00
|
|
|
|
2015-07-22 18:05:54 +00:00
|
|
|
#define REG_PSTATE_PAN_IMM sys_reg(0, 0, 4, 0, 4)
|
|
|
|
#define SCTLR_EL1_SPAN (1 << 23)
|
|
|
|
|
|
|
|
#define SET_PSTATE_PAN(x) __inst_arm(0xd5000000 | REG_PSTATE_PAN_IMM |\
|
|
|
|
(!!x)<<8 | 0x1f)
|
|
|
|
|
2015-10-19 13:24:42 +00:00
|
|
|
#define ID_AA64MMFR0_BIGENDEL0_SHIFT 16
|
|
|
|
#define ID_AA64MMFR0_BIGENDEL_SHIFT 8
|
2015-10-19 13:19:35 +00:00
|
|
|
|
|
|
|
#define ID_AA64MMFR0_TGRAN4_SHIFT 28
|
|
|
|
#define ID_AA64MMFR0_TGRAN64_SHIFT 24
|
|
|
|
#define ID_AA64MMFR0_TGRAN16_SHIFT 20
|
|
|
|
|
|
|
|
#define ID_AA64MMFR0_TGRAN4_NI 0xf
|
|
|
|
#define ID_AA64MMFR0_TGRAN4_SUPPORTED 0x0
|
|
|
|
#define ID_AA64MMFR0_TGRAN64_NI 0xf
|
|
|
|
#define ID_AA64MMFR0_TGRAN64_SUPPORTED 0x0
|
|
|
|
#define ID_AA64MMFR0_TGRAN16_NI 0x0
|
|
|
|
#define ID_AA64MMFR0_TGRAN16_SUPPORTED 0x1
|
|
|
|
|
|
|
|
#if defined(CONFIG_ARM64_4K_PAGES)
|
|
|
|
#define ID_AA64MMFR0_TGRAN_SHIFT ID_AA64MMFR0_TGRAN4_SHIFT
|
|
|
|
#define ID_AA64MMFR0_TGRAN_SUPPORTED ID_AA64MMFR0_TGRAN4_SUPPORTED
|
2015-10-19 13:19:37 +00:00
|
|
|
#elif defined(CONFIG_ARM64_16K_PAGES)
|
|
|
|
#define ID_AA64MMFR0_TGRAN_SHIFT ID_AA64MMFR0_TGRAN16_SHIFT
|
|
|
|
#define ID_AA64MMFR0_TGRAN_SUPPORTED ID_AA64MMFR0_TGRAN16_SUPPORTED
|
2015-10-19 13:19:35 +00:00
|
|
|
#elif defined(CONFIG_ARM64_64K_PAGES)
|
|
|
|
#define ID_AA64MMFR0_TGRAN_SHIFT ID_AA64MMFR0_TGRAN64_SHIFT
|
|
|
|
#define ID_AA64MMFR0_TGRAN_SUPPORTED ID_AA64MMFR0_TGRAN64_SUPPORTED
|
|
|
|
#endif
|
|
|
|
|
2014-07-24 13:14:42 +00:00
|
|
|
#ifdef __ASSEMBLY__
|
|
|
|
|
|
|
|
.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
|
|
|
|
.equ __reg_num_x\num, \num
|
|
|
|
.endr
|
|
|
|
.equ __reg_num_xzr, 31
|
|
|
|
|
|
|
|
.macro mrs_s, rt, sreg
|
2015-07-22 10:38:14 +00:00
|
|
|
.inst 0xd5200000|(\sreg)|(__reg_num_\rt)
|
2014-07-24 13:14:42 +00:00
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro msr_s, sreg, rt
|
2015-07-22 10:38:14 +00:00
|
|
|
.inst 0xd5000000|(\sreg)|(__reg_num_\rt)
|
2014-07-24 13:14:42 +00:00
|
|
|
.endm
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
asm(
|
|
|
|
" .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"
|
|
|
|
" .equ __reg_num_x\\num, \\num\n"
|
|
|
|
" .endr\n"
|
|
|
|
" .equ __reg_num_xzr, 31\n"
|
|
|
|
"\n"
|
|
|
|
" .macro mrs_s, rt, sreg\n"
|
2015-07-22 10:38:14 +00:00
|
|
|
" .inst 0xd5200000|(\\sreg)|(__reg_num_\\rt)\n"
|
2014-07-24 13:14:42 +00:00
|
|
|
" .endm\n"
|
|
|
|
"\n"
|
|
|
|
" .macro msr_s, sreg, rt\n"
|
2015-07-22 10:38:14 +00:00
|
|
|
" .inst 0xd5000000|(\\sreg)|(__reg_num_\\rt)\n"
|
2014-07-24 13:14:42 +00:00
|
|
|
" .endm\n"
|
|
|
|
);
|
|
|
|
|
2015-07-21 12:23:27 +00:00
|
|
|
static inline void config_sctlr_el1(u32 clear, u32 set)
|
|
|
|
{
|
|
|
|
u32 val;
|
|
|
|
|
|
|
|
asm volatile("mrs %0, sctlr_el1" : "=r" (val));
|
|
|
|
val &= ~clear;
|
|
|
|
val |= set;
|
|
|
|
asm volatile("msr sctlr_el1, %0" : : "r" (val));
|
|
|
|
}
|
2014-07-24 13:14:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __ASM_SYSREG_H */
|