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    EXTERN  _tx_execution_isr_enter
27    SECTION `.text`:CODE:NOROOT(2)
28    THUMB
29/**************************************************************************/
30/*                                                                        */
31/*  FUNCTION                                               RELEASE        */
32/*                                                                        */
33/*    _tx_thread_context_save                          Cortex-Mx/IAR      */
34/*                                                           6.3.0        */
35/*  AUTHOR                                                                */
36/*                                                                        */
37/*    Scott Larson, Microsoft Corporation                                 */
38/*                                                                        */
39/*  DESCRIPTION                                                           */
40/*                                                                        */
41/*    This function is only needed for legacy applications and it should  */
42/*    not be called in any new development on a Cortex-M.                 */
43/*                                                                        */
44/*  INPUT                                                                 */
45/*                                                                        */
46/*    None                                                                */
47/*                                                                        */
48/*  OUTPUT                                                                */
49/*                                                                        */
50/*    None                                                                */
51/*                                                                        */
52/*  CALLS                                                                 */
53/*                                                                        */
54/*    [_tx_execution_isr_enter]             Execution profiling ISR enter */
55/*                                                                        */
56/*  CALLED BY                                                             */
57/*                                                                        */
58/*    ISRs                                                                */
59/*                                                                        */
60/*  RELEASE HISTORY                                                       */
61/*                                                                        */
62/*    DATE              NAME                      DESCRIPTION             */
63/*                                                                        */
64/*  06-02-2021      Scott Larson            Initial Version 6.1.7         */
65/*  10-31-2023      Tiejun Zhou             Included tx_user.h,           */
66/*                                            resulting in version 6.3.0  */
67/*                                                                        */
68/**************************************************************************/
69// VOID   _tx_thread_context_save(VOID)
70// {
71    PUBLIC  _tx_thread_context_save
72_tx_thread_context_save:
73
74#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
75    /* Call the ISR enter function to indicate an ISR is starting.  */
76    PUSH    {r0, lr}                                // Save return address
77    BL      _tx_execution_isr_enter                 // Call the ISR enter function
78    POP     {r0, lr}                                // Recover return address
79#endif
80
81    /* Context is already saved - just return.  */
82
83    BX      lr
84// }
85    END
86