mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 07:45:16 +08:00
riscv_cpuindex.c: Fix usage of CONFIG_ARCH_RV_HARTID_BASE
The offset was supposed to assume hartid > cpuid, so when converting from hartid we must subtract the offset to get the cpuid and vice versa.
This commit is contained in:
@@ -73,7 +73,7 @@ int up_this_cpu(void)
|
||||
|
||||
int weak_function riscv_hartid_to_cpuid(int cpu)
|
||||
{
|
||||
return cpu + CONFIG_ARCH_RV_HARTID_BASE;
|
||||
return cpu - CONFIG_ARCH_RV_HARTID_BASE;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -87,5 +87,5 @@ int weak_function riscv_hartid_to_cpuid(int cpu)
|
||||
|
||||
int weak_function riscv_cpuid_to_hartid(int cpu)
|
||||
{
|
||||
return cpu - CONFIG_ARCH_RV_HARTID_BASE;
|
||||
return cpu + CONFIG_ARCH_RV_HARTID_BASE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user