diff options
Diffstat (limited to 'ports/risc-v64/gnu/src/tx_thread_interrupt_control.S')
| -rw-r--r-- | ports/risc-v64/gnu/src/tx_thread_interrupt_control.S | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/ports/risc-v64/gnu/src/tx_thread_interrupt_control.S b/ports/risc-v64/gnu/src/tx_thread_interrupt_control.S index c75c7c47..dfcb6b47 100644 --- a/ports/risc-v64/gnu/src/tx_thread_interrupt_control.S +++ b/ports/risc-v64/gnu/src/tx_thread_interrupt_control.S @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * 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 **************************************************************************/ @@ -19,8 +20,6 @@ /**************************************************************************/ /**************************************************************************/ - RETURN_MASK = 0x000000000000000F - SET_SR_MASK = 0xFFFFFFFFFFFFFFF0 .section .text /**************************************************************************/ @@ -54,28 +53,26 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 03-08-2023 Scott Larson Initial Version 6.2.1 */ -/* */ /**************************************************************************/ /* UINT _tx_thread_interrupt_control(UINT new_posture) { */ .global _tx_thread_interrupt_control _tx_thread_interrupt_control: /* Pickup current interrupt lockout posture. */ + /* old_mstatus = mstatus; */ csrr t0, mstatus mv t1, t0 // Save original mstatus for return - /* Apply the new interrupt posture. */ + /* Apply the new interrupt posture while preserving unrelated mstatus bits. */ + /* Only modify the MIE bit (bit 3) */ + /* mstatus = (mstatus & ~MIE) | (new_posture & MIE); */ - li t2, SET_SR_MASK // Build set SR mask - and t0, t0, t2 // Isolate interrupt lockout bits - or t0, t0, a0 // Put new lockout bits in + li t2, ~0x08 // Build mask to clear MIE + and t0, t0, t2 // Clear MIE bit + and a0, a0, 0x08 // Mask incoming to only MIE bit + or t0, t0, a0 // Set requested MIE state csrw mstatus, t0 - andi a0, t1, RETURN_MASK // Return original mstatus. + andi a0, t1, 0x08 // Return original MIE bit ret /* } */ |
