1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** ThreadX Component                                                     */
17 /**                                                                       */
18 /**   Trace                                                               */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define TX_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "tx_api.h"
29 #include "tx_trace.h"
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _tx_trace_disable                                   PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    William E. Lamie, Microsoft Corporation                             */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function disables trace inside of ThreadX.                     */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    None                                                                */
49 /*                                                                        */
50 /*  OUTPUT                                                                */
51 /*                                                                        */
52 /*    Completion Status                                                   */
53 /*                                                                        */
54 /*  CALLS                                                                 */
55 /*                                                                        */
56 /*    None                                                                */
57 /*                                                                        */
58 /*  CALLED BY                                                             */
59 /*                                                                        */
60 /*    Application Code                                                    */
61 /*                                                                        */
62 /*  RELEASE HISTORY                                                       */
63 /*                                                                        */
64 /*    DATE              NAME                      DESCRIPTION             */
65 /*                                                                        */
66 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
67 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
68 /*                                            resulting in version 6.1    */
69 /*                                                                        */
70 /**************************************************************************/
_tx_trace_disable(VOID)71 UINT  _tx_trace_disable(VOID)
72 {
73 
74 #ifdef TX_ENABLE_EVENT_TRACE
75 UINT     status;
76 
77 
78     /* Determine if trace is already disabled.  */
79     if (_tx_trace_buffer_current_ptr == TX_NULL)
80     {
81 
82         /* Yes, trace is already disabled.  */
83         status =  TX_NOT_DONE;
84     }
85     else
86     {
87 
88         /* Otherwise, simply clear the current pointer and registery start pointer to disable the trace.  */
89         _tx_trace_buffer_current_ptr =  TX_NULL;
90         _tx_trace_registry_start_ptr =  TX_NULL;
91 
92         /* Successful completion.  */
93         status =  TX_SUCCESS;
94     }
95 
96     /* Return completion status.  */
97     return(status);
98 
99 #else
100 
101     /* Trace not enabled, return an error.  */
102     return(TX_FEATURE_NOT_ENABLED);
103 #endif
104 }
105 
106