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;
31    section .text:CODE:ROOT
32;/**************************************************************************/
33;/*                                                                        */
34;/*  FUNCTION                                               RELEASE        */
35;/*                                                                        */
36;/*    _tx_thread_interrupt_control                         RXv2/IAR       */
37;/*                                                           6.1.11       */
38;/*  AUTHOR                                                                */
39;/*                                                                        */
40;/*    William E. Lamie, Microsoft Corporation                             */
41;/*                                                                        */
42;/*  DESCRIPTION                                                           */
43;/*                                                                        */
44;/*    This function is responsible for changing the interrupt lockout     */
45;/*    posture of the system.                                              */
46;/*                                                                        */
47;/*  INPUT                                                                 */
48;/*                                                                        */
49;/*    new_posture                           New interrupt lockout posture */
50;/*                                                                        */
51;/*  OUTPUT                                                                */
52;/*                                                                        */
53;/*    old_posture                           Old interrupt lockout posture */
54;/*                                                                        */
55;/*  CALLS                                                                 */
56;/*                                                                        */
57;/*    None                                                                */
58;/*                                                                        */
59;/*  CALLED BY                                                             */
60;/*                                                                        */
61;/*    Application Code                                                    */
62;/*                                                                        */
63;/*  RELEASE HISTORY                                                       */
64;/*                                                                        */
65;/*    DATE              NAME                      DESCRIPTION             */
66;/*                                                                        */
67;/*  12-30-2020     William E. Lamie         Initial Version 6.1.3         */
68;/*  10-15-2021     William E. Lamie         Modified comment(s),          */
69;/*                                            resulting in version 6.1.9  */
70;/*  01-31-2022     William E. Lamie         Modified comment(s),          */
71;/*                                            resulting in version 6.1.10 */
72;/*  04-25-2022     William E. Lamie         Modified comment(s),          */
73;/*                                            resulting in version 6.1.11 */
74;/*                                                                        */
75;/**************************************************************************/
76;UINT   _tx_thread_interrupt_control(UINT new_posture)
77;{
78    public __tx_thread_interrupt_control
79__tx_thread_interrupt_control:
80;
81;    /* Pickup current interrupt lockout posture.  */
82;
83
84    MVFC      PSW, R2           ; Save PSW to R2
85    MOV.L     R2, R3            ; Make a copy of PSW in r3
86
87;
88;    /* Apply the new interrupt posture.  */
89;
90
91    BTST    #16, R1             ; Test I bit of PSW of "new posture"
92    BMNE    #16, R2             ; Conditionally set I bit of intermediate posture
93
94    MVTC    R2, PSW             ; Save intermediate posture to PSW
95
96    MOV.L   R3,R1               ; Get original SR
97    RTS                         ; Return to caller
98;}
99    END
100