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#ifdef TX_INCLUDE_USER_DEFINE_FILE
23#include "tx_user.h"
24#endif
25
26INT_MASK        =   0x03F
27
28
29/* Define the 16-bit Thumb mode veneer for _tx_thread_interrupt_control for
30   applications calling this function from to 16-bit Thumb mode.  */
31
32    .text
33    .align 2
34    .global $_tx_thread_interrupt_control
35$_tx_thread_interrupt_control:
36        .thumb
37     BX        pc                               // Switch to 32-bit mode
38     NOP                                        //
39    .arm
40     STMFD     sp!, {lr}                        // Save return address
41     BL        _tx_thread_interrupt_control     // Call _tx_thread_interrupt_control function
42     LDMFD     sp!, {lr}                        // Recover saved return address
43     BX        lr                               // Return to 16-bit caller
44
45
46    .text
47    .align 2
48/**************************************************************************/
49/*                                                                        */
50/*  FUNCTION                                               RELEASE        */
51/*                                                                        */
52/*    _tx_thread_interrupt_control                         ARMv7-A        */
53/*                                                           6.3.0        */
54/*  AUTHOR                                                                */
55/*                                                                        */
56/*    William E. Lamie, Microsoft Corporation                             */
57/*                                                                        */
58/*  DESCRIPTION                                                           */
59/*                                                                        */
60/*    This function is responsible for changing the interrupt lockout     */
61/*    posture of the system.                                              */
62/*                                                                        */
63/*  INPUT                                                                 */
64/*                                                                        */
65/*    new_posture                           New interrupt lockout posture */
66/*                                                                        */
67/*  OUTPUT                                                                */
68/*                                                                        */
69/*    old_posture                           Old interrupt lockout posture */
70/*                                                                        */
71/*  CALLS                                                                 */
72/*                                                                        */
73/*    None                                                                */
74/*                                                                        */
75/*  CALLED BY                                                             */
76/*                                                                        */
77/*    Application Code                                                    */
78/*                                                                        */
79/*  RELEASE HISTORY                                                       */
80/*                                                                        */
81/*    DATE              NAME                      DESCRIPTION             */
82/*                                                                        */
83/*  09-30-2020     William E. Lamie         Initial Version 6.1           */
84/*  04-25-2022     Zhen Kong                Updated comments,             */
85/*                                            resulting in version 6.1.11 */
86/*  10-31-2023     Tiejun Zhou              Modified comment(s), added    */
87/*                                            #include tx_user.h,         */
88/*                                            resulting in version 6.3.0  */
89/*                                                                        */
90/**************************************************************************/
91    .global _tx_thread_interrupt_control
92    .type   _tx_thread_interrupt_control,function
93_tx_thread_interrupt_control:
94
95    /* Pickup current interrupt lockout posture.  */
96
97    MRS     r3, CPSR                    // Pickup current CPSR
98    MOV     r2, #INT_MASK               // Build interrupt mask
99    AND     r1, r3, r2                  // Clear interrupt lockout bits
100    ORR     r1, r1, r0                  // Or-in new interrupt lockout bits
101
102    /* Apply the new interrupt posture.  */
103
104    MSR     CPSR_c, r1                  // Setup new CPSR
105    BIC     r0, r3, r2                  // Return previous interrupt mask
106#ifdef __THUMB_INTERWORK
107    BX      lr                          // Return to caller
108#else
109    MOV     pc, lr                      // Return to caller
110#endif
111