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;#define TX_SOURCE_CODE
23;
24;
25;/* Include necessary system files.  */
26;
27;#include "tx_api.h"
28;#include "tx_thread.h"
29;
30;
31    .SECTION    P,CODE
32;/**************************************************************************/
33;/*                                                                        */
34;/*  FUNCTION                                               RELEASE        */
35;/*                                                                        */
36;/*    _tx_thread_interrupt_control                         RXv1/CCRX      */
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;/*  08-02-2021     William E. Lamie         Initial Version 6.1.8         */
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
79.GLB __tx_thread_interrupt_control
80__tx_thread_interrupt_control:
81;
82;    /* Pickup current interrupt lockout posture.  */
83;
84
85    MVFC      PSW, R2           ; Save PSW to R2
86    MOV.L     R2, R3            ; Make a copy of PSW in r3
87
88;
89;    /* Apply the new interrupt posture.  */
90;
91
92    BTST    #16, R1             ; Test I bit of PSW of "new posture"
93    BMNE    #16, R2             ; Conditionally set I bit of intermediate posture
94
95    MVTC    R2, PSW             ; Save intermediate posture to PSW
96
97    MOV.L   R3,R1               ; Get original SR
98    RTS                         ; Return to caller
99;}
100    .END
101