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