-
Notifications
You must be signed in to change notification settings - Fork 924
Expand file tree
/
Copy pathtx_event_flags_create.c
More file actions
142 lines (114 loc) · 6.83 KB
/
tx_event_flags_create.c
File metadata and controls
142 lines (114 loc) · 6.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** ThreadX Component */
/** */
/** Event Flags */
/** */
/**************************************************************************/
/**************************************************************************/
#define TX_SOURCE_CODE
/* Include necessary system files. */
#include "tx_api.h"
#include "tx_trace.h"
#include "tx_event_flags.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _tx_event_flags_create PORTABLE C */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function creates a group of 32 event flags. All the flags are */
/* initially in a cleared state. */
/* */
/* INPUT */
/* */
/* group_ptr Pointer to event flags group */
/* control block */
/* name_ptr Pointer to event flags name */
/* */
/* OUTPUT */
/* */
/* TX_SUCCESS Successful completion status */
/* */
/* CALLS */
/* */
/* None */
/* */
/* CALLED BY */
/* */
/* Application Code */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
/* */
/**************************************************************************/
UINT _tx_event_flags_create(TX_EVENT_FLAGS_GROUP *group_ptr, const CHAR *name_ptr)
{
TX_INTERRUPT_SAVE_AREA
TX_EVENT_FLAGS_GROUP *next_group;
TX_EVENT_FLAGS_GROUP *previous_group;
/* Initialize event flags control block to all zeros. */
TX_MEMSET(group_ptr, 0, (sizeof(TX_EVENT_FLAGS_GROUP)));
/* Setup the basic event flags group fields. */
group_ptr -> tx_event_flags_group_name = name_ptr;
/* Disable interrupts to put the event flags group on the created list. */
TX_DISABLE
/* Setup the event flags ID to make it valid. */
group_ptr -> tx_event_flags_group_id = TX_EVENT_FLAGS_ID;
/* Place the group on the list of created event flag groups. First,
check for an empty list. */
if (_tx_event_flags_created_count == TX_EMPTY)
{
/* The created event flags list is empty. Add event flag group to empty list. */
_tx_event_flags_created_ptr = group_ptr;
group_ptr -> tx_event_flags_group_created_next = group_ptr;
group_ptr -> tx_event_flags_group_created_previous = group_ptr;
}
else
{
/* This list is not NULL, add to the end of the list. */
next_group = _tx_event_flags_created_ptr;
previous_group = next_group -> tx_event_flags_group_created_previous;
/* Place the new event flag group in the list. */
next_group -> tx_event_flags_group_created_previous = group_ptr;
previous_group -> tx_event_flags_group_created_next = group_ptr;
/* Setup this group's created links. */
group_ptr -> tx_event_flags_group_created_previous = previous_group;
group_ptr -> tx_event_flags_group_created_next = next_group;
}
/* Increment the number of created event flag groups. */
_tx_event_flags_created_count++;
/* Optional event flag group create extended processing. */
TX_EVENT_FLAGS_GROUP_CREATE_EXTENSION(group_ptr)
/* If trace is enabled, register this object. */
TX_TRACE_OBJECT_REGISTER(TX_TRACE_OBJECT_TYPE_EVENT_FLAGS, group_ptr, name_ptr, 0, 0)
/* If trace is enabled, insert this event into the trace buffer. */
TX_TRACE_IN_LINE_INSERT(TX_TRACE_EVENT_FLAGS_CREATE, group_ptr, TX_POINTER_TO_ULONG_CONVERT(&next_group), 0, 0, TX_TRACE_EVENT_FLAGS_EVENTS)
/* Log this kernel call. */
TX_EL_EVENT_FLAGS_CREATE_INSERT
/* Restore interrupts. */
TX_RESTORE
/* Return TX_SUCCESS. */
return(TX_SUCCESS);
}