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 /**   Trace                                                               */
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_trace.h"
29 
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _tx_trace_disable                                   PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    William E. Lamie, Microsoft Corporation                             */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This function disables trace inside of ThreadX.                     */
44 /*                                                                        */
45 /*  INPUT                                                                 */
46 /*                                                                        */
47 /*    None                                                                */
48 /*                                                                        */
49 /*  OUTPUT                                                                */
50 /*                                                                        */
51 /*    Completion Status                                                   */
52 /*                                                                        */
53 /*  CALLS                                                                 */
54 /*                                                                        */
55 /*    None                                                                */
56 /*                                                                        */
57 /*  CALLED BY                                                             */
58 /*                                                                        */
59 /*    Application Code                                                    */
60 /*                                                                        */
61 /*  RELEASE HISTORY                                                       */
62 /*                                                                        */
63 /*    DATE              NAME                      DESCRIPTION             */
64 /*                                                                        */
65 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
66 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
67 /*                                            resulting in version 6.1    */
68 /*                                                                        */
69 /**************************************************************************/
_tx_trace_disable(VOID)70 UINT  _tx_trace_disable(VOID)
71 {
72 
73 #ifdef TX_ENABLE_EVENT_TRACE
74 UINT     status;
75 
76 
77     /* Determine if trace is already disabled.  */
78     if (_tx_trace_buffer_current_ptr == TX_NULL)
79     {
80 
81         /* Yes, trace is already disabled.  */
82         status =  TX_NOT_DONE;
83     }
84     else
85     {
86 
87         /* Otherwise, simply clear the current pointer and registery start pointer to disable the trace.  */
88         _tx_trace_buffer_current_ptr =  TX_NULL;
89         _tx_trace_registry_start_ptr =  TX_NULL;
90 
91         /* Successful completion.  */
92         status =  TX_SUCCESS;
93     }
94 
95     /* Return completion status.  */
96     return(status);
97 
98 #else
99 
100     /* Trace not enabled, return an error.  */
101     return(TX_FEATURE_NOT_ENABLED);
102 #endif
103 }
104 
105