Files
ThreadX4TGFS/port/threadx/src/trap_entry.S
T
alex d404e17e5a Migrates plain ThreadX to the upstream RISC-V ports
Keeps the Moonlight startup objects local to the board. Updates the plain and SMP VP regression harnesses for the new ThreadX revision and replaces generated ISR hooks with direct callbacks.
2026-11-26 18:56:36 +01:00

44 lines
1.1 KiB
ArmAsm

/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/
#include "tx_port.h"
#if __riscv_xlen == 64
#define REG_STORE sd
#define REG_LOAD ld
#define REG_BYTES 8
#else
#define REG_STORE sw
#define REG_LOAD lw
#define REG_BYTES 4
#endif
.section .text
.balign 4
.global trap_entry
.type trap_entry, @function
trap_entry:
addi sp, sp, -TX_RISCV_TRAP_FRAME_SIZE
REG_STORE ra, (28 * REG_BYTES)(sp)
call _tx_thread_context_save
csrr a0, mcause
csrr a1, mepc
csrr a2, mtval
addi sp, sp, -TX_RISCV_TRAP_CALL_FRAME_SIZE
REG_STORE ra, 0(sp)
call trap_handler
REG_LOAD ra, 0(sp)
addi sp, sp, TX_RISCV_TRAP_CALL_FRAME_SIZE
call _tx_thread_context_restore
1: j 1b
.size trap_entry, .-trap_entry