riscv: add support to check machine length at runtime

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 <wxjstz@126.com>
Reviewed-on: https://review.coreboot.org/27770
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
This commit is contained in:
Xiang Wang 2018-08-01 12:36:14 +08:00 committed by Patrick Georgi
parent ee0f225e3a
commit ce1af8b0bf
1 changed files with 6 additions and 0 deletions

View File

@ -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__ */