mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-09-23 14:51:31 +02:00
riscv: Fix detecting FPU support in standard extension
We should check the string until it hits underscore, in case it searches multi-letter extensions. For example, "rv64imac_xandes" will be treated as D extension support since there is a "d" in "andes", resulting illegal instruction caused by initializing FCSR. Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Rick Chen <rick@andestech.com> Reviewed-by: Padmarao Begari <padmarao.begari@microchip.com> Reviewed-by: Samuel Holland <samuel@sholland.org>
This commit is contained in:
parent
3f3527044d
commit
c277c787a0
@ -36,6 +36,7 @@ static inline bool supports_extension(char ext)
|
|||||||
#ifdef CONFIG_CPU
|
#ifdef CONFIG_CPU
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
char desc[32];
|
char desc[32];
|
||||||
|
int i;
|
||||||
|
|
||||||
uclass_find_first_device(UCLASS_CPU, &dev);
|
uclass_find_first_device(UCLASS_CPU, &dev);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
@ -43,9 +44,16 @@ static inline bool supports_extension(char ext)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!cpu_get_desc(dev, desc, sizeof(desc))) {
|
if (!cpu_get_desc(dev, desc, sizeof(desc))) {
|
||||||
/* skip the first 4 characters (rv32|rv64) */
|
/*
|
||||||
if (strchr(desc + 4, ext))
|
* skip the first 4 characters (rv32|rv64) and
|
||||||
return true;
|
* check until underscore
|
||||||
|
*/
|
||||||
|
for (i = 4; i < sizeof(desc); i++) {
|
||||||
|
if (desc[i] == '_' || desc[i] == '\0')
|
||||||
|
break;
|
||||||
|
if (desc[i] == ext)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user