]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/portable/GCC/RISC-V-RV32/portASM.S
Update RISC-V port to use a separate interrupt stack.
[freertos] / FreeRTOS / Source / portable / GCC / RISC-V-RV32 / portASM.S
index 5f6c3a10ed8db94f5040a120426351f931e42e55..e9ba83856fc8d67993de853e9b54006c54891e9a 100644 (file)
@@ -49,7 +49,7 @@
 .extern pullMachineTimerCompareRegister\r
 .extern pullNextTime\r
 .extern ulTimerIncrementsForOneTick\r
-\r
+.extern xISRStackTop\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
@@ -136,14 +136,13 @@ vPortTrapHandler:
 \r
        csrr a0, mcause\r
        csrr a1, mepc\r
-       mv a2, sp\r
 \r
 test_if_environment_call:\r
        li t0, 11                                                               /* 11 == environment call when using qemu. */\r
        bne a0, t0, test_if_timer\r
        addi a1, a1, 4                                                  /* Synchronous so return to the instruction after the environment call. */\r
        sw a1, 0( sp )                                                  /* Save updated exception return address. */\r
-/*_RB_ Does stack need aligning here? */\r
+       lw sp, xISRStackTop                                             /* Switch to ISR stack before function call. */\r
        jal vTaskSwitchContext\r
        j processed_source\r
 \r
@@ -167,13 +166,15 @@ test_if_timer:
        add t6, t3, t5                                                  /* Add overflow to high word of ullNextTime. */\r
        sw t4, 0(t1)                                                    /* Store new low word of ullNextTime. */\r
        sw t6, 4(t1)                                                    /* Store new high word of ullNextTime. */\r
+       lw sp, xISRStackTop                                             /* Switch to ISR stack before function call. */\r
        jal xTaskIncrementTick\r
        beqz a0, processed_source                               /* Don't switch context if incrementing tick didn't unblock a task. */\r
        jal vTaskSwitchContext\r
        j processed_source\r
 \r
 as_yet_unhandled:\r
-       j as_yet_unhandled                                              /* External interrupt? */\r
+//     ebreak                                          /* External interrupt? */\r
+       j as_yet_unhandled\r
 \r
 processed_source:\r
        lw  sp, pxCurrentTCB                                    /* Load pxCurrentTCB. */\r