1/**************************************************************************/ 2/* */ 3/* Copyright (c) Microsoft Corporation. All rights reserved. */ 4/* */ 5/* This software is licensed under the Microsoft Software License */ 6/* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8/* and in the root directory of this software. */ 9/* */ 10/**************************************************************************/ 11 12 13/**************************************************************************/ 14/**************************************************************************/ 15/** */ 16/** ThreadX Component */ 17/** */ 18/** Thread */ 19/** */ 20/**************************************************************************/ 21/**************************************************************************/ 22 23/* #define TX_SOURCE_CODE */ 24 25 26/* Include necessary system files. */ 27 28/* #include "tx_api.h" 29 #include "tx_thread.h" */ 30 31RETURN_MASK DEFINE 0x0000000F 32SET_SR_MASK DEFINE 0xFFFFFFF0 33 34 SECTION `.text`:CODE:REORDER:NOROOT(2) 35 CODE 36/**************************************************************************/ 37/* */ 38/* FUNCTION RELEASE */ 39/* */ 40/* _tx_thread_interrupt_control RISC-V32/IAR */ 41/* 6.1 */ 42/* AUTHOR */ 43/* */ 44/* William E. Lamie, Microsoft Corporation */ 45/* Tom van Leeuwen, Technolution B.V. */ 46/* */ 47/* DESCRIPTION */ 48/* */ 49/* This function is responsible for changing the interrupt lockout */ 50/* posture of the system. */ 51/* */ 52/* INPUT */ 53/* */ 54/* new_posture New interrupt lockout posture */ 55/* */ 56/* OUTPUT */ 57/* */ 58/* old_posture Old interrupt lockout posture */ 59/* */ 60/* CALLS */ 61/* */ 62/* None */ 63/* */ 64/* CALLED BY */ 65/* */ 66/* Application Code */ 67/* */ 68/* RELEASE HISTORY */ 69/* */ 70/* DATE NAME DESCRIPTION */ 71/* */ 72/* 09-30-2020 William E. Lamie Initial Version 6.1 */ 73/* */ 74/**************************************************************************/ 75/* UINT _tx_thread_interrupt_control(UINT new_posture) 76{ */ 77 PUBLIC _tx_thread_interrupt_control 78_tx_thread_interrupt_control: 79 /* Pickup current interrupt lockout posture. */ 80 81 csrr t0, mstatus 82 mv t1, t0 ; Save original mstatus for return 83 84 /* Apply the new interrupt posture. */ 85 86 li t2, SET_SR_MASK ; Build set SR mask 87 and t0, t0, t2 ; Isolate interrupt lockout bits 88 or t0, t0, a0 ; Put new lockout bits in 89 csrw mstatus, t0 90 andi a0, t1, RETURN_MASK ; Return original mstatus. 91 ret 92/* } */ 93 END 94