diff options
author | Xiang Wang <merle@hardenedlinux.org> | 2019-11-26 13:36:29 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2019-11-26 13:36:29 +0300 |
commit | c96cc03fcc2723fa007b65e5ae6fe2673ea41413 (patch) | |
tree | 0ba08cbedbf6cefea45618ccdaf9180c27e9929c /lib/sbi/sbi_init.c | |
parent | 75f903dd78e2419057d04e14d6720fde764cbf78 (diff) | |
download | opensbi-c96cc03fcc2723fa007b65e5ae6fe2673ea41413.tar.xz |
lib: Fix CPU capabilities detection function
On some platforms, misa may not be implemented. On such a platform,
reading misa will get 0. At this time, platform is required to
implement a non-standard function to detect the CPU's capabilities.
Therefore, this modification add interfaces for non-standard function.
The MXL field of misa is always at the highest two bits, whether it
is a 32-bit 64-bit or a 128-bit machine. Therefore, this modification
fixes the use of a fixed offset to detect the machine length.
Signed-off-by: Xiang Wang <merle@hardenedlinux.org>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'lib/sbi/sbi_init.c')
-rw-r--r-- | lib/sbi/sbi_init.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c index 265bb02..51ce3a0 100644 --- a/lib/sbi/sbi_init.c +++ b/lib/sbi/sbi_init.c @@ -30,10 +30,10 @@ static void sbi_boot_prints(struct sbi_scratch *scratch, u32 hartid) { + int xlen; char str[64]; const struct sbi_platform *plat = sbi_platform_ptr(scratch); - misa_string(str, sizeof(str)); #ifdef OPENSBI_VERSION_GIT sbi_printf("\nOpenSBI %s\n", OPENSBI_VERSION_GIT); #else @@ -43,9 +43,18 @@ static void sbi_boot_prints(struct sbi_scratch *scratch, u32 hartid) sbi_printf(BANNER); + /* Determine MISA XLEN and MISA string */ + xlen = misa_xlen(); + if (xlen < 1) { + sbi_printf("Error %d getting MISA XLEN\n", xlen); + sbi_hart_hang(); + } + xlen = 16 * (1 << xlen); + misa_string(str, sizeof(str)); + /* Platform details */ sbi_printf("Platform Name : %s\n", sbi_platform_name(plat)); - sbi_printf("Platform HART Features : RV%d%s\n", misa_xlen(), str); + sbi_printf("Platform HART Features : RV%d%s\n", xlen, str); sbi_printf("Platform Max HARTs : %d\n", sbi_platform_hart_count(plat)); sbi_printf("Current Hart : %u\n", hartid); |