Skip to content

Commit 6c0a7d1

Browse files
committed
[libcpu-riscv]: [common64 virt64]:Fix compilation errors after enabling the SMP architecture.
Currently, the bsp: qemu-virt64-riscv does not support the SMP architecture, and some necessary interfaces are not implemented. Solution: Add the interface declarations to make the compilation pass. Signed-off-by: Mengchen Teng <teng_mengchen@163.com>
1 parent 6a9a1df commit 6c0a7d1

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

libcpu/risc-v/common64/cpuport.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,15 @@ void rt_hw_set_process_id(int pid)
137137
{
138138
// TODO
139139
}
140+
141+
#ifdef RT_USING_SMP
142+
void rt_hw_secondary_cpu_up(void)
143+
{
144+
145+
}
146+
147+
void secondary_cpu_entry(void)
148+
{
149+
150+
}
151+
#endif /* RT_USING_SMP */

libcpu/risc-v/common64/interrupt_gcc.S

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ _resume_kernel:
8888
csrw sscratch, zero
8989
sret
9090

91+
#ifndef RT_USING_SMP
9192
.global rt_hw_interrupt_enable
9293
rt_hw_interrupt_enable:
9394
csrs sstatus, a0 /* restore to old csr */
@@ -97,3 +98,18 @@ rt_hw_interrupt_enable:
9798
rt_hw_interrupt_disable:
9899
csrrci a0, sstatus, 2 /* clear SIE */
99100
jr ra
101+
#else
102+
.global rt_hw_local_irq_disable
103+
rt_hw_local_irq_disable:
104+
csrrci a0, sstatus, 2
105+
jr ra
106+
107+
.global rt_hw_local_irq_enable
108+
rt_hw_local_irq_enable:
109+
csrs sstatus, a0
110+
jr ra
111+
112+
.global rt_hw_secondary_cpu_idle_exec
113+
rt_hw_secondary_cpu_idle_exec:
114+
jr ra
115+
#endif /* RT_USING_SMP */

libcpu/risc-v/common64/trap.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ static volatile int nested = 0;
136136
#define EXIT_TRAP nested -= 1
137137
#define CHECK_NESTED_PANIC(cause, tval, epc, eframe) \
138138
if (nested != 1) handle_nested_trap_panic(cause, tval, epc, eframe)
139+
#else
140+
/* Add trap nesting detection under the SMP architecture. */
141+
static volatile int nested[RT_CPUS_NR] = {0};
142+
#define ENTER_TRAP nested[rt_hw_cpu_id()] += 1
143+
#define EXIT_TRAP nested[rt_hw_cpu_id()] -= 1
144+
#define CHECK_NESTED_PANIC(cause, tval, epc, eframe) \
145+
if (nested[rt_hw_cpu_id()] != 1) \
146+
handle_nested_trap_panic(cause, tval, epc, eframe)
139147
#endif /* RT_USING_SMP */
140148

141149
static const char *get_exception_msg(int id)

libcpu/risc-v/virt64/interrupt.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,25 @@ void rt_hw_interrupt_init()
9292

9393
plic_set_threshold(0);
9494
}
95+
96+
#ifdef RT_USING_SMP
97+
void rt_hw_spin_lock_init(rt_hw_spinlock_t *_lock)
98+
{
99+
100+
}
101+
102+
void rt_hw_spin_lock(rt_hw_spinlock_t *lock)
103+
{
104+
105+
}
106+
107+
void rt_hw_spin_unlock(rt_hw_spinlock_t *lock)
108+
{
109+
110+
}
111+
112+
void rt_hw_ipi_send(int ipi_vector, unsigned int cpu_mask)
113+
{
114+
115+
}
116+
#endif /* RT_USING_SMP */

0 commit comments

Comments
 (0)