Skip to content

Commit a7f9ebe

Browse files
fanghuaqikartben
authored andcommitted
driver: interrupt_controller: intc_clic: support 32 and 64 bit riscv cpu
This patch is used to provide clic(eclic) in 64 bit riscv cpu support, since in 64 bit riscv cpu, the clic irq table entry is also 64 bit, so we need to use ld/sd to do irq entry load and store Signed-off-by: Huaqi Fang <[email protected]>
1 parent 5cf6545 commit a7f9ebe

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

drivers/interrupt_controller/intc_clic.S

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,29 @@
1111
#include <zephyr/arch/cpu.h>
1212
#include "intc_clic.h"
1313

14+
#ifdef CONFIG_64BIT
15+
/* register-wide load/store based on ld/sd (XLEN = 64) */
16+
17+
.macro lr, rd, mem
18+
ld \rd, \mem
19+
.endm
20+
21+
.macro sr, rs, mem
22+
sd \rs, \mem
23+
.endm
24+
25+
#else
26+
/* register-wide load/store based on lw/sw (XLEN = 32) */
27+
28+
.macro lr, rd, mem
29+
lw \rd, \mem
30+
.endm
31+
32+
.macro sr, rs, mem
33+
sw \rs, \mem
34+
.endm
35+
36+
#endif
1437

1538
GTEXT(__soc_handle_irq)
1639
/*
@@ -36,7 +59,7 @@ GTEXT(sys_trace_isr_exit)
3659
*/
3760
SECTION_FUNC(exception.other, __soc_handle_all_irqs)
3861
addi sp, sp, -16
39-
sw ra, 0(sp)
62+
sr ra, 0(sp)
4063

4164
/* Read and clear mnxti to get highest current interrupt and enable interrupts. Will return
4265
* original interrupt if no others appear. */
@@ -58,10 +81,10 @@ irq_loop:
5881
add t0, t0, a0
5982

6083
/* Load argument in a0 register */
61-
lw a0, 0(t0)
84+
lr a0, 0(t0)
6285

6386
/* Load ISR function address in register t1 */
64-
lw t1, RV_REGSIZE(t0)
87+
lr t1, RV_REGSIZE(t0)
6588

6689
/* Call ISR function */
6790
jalr ra, t1, 0
@@ -75,6 +98,6 @@ irq_loop:
7598
bnez a0, irq_loop
7699

77100
irq_done:
78-
lw ra, 0(sp)
101+
lr ra, 0(sp)
79102
addi sp, sp, 16
80103
ret

0 commit comments

Comments
 (0)