File tree Expand file tree Collapse file tree 2 files changed +18
-14
lines changed
Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Original file line number Diff line number Diff line change @@ -697,10 +697,27 @@ irqstate_t up_irq_enable(void);
697697 * Description:
698698 * Return the real core number regardless CONFIG_SMP setting
699699 *
700+ * When CONFIG_RISCV_PERCPU_SCRATCH is enabled, this uses the percpu
701+ * scratch area to store the hart ID. This is needed when the CSR_MHARTID
702+ * register may not contain the actual hart ID.
703+ *
704+ * When CONFIG_RISCV_PERCPU_SCRATCH is not enabled, this directly reads
705+ * the CSR_MHARTID register. Use this version when you can guarantee
706+ * CSR_MHARTID contains the actual hart ID. This is the default behavior
707+ * that can be achieved by single instruction to provide better
708+ * performance.
709+ *
700710 ****************************************************************************/
701711
702712#ifdef CONFIG_ARCH_HAVE_MULTICPU
703- int up_cpu_index (void ) noinstrument_function ;
713+ noinstrument_function static inline int up_cpu_index (void )
714+ {
715+ #ifdef CONFIG_RISCV_PERCPU_SCRATCH
716+ return (int )riscv_mhartid ();
717+ #else
718+ return READ_CSR (CSR_MHARTID );
719+ #endif
720+ }
704721#endif /* CONFIG_ARCH_HAVE_MULTICPU */
705722
706723/****************************************************************************
Original file line number Diff line number Diff line change 3737 * Public Functions
3838 ****************************************************************************/
3939
40- /****************************************************************************
41- * Name: up_cpu_index
42- *
43- * Description:
44- * Return the real core number regardless CONFIG_SMP setting
45- *
46- ****************************************************************************/
47-
48- int up_cpu_index (void )
49- {
50- return (int )riscv_mhartid ();
51- }
52-
5340/****************************************************************************
5441 * Name: up_this_cpu
5542 *
You can’t perform that action at this time.
0 commit comments