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