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@/* Define the 16-bit Thumb mode veneer for _tx_thread_interrupt_restore for
26@   applications calling this function from to 16-bit Thumb mode.  */
27@
28    .text
29    .align 2
30    .global $_tx_thread_interrupt_restore
31$_tx_thread_interrupt_restore:
32        .thumb
33     BX        pc                               @ Switch to 32-bit mode
34     NOP                                        @
35    .arm
36     STMFD     sp!, {lr}                        @ Save return address
37     BL        _tx_thread_interrupt_restore     @ Call _tx_thread_interrupt_restore function
38     LDMFD     sp!, {lr}                        @ Recover saved return address
39     BX        lr                               @ Return to 16-bit caller
40@
41@
42    .text
43    .align 2
44@/**************************************************************************/
45@/*                                                                        */
46@/*  FUNCTION                                               RELEASE        */
47@/*                                                                        */
48@/*    _tx_thread_interrupt_restore                         ARM9/GNU       */
49@/*                                                           6.2.1        */
50@/*  AUTHOR                                                                */
51@/*                                                                        */
52@/*    William E. Lamie, Microsoft Corporation                             */
53@/*                                                                        */
54@/*  DESCRIPTION                                                           */
55@/*                                                                        */
56@/*    This function is responsible for restoring interrupts to the state  */
57@/*    returned by a previous _tx_thread_interrupt_disable call.           */
58@/*                                                                        */
59@/*  INPUT                                                                 */
60@/*                                                                        */
61@/*    old_posture                           Old interrupt lockout posture */
62@/*                                                                        */
63@/*  OUTPUT                                                                */
64@/*                                                                        */
65@/*    None                                                                */
66@/*                                                                        */
67@/*  CALLS                                                                 */
68@/*                                                                        */
69@/*    None                                                                */
70@/*                                                                        */
71@/*  CALLED BY                                                             */
72@/*                                                                        */
73@/*    Application Code                                                    */
74@/*                                                                        */
75@/*  RELEASE HISTORY                                                       */
76@/*                                                                        */
77@/*    DATE              NAME                      DESCRIPTION             */
78@/*                                                                        */
79@/*  09-30-2020     William E. Lamie         Initial Version 6.1           */
80@/*  03-08-2023     Cindy Deng               Modified comment(s), added    */
81@/*                                            #include tx_user.h,         */
82@/*                                            resulting in version 6.2.1  */
83@/*                                                                        */
84@/**************************************************************************/
85@UINT   _tx_thread_interrupt_restore(UINT old_posture)
86@{
87    .global  _tx_thread_interrupt_restore
88    .type    _tx_thread_interrupt_restore,function
89_tx_thread_interrupt_restore:
90@
91@    /* Apply the new interrupt posture.  */
92@
93    MSR     CPSR_cxsf, r0                       @ Setup new CPSR
94#ifdef __THUMB_INTERWORK
95    BX      lr                                  @ Return to caller
96#else
97    MOV     pc, lr                              @ Return to caller
98#endif
99@}
100
101