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 /**   Event Flags                                                         */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 
24 /**************************************************************************/
25 /*                                                                        */
26 /*  COMPONENT DEFINITION                                   RELEASE        */
27 /*                                                                        */
28 /*    tx_event_flags.h                                    PORTABLE C      */
29 /*                                                           6.1          */
30 /*  AUTHOR                                                                */
31 /*                                                                        */
32 /*    William E. Lamie, Microsoft Corporation                             */
33 /*                                                                        */
34 /*  DESCRIPTION                                                           */
35 /*                                                                        */
36 /*    This file defines the ThreadX event flags management component,     */
37 /*    including all data types and external references.  It is assumed    */
38 /*    that tx_api.h and tx_port.h have already been included.             */
39 /*                                                                        */
40 /*  RELEASE HISTORY                                                       */
41 /*                                                                        */
42 /*    DATE              NAME                      DESCRIPTION             */
43 /*                                                                        */
44 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
45 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
46 /*                                            resulting in version 6.1    */
47 /*                                                                        */
48 /**************************************************************************/
49 
50 #ifndef TX_EVENT_FLAGS_H
51 #define TX_EVENT_FLAGS_H
52 
53 
54 /* Define event flags control specific data definitions.  */
55 
56 #define TX_EVENT_FLAGS_ID                       ((ULONG) 0x4456444E)
57 #define TX_EVENT_FLAGS_AND_MASK                 ((UINT) 0x2)
58 #define TX_EVENT_FLAGS_CLEAR_MASK               ((UINT) 0x1)
59 
60 
61 /* Determine if in-line component initialization is supported by the
62    caller.  */
63 #ifdef TX_INVOKE_INLINE_INITIALIZATION
64 
65 /* Yes, in-line initialization is supported, remap the event flag initialization
66    function.  */
67 
68 #ifndef TX_EVENT_FLAGS_ENABLE_PERFORMANCE_INFO
69 #define _tx_event_flags_initialize() \
70                     _tx_event_flags_created_ptr =                   TX_NULL;     \
71                     _tx_event_flags_created_count =                 TX_EMPTY
72 #else
73 #define _tx_event_flags_initialize() \
74                     _tx_event_flags_created_ptr =                   TX_NULL;     \
75                     _tx_event_flags_created_count =                 TX_EMPTY;    \
76                     _tx_event_flags_performance_set_count =         ((ULONG) 0); \
77                     _tx_event_flags_performance_get_count =         ((ULONG) 0); \
78                     _tx_event_flags_performance_suspension_count =  ((ULONG) 0); \
79                     _tx_event_flags_performance_timeout_count =     ((ULONG) 0)
80 #endif
81 #define TX_EVENT_FLAGS_INIT
82 #else
83 
84 /* No in-line initialization is supported, use standard function call.  */
85 VOID        _tx_event_flags_initialize(VOID);
86 #endif
87 
88 
89 /* Define internal event flags management function prototypes.  */
90 
91 VOID        _tx_event_flags_cleanup(TX_THREAD *thread_ptr, ULONG suspension_sequence);
92 
93 
94 /* Event flags management component data declarations follow.  */
95 
96 /* Determine if the initialization function of this component is including
97    this file.  If so, make the data definitions really happen.  Otherwise,
98    make them extern so other functions in the component can access them.  */
99 
100 #ifdef TX_EVENT_FLAGS_INIT
101 #define EVENT_FLAGS_DECLARE
102 #else
103 #define EVENT_FLAGS_DECLARE extern
104 #endif
105 
106 
107 /* Define the head pointer of the created event flags list.  */
108 
109 EVENT_FLAGS_DECLARE  TX_EVENT_FLAGS_GROUP * _tx_event_flags_created_ptr;
110 
111 
112 /* Define the variable that holds the number of created event flag groups. */
113 
114 EVENT_FLAGS_DECLARE  ULONG                  _tx_event_flags_created_count;
115 
116 
117 #ifdef TX_EVENT_FLAGS_ENABLE_PERFORMANCE_INFO
118 
119 /* Define the total number of event flag sets.  */
120 
121 EVENT_FLAGS_DECLARE  ULONG                  _tx_event_flags_performance_set_count;
122 
123 
124 /* Define the total number of event flag gets.  */
125 
126 EVENT_FLAGS_DECLARE  ULONG                  _tx_event_flags_performance_get_count;
127 
128 
129 /* Define the total number of event flag suspensions.  */
130 
131 EVENT_FLAGS_DECLARE  ULONG                  _tx_event_flags_performance_suspension_count;
132 
133 
134 /* Define the total number of event flag timeouts.  */
135 
136 EVENT_FLAGS_DECLARE  ULONG                  _tx_event_flags_performance_timeout_count;
137 
138 
139 #endif
140 
141 /* Define default post event flag group delete macro to whitespace, if it hasn't been defined previously (typically in tx_port.h).  */
142 
143 #ifndef TX_EVENT_FLAGS_GROUP_DELETE_PORT_COMPLETION
144 #define TX_EVENT_FLAGS_GROUP_DELETE_PORT_COMPLETION(g)
145 #endif
146 
147 
148 #endif
149 
150