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_object_unregister                         PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    William E. Lamie, Microsoft Corporation                             */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function unregisters a ThreadX system object from the trace    */
45 /*    registry area.                                                      */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    object_pointer                        Address of system object      */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    None                                                                */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    None                                                                */
58 /*                                                                        */
59 /*  CALLED BY                                                             */
60 /*                                                                        */
61 /*    Application Code                                                    */
62 /*                                                                        */
63 /*  RELEASE HISTORY                                                       */
64 /*                                                                        */
65 /*    DATE              NAME                      DESCRIPTION             */
66 /*                                                                        */
67 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
68 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
69 /*                                            resulting in version 6.1    */
70 /*                                                                        */
71 /**************************************************************************/
_tx_trace_object_unregister(VOID * object_ptr)72 VOID  _tx_trace_object_unregister(VOID *object_ptr)
73 {
74 
75 #ifdef TX_ENABLE_EVENT_TRACE
76 
77 UINT                            i, entries;
78 UCHAR                           *work_ptr;
79 TX_TRACE_OBJECT_ENTRY           *entry_ptr;
80 
81 
82     /* Determine if the registry area is setup.  */
83     if (_tx_trace_registry_start_ptr != TX_NULL)
84     {
85 
86         /* Registry is setup, proceed.  */
87 
88         /* Pickup the total entries.  */
89         entries =  _tx_trace_total_registry_entries;
90 
91         /* Loop to find available entry.  */
92         for (i = ((ULONG) 0); i < entries; i++)
93         {
94 
95             /* Setup the registry entry pointer.  */
96             work_ptr =   TX_OBJECT_TO_UCHAR_POINTER_CONVERT(_tx_trace_registry_start_ptr);
97             work_ptr =   TX_UCHAR_POINTER_ADD(work_ptr, ((sizeof(TX_TRACE_OBJECT_ENTRY))*i));
98             entry_ptr =  TX_UCHAR_TO_OBJECT_POINTER_CONVERT(work_ptr);
99 
100             /* Determine if this entry matches the object pointer... */
101             if (entry_ptr -> tx_trace_object_entry_thread_pointer == TX_POINTER_TO_ULONG_CONVERT(object_ptr))
102             {
103 
104                 /* Mark this entry as available, but leave the other information so that old trace entries can
105                    still find it - if necessary!  */
106                 entry_ptr -> tx_trace_object_entry_available =  ((UCHAR) TX_TRUE);
107 
108                 /* Increment the number of available registry entries.  */
109                 _tx_trace_available_registry_entries++;
110 
111                 /* Adjust the search index to this position.  */
112                 _tx_trace_registry_search_start =  i;
113 
114                 break;
115             }
116         }
117     }
118 #else
119 
120 TX_INTERRUPT_SAVE_AREA
121 
122 
123     /* Access input arguments just for the sake of lint, MISRA, etc.  */
124     if (object_ptr != TX_NULL)
125     {
126 
127         /* NOP code.  */
128         TX_DISABLE
129         TX_RESTORE
130     }
131 #endif
132 }
133 
134