/*************************************************************************** * 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 **************************************************************************/ .section .text .align 4 #include "tx_port.h" /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* trap_entry RISC-V64/GNU */ /* 6.2.1 */ /* AUTHOR */ /* */ /* Jer6y , luojun@oerv.isrc.iscas.ac.cn */ /* */ /* DESCRIPTION */ /* */ /* This function is responsible for riscv processor trap handle */ /* It will do the contex save and call c trap_handler and do contex */ /* load */ /* */ /* INPUT */ /* */ /* None */ /* */ /* OUTPUT */ /* */ /* None */ /* */ /* CALLS */ /* */ /* trap_handler */ /* */ /* CALLED BY */ /* */ /* hardware exception */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 10-25-2024 Jerry Luo */ /* */ /**************************************************************************/ /**************************************************************************/ /**************************************************************************/ /** */ /** ThreadX Component */ /** */ /** Initialize */ /** */ /**************************************************************************/ /**************************************************************************/ .balign 4 .global trap_entry .type trap_entry, @function trap_entry: addi sp, sp, -TX_RISCV_TRAP_FRAME_SIZE #if __riscv_xlen == 64 sd ra, 28*8(sp) #else sw ra, 28*4(sp) #endif call _tx_thread_context_save csrr a0, mcause csrr a1, mepc csrr a2, mtval call trap_handler tail _tx_thread_context_restore .weak trap_handler trap_handler: j trap_handler