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 /** USBX Component */
16 /** */
17 /** Utility */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22
23 /* Include necessary system files. */
24
25 #define UX_SOURCE_CODE
26
27 #include "ux_api.h"
28
29
30 #if !defined(UX_STANDALONE)
31 #include "tx_thread.h"
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _ux_utility_thread_identify PORTABLE C */
37 /* 6.1.11 */
38 /* AUTHOR */
39 /* */
40 /* Chaoqiong Xiao, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function return a pointer to the calling thread. */
45 /* */
46 /* INPUT */
47 /* */
48 /* None */
49 /* */
50 /* OUTPUT */
51 /* */
52 /* Completion Status */
53 /* */
54 /* CALLS */
55 /* */
56 /* tx_thread_identify ThreadX identify function */
57 /* */
58 /* CALLED BY */
59 /* */
60 /* USBX Components */
61 /* */
62 /* RELEASE HISTORY */
63 /* */
64 /* DATE NAME DESCRIPTION */
65 /* */
66 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
67 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
68 /* used UX prefix to refer to */
69 /* TX symbols instead of using */
70 /* them directly, */
71 /* resulting in version 6.1 */
72 /* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
73 /* off in standalone build, */
74 /* resulting in version 6.1.11 */
75 /* */
76 /**************************************************************************/
_ux_utility_thread_identify(VOID)77 UX_THREAD *_ux_utility_thread_identify(VOID)
78 {
79
80
81 /* If we're under interrupt, the thread returned by tx_thread_identify
82 is the thread running prior to the ISR. Instead, we set it to null. */
83 return(UX_THREAD_GET_SYSTEM_STATE() ? UX_NULL : tx_thread_identify());
84 }
85 #endif
86