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 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _ux_utility_mutex_on PORTABLE C */
36 /* 6.1.11 */
37 /* AUTHOR */
38 /* */
39 /* Chaoqiong Xiao, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function gets system protection. */
44 /* */
45 /* INPUT */
46 /* */
47 /* Mutex */
48 /* */
49 /* OUTPUT */
50 /* */
51 /* None */
52 /* */
53 /* CALLS */
54 /* */
55 /* tx_mutex_get ThreadX mutex get */
56 /* */
57 /* CALLED BY */
58 /* */
59 /* USBX Components */
60 /* */
61 /* RELEASE HISTORY */
62 /* */
63 /* DATE NAME DESCRIPTION */
64 /* */
65 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
66 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
67 /* used UX prefix to refer to */
68 /* TX symbols instead of using */
69 /* them directly, */
70 /* resulting in version 6.1 */
71 /* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
72 /* off in standalone build, */
73 /* resulting in version 6.1.11 */
74 /* */
75 /**************************************************************************/
_ux_utility_mutex_on(UX_MUTEX * mutex)76 VOID _ux_utility_mutex_on(UX_MUTEX *mutex)
77 {
78
79 UINT status;
80
81 /* Call ThreadX to get system mutex. */
82 status = tx_mutex_get(mutex, TX_WAIT_FOREVER);
83
84 /* Check for status. */
85 if (status != UX_SUCCESS)
86 {
87
88 /* Error trap. */
89 _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_UTILITY, status);
90 }
91
92 /* Return to caller. */
93 return;
94 }
95 #endif
96