From ce1af8b0bf8569ad2d0ebc7bc7b0babe1579c7f2 Mon Sep 17 00:00:00 2001 From: Xiang Wang Date: Wed, 1 Aug 2018 12:36:14 +0800 Subject: riscv: add support to check machine length at runtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Highest two bits of misa can be used to check machine length. Add code to support this. Change-Id: I3bab301d38ea8aabf2c70437e179287814298b25 Signed-off-by: Xiang Wang Reviewed-on: https://review.coreboot.org/27770 Tested-by: build bot (Jenkins) Reviewed-by: Jonathan Neuschäfer --- src/arch/riscv/include/arch/cpu.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/arch') diff --git a/src/arch/riscv/include/arch/cpu.h b/src/arch/riscv/include/arch/cpu.h index 6008c75122..d2f42a8665 100644 --- a/src/arch/riscv/include/arch/cpu.h +++ b/src/arch/riscv/include/arch/cpu.h @@ -51,5 +51,11 @@ static inline int supports_extension(char ext) return read_csr(misa) & (1 << (ext - 'A')); } +static inline int machine_xlen(void) +{ + int mxl = (read_csr(misa) >> (__riscv_xlen - 2)) & 3; + return (1 << mxl) * 16; +} + struct cpu_info *cpu_info(void); #endif /* __ARCH_CPU_H__ */ -- cgit v1.2.3