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#ifdef TX_INCLUDE_USER_DEFINE_FILE
22#include "tx_user.h"
23#endif
24
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                        ARM11/GNU       */
53@/*                                                            6.2.1       */
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@/*  03-08-2023     Cindy Deng               Modified comment(s), added    */
85@/*                                            #include tx_user.h,         */
86@/*                                            resulting in version 6.2.1  */
87@/*                                                                        */
88@/**************************************************************************/
89@UINT   _tx_thread_interrupt_control(UINT new_posture)
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, 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@}
112
113