1/*************************************************************************** 2 * Copyright (c) 2024 Microsoft Corporation 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the MIT License which is available at 6 * https://opensource.org/licenses/MIT. 7 * 8 * SPDX-License-Identifier: MIT 9 **************************************************************************/ 10 11 12/**************************************************************************/ 13/**************************************************************************/ 14/** */ 15/** ThreadX Component */ 16/** */ 17/** Thread */ 18/** */ 19/**************************************************************************/ 20/**************************************************************************/ 21 22 RETURN_MASK = 0x000000000000000F 23 SET_SR_MASK = 0xFFFFFFFFFFFFFFF0 24 25 .section .text 26/**************************************************************************/ 27/* */ 28/* FUNCTION RELEASE */ 29/* */ 30/* _tx_thread_interrupt_control RISC-V64/GNU */ 31/* 6.2.1 */ 32/* AUTHOR */ 33/* */ 34/* Scott Larson, Microsoft Corporation */ 35/* */ 36/* DESCRIPTION */ 37/* */ 38/* This function is responsible for changing the interrupt lockout */ 39/* posture of the system. */ 40/* */ 41/* INPUT */ 42/* */ 43/* new_posture New interrupt lockout posture */ 44/* */ 45/* OUTPUT */ 46/* */ 47/* old_posture Old interrupt lockout posture */ 48/* */ 49/* CALLS */ 50/* */ 51/* None */ 52/* */ 53/* CALLED BY */ 54/* */ 55/* Application Code */ 56/* */ 57/* RELEASE HISTORY */ 58/* */ 59/* DATE NAME DESCRIPTION */ 60/* */ 61/* 03-08-2023 Scott Larson Initial Version 6.2.1 */ 62/* */ 63/**************************************************************************/ 64/* UINT _tx_thread_interrupt_control(UINT new_posture) 65{ */ 66 .global _tx_thread_interrupt_control 67_tx_thread_interrupt_control: 68 /* Pickup current interrupt lockout posture. */ 69 70 csrr t0, mstatus 71 mv t1, t0 // Save original mstatus for return 72 73 /* Apply the new interrupt posture. */ 74 75 li t2, SET_SR_MASK // Build set SR mask 76 and t0, t0, t2 // Isolate interrupt lockout bits 77 or t0, t0, a0 // Put new lockout bits in 78 csrw mstatus, t0 79 andi a0, t1, RETURN_MASK // Return original mstatus. 80 ret 81/* } */ 82