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