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 /** Thread */
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 #include "tx_thread.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _tx_thread_entry_exit_notify PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* William E. Lamie, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function registers an application entry/exit notification */
46 /* callback routine for the application. Once registered, the callback */
47 /* routine is called when the thread is initially entered and called */
48 /* again when the thread completes or is terminated. */
49 /* */
50 /* INPUT */
51 /* */
52 /* thread_ptr Pointer to thread */
53 /* thread_entry_exit_notify Pointer to notify callback */
54 /* function, TX_NULL to disable*/
55 /* */
56 /* OUTPUT */
57 /* */
58 /* status Service return status */
59 /* */
60 /* CALLS */
61 /* */
62 /* None */
63 /* */
64 /* CALLED BY */
65 /* */
66 /* Application Code */
67 /* */
68 /* RELEASE HISTORY */
69 /* */
70 /* DATE NAME DESCRIPTION */
71 /* */
72 /* 05-19-2020 William E. Lamie Initial Version 6.0 */
73 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
74 /* resulting in version 6.1 */
75 /* */
76 /**************************************************************************/
_tx_thread_entry_exit_notify(TX_THREAD * thread_ptr,VOID (* thread_entry_exit_notify)(TX_THREAD * notify_thread_ptr,UINT id))77 UINT _tx_thread_entry_exit_notify(TX_THREAD *thread_ptr, VOID (*thread_entry_exit_notify)(TX_THREAD *notify_thread_ptr, UINT id))
78 {
79
80 #ifdef TX_DISABLE_NOTIFY_CALLBACKS
81
82 TX_THREAD_NOT_USED(thread_ptr);
83 TX_THREAD_ENTRY_EXIT_NOTIFY_NOT_USED(thread_entry_exit_notify);
84
85 /* Feature is not enabled, return error. */
86 return(TX_FEATURE_NOT_ENABLED);
87 #else
88
89 TX_INTERRUPT_SAVE_AREA
90
91
92 /* Disable interrupts. */
93 TX_DISABLE
94
95 /* Make entry in event log. */
96 TX_TRACE_IN_LINE_INSERT(TX_TRACE_THREAD_ENTRY_EXIT_NOTIFY, thread_ptr, thread_ptr -> tx_thread_state, 0, 0, TX_TRACE_THREAD_EVENTS)
97
98 /* Make entry in event log. */
99 TX_EL_THREAD_ENTRY_EXIT_NOTIFY_INSERT
100
101 /* Setup thread entry/exit notification callback function. */
102 thread_ptr -> tx_thread_entry_exit_notify = thread_entry_exit_notify;
103
104 /* Restore interrupts. */
105 TX_RESTORE
106
107 /* Return success to caller. */
108 return(TX_SUCCESS);
109 #endif
110 }
111
112