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#ifdef TX_INCLUDE_USER_DEFINE_FILE
23#include "tx_user.h"
24#endif
25
26    AREA ||.text||, CODE, READONLY
27/**************************************************************************/
28/*                                                                        */
29/*  FUNCTION                                               RELEASE        */
30/*                                                                        */
31/*    _tx_thread_interrupt_control                     Cortex-Mx/AC5      */
32/*                                                           6.3.0        */
33/*  AUTHOR                                                                */
34/*                                                                        */
35/*    Scott Larson, Microsoft Corporation                                 */
36/*                                                                        */
37/*  DESCRIPTION                                                           */
38/*                                                                        */
39/*    This function is responsible for changing the interrupt lockout     */
40/*    posture of the system.                                              */
41/*                                                                        */
42/*  INPUT                                                                 */
43/*                                                                        */
44/*    new_posture                           New interrupt lockout posture */
45/*                                                                        */
46/*  OUTPUT                                                                */
47/*                                                                        */
48/*    old_posture                           Old interrupt lockout posture */
49/*                                                                        */
50/*  CALLS                                                                 */
51/*                                                                        */
52/*    None                                                                */
53/*                                                                        */
54/*  CALLED BY                                                             */
55/*                                                                        */
56/*    Application Code                                                    */
57/*                                                                        */
58/*  RELEASE HISTORY                                                       */
59/*                                                                        */
60/*    DATE              NAME                      DESCRIPTION             */
61/*                                                                        */
62/*  06-02-2021      Scott Larson            Initial Version 6.1.7         */
63/*  10-31-2023      Tiejun Zhou             Included tx_user.h,           */
64/*                                            resulting in version 6.3.0  */
65/*                                                                        */
66/**************************************************************************/
67// UINT   _tx_thread_interrupt_control(UINT new_posture)
68// {
69    EXPORT  _tx_thread_interrupt_control
70_tx_thread_interrupt_control
71#ifdef TX_PORT_USE_BASEPRI
72    MRS     r1, BASEPRI                         // Pickup current interrupt posture
73    MSR     BASEPRI, r0                         // Apply the new interrupt posture
74    MOV     r0, r1                              // Transfer old to return register
75#else
76    MRS     r1, PRIMASK                         // Pickup current interrupt lockout
77    MSR     PRIMASK, r0                         // Apply the new interrupt lockout
78    MOV     r0, r1                              // Transfer old to return register
79#endif
80    BX      lr                                  // Return to caller
81// }
82    END
83