QP/C
7.2.2
Real-Time Embedded Framework
Loading...
Searching...
No Matches
qf_port.h
Go to the documentation of this file.
1
/*============================================================================
2
* QP/C Real-Time Embedded Framework
3
* Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
4
*
5
* SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
6
*
7
* This software is dual-licensed under the terms of the open source GNU
8
* General Public License version 3 (or any later version), or alternatively,
9
* under the terms of one of the closed source Quantum Leaps commercial
10
* licenses.
11
*
12
* The terms of the open source GNU General Public License version 3
13
* can be found at: <www.gnu.org/licenses/gpl-3.0>
14
*
15
* The terms of the closed source Quantum Leaps commercial licenses
16
* can be found at: <www.state-machine.com/licensing>
17
*
18
* Redistributions in source code must retain this top-level comment block.
19
* Plagiarizing this software to sidestep the license obligations is illegal.
20
*
21
* Contact information:
22
* <www.state-machine.com>
23
* <info@state-machine.com>
24
============================================================================*/
25
/*!
26
* @date Last updated on: 2022-11-23
27
* @version Last updated for: @ref qpc_7_2_0
28
*
29
* @file
30
* @brief QF/C sample port with all configurable options
31
*/
32
#ifndef QF_PORT_H_
33
#define QF_PORT_H_
34
35
/*! This macro defines the type of the thread handle used for AOs */
36
#define QF_THREAD_TYPE void*
37
38
/*! This macro defines the type of the event-queue used for AOs */
39
#define QF_EQUEUE_TYPE QEQueue
40
41
/*! This macro defines the type of the OS-Object used for blocking
42
* the native ::QEQueue when the queue is empty
43
*
44
* @description
45
* This macro is used when ::QEQueue is used as the event-queue for AOs
46
* but also the AO queue must *block* when the queue is empty.
47
* In that case, #QF_OS_OBJECT_TYPE specifies the blocking mechanism.
48
* For example, in the POSIX port, the blocking mechanism is a condition
49
* variable.
50
*/
51
#define QF_OS_OBJECT_TYPE pthread_cond_t
52
53
/*! This macro defines the type of the event pool used in the port.
54
*
55
* @description
56
* This is a specific implementation for the QK-port of QF.
57
* In other QF ports you need to define the macro appropriately for
58
* the underlying kernel/OS you're using.
59
*/
60
#define QF_EPOOL_TYPE_ QMPool
61
62
/*! The maximum number of active objects in the application.
63
*
64
* @description
65
* This macro *must* be defined in the `qf_port.h` header file and should be
66
* in range of 1U..64U, inclusive. The value of this macro determines the
67
* maximum priority level of an active object in the system. Not all priority
68
* levels must be used, but the maximum priority cannot exceed `QF_MAX_ACTIVE`.
69
* Defining the value below the maximum limit of 64 saves some memory (RAM).
70
*/
71
#define QF_MAX_ACTIVE 64U
72
73
/*! The maximum number of clock tick rates in the application.
74
*
75
* @description
76
* This macro can be defined in the `qf_port.h` header file and should be
77
* in range of 1U..15U, inclusive. The value of this macro determines the
78
* maximum number of clock tick rates for time events (::QTimeEvt).
79
*
80
* If the macro is not defined, the `qf.h` header file sets the default
81
* value to 1U.
82
*/
83
#define QF_MAX_TICK_RATE 1U
84
85
/*! The size (in bytes) of the time event-counter representation
86
* in the ::QTimeEvt struct. Valid values: 1U, 2U, or 4U; default 2U.
87
*
88
* @description
89
* This macro can be defined in the `qf_port.h` header file to configure the
90
* internal tick counters of Time Events. If the macro is not defined, the
91
* default of 4 bytes will be chosen in `qf.h`. The valid #QF_TIMEEVT_CTR_SIZE
92
* values of 1, 2, or 4, correspond to tick counters of uint8_t, uint16_t,
93
* and uint32_t, respectively. The tick counter representation determines the
94
* dynamic range of time delays that a Time Event can handle.
95
* @sa ::QTimeEvt
96
*/
97
#define QF_TIMEEVT_CTR_SIZE 4U
98
99
/*! The maximum number of event pools in the application.
100
*
101
* @description
102
* This macro can be defined in the `qf_port.h` header file and should be
103
* in range of 1U..255U, inclusive. The value of this macro determines the
104
* maximum number of event pools in the system. Not all event pools must be
105
* actually used, but the maximum number of pools cannot exceed `QF_MAX_EPOOL`.
106
*
107
* If the macro is not defined, the `qf.h` header file sets the default
108
* value to 3U. Defining `QF_MAX_EPOOL` below the maximum limit of 255
109
* saves some memory (RAM).
110
*/
111
#define QF_MAX_EPOOL 3U
112
113
/*! The size (in bytes) of the event-size representation in the QF.
114
* Valid values: 1U, 2U, or 4U; default 2U
115
*
116
* @description
117
* This macro can be defined in the QF ports to configure the size
118
* of the event-size.
119
*/
120
#define QF_EVENT_SIZ_SIZE 2U
121
122
/*! The size (in bytes) of the ring-buffer counters used in the native QF
123
* event queue implementation. Valid values: 1U, 2U, or 4U; default 1U
124
*
125
* @description
126
* This macro can be defined in the `qf_port.h` header file to configure
127
* the ::QEQueueCtr type. If the macro is not defined, the default of 1 byte
128
* will be chosen in `qequeue.h`. The valid #QF_EQUEUE_CTR_SIZE values of
129
* 1U, 2U, or 4U, correspond to ::QEQueueCtr of uint8_t, uint16_t, and
130
* uint32_t, respectively. The::QEQueueCtr data type determines the dynamic
131
* range of numerical values of ring-buffer counters inside event queues, or,
132
* in other words, the maximum number of events that the native QF event
133
* queue can manage.
134
* @sa ::QEQueue
135
*/
136
#define QF_EQUEUE_CTR_SIZE 1U
137
138
/*! The size (in bytes) of the block-size representation in the native QF
139
* event pool. Valid values: 1U, 2U, or 4U; default #QF_EVENT_SIZ_SIZE.
140
*
141
* @description
142
* This macro can be defined in the `qf_port.h` header file to configure the
143
* ::QMPoolSize type. If the macro is not defined, the default of
144
* #QF_EVENT_SIZ_SIZE will be chosen in `qmpool.h`, because the memory pool
145
* is primarily used for implementing event pools.
146
*
147
* The valid #QF_MPOOL_SIZ_SIZE values of 1U, 2U, or 4U, correspond to
148
* ::QMPoolSize of uint8_t, uint16_t, and uint32_t, respectively. The
149
* ::QMPoolSize data type determines the dynamic range of block-sizes that
150
* the native ::QMPool can handle.
151
* @sa #QF_EVENT_SIZ_SIZE, ::QMPool
152
*/
153
#define QF_MPOOL_SIZ_SIZE 2U
154
155
/*! The size (in bytes) of the block-counter representation in the
156
* native QF event pool. Valid values: 1U, 2U, or 4U; default 2U.
157
*
158
* @description
159
* This macro can be defined in the `qf_port.h` header file to configure the
160
* ::QMPoolCtr type. If the macro is not defined, the default of 2 bytes will
161
* be chosen in `qmpool.h`. The valid #QF_MPOOL_CTR_SIZE values of 1U, 2U,
162
* or 4U, correspond to ::QMPoolSize of uint8_t, uint16_t, and uint32_t,
163
* respectively. The ::QMPoolCtr data type determines the dynamic range of
164
* block-counters that the native ::QMPool can handle, or, in other words,
165
* the maximum number of blocks that the native QF event pool can manage.
166
* @sa ::QMPool
167
*/
168
#define QF_MPOOL_CTR_SIZE 2U
169
170
/*! Define the interrupt disabling policy.
171
*
172
* @description
173
* This macro encapsulates platform-specific way of disabling interrupts
174
* from "C" for a given CPU and compiler.
175
*
176
* @note
177
* the #QF_INT_DISABLE macro should always be used in pair with the
178
* macro #QF_INT_ENABLE.
179
*/
180
#define QF_INT_DISABLE() intDisable()
181
182
/*! Define the interrupt enabling policy.
183
*
184
* @description
185
* This macro encapsulates platform-specific way of enabling interrupts
186
* from "C" for a given CPU and compiler.
187
*
188
* @note the #QF_INT_DISABLE macro should always be used in pair with the
189
* macro #QF_INT_ENABLE.
190
*/
191
#define QF_INT_ENABLE() intEnable()
192
193
/*! Define the type of the critical section status.
194
*
195
* @description
196
* Defining this macro configures the "saving and restoring critical section
197
* status" policy. Conversely, if this macro is not defined, the simple
198
* "unconditional critical section exit" is used.
199
*/
200
#define QF_CRIT_STAT_TYPE crit_stat_t
201
202
/*! Define the critical section entry policy.
203
*
204
* @description
205
* This macro enters a critical section (often by means of disabling
206
* interrupts). When the "saving and restoring critical section status"
207
* policy is used, the macro sets the @a status_ argument to the critical
208
* section status just before the entry. When the policy of "unconditional
209
* critical section exit" is used, the macro does not use the @a status_
210
* argument.
211
*
212
* @note the #QF_CRIT_ENTRY macro should always be used in pair with the
213
* macro #QF_CRIT_EXIT.
214
*/
215
#define QF_CRIT_ENTRY(stat_) ((stat_) = critEntry())
216
217
/*! Define the critical section exit policy.
218
*
219
* @description
220
* This macro enters a critical section (often by means of disabling
221
* interrupts). When the "saving and restoring critical section status"
222
* policy is used, the macro restores the critical section status from the
223
* @a status_ argument. When the policy of "unconditional critical section
224
* exit" is used, the macro does not use the @a status argument and
225
* exits the critical section unconditionally (often by means of enabling
226
* interrupts).
227
*
228
* @note the #QF_CRIT_ENTRY macro should always be used in pair with the
229
* macro #QF_CRIT_EXIT.
230
*/
231
#define QF_CRIT_EXIT(stat_) critExit(stat_)
232
233
/*! Define No-Operation (NOP) implementation to prevent joining
234
* adjacent critical sections.
235
*/
236
#define QF_CRIT_EXIT_NOP() __asm volatile ("isb"
)
237
238
/*! Define integer log-base-2 implementation strategy
239
*
240
* @description
241
* This macro can be defined in the `qf_port.h` header file to speed up
242
* the integer log-base-2 computation, which is used internally in QP to
243
* quickly find the highest-priority AO to execute or to find the
244
* highest-priority subscriber AO to a given event signal. The QF_LOG2()
245
* macro allows the port to specify a fast, hardware-supported computation
246
* (e.g., based on the count-leading-zeros instruction available in some CPUs).
247
*
248
* If this macros is NOT defined a default, reasonably fast algorithm is used.
249
*/
250
#define QF_LOG2(n_) ((uint_fast8_t)(32U - __builtin_clz((unsigned)(n_))))
251
252
#include "
qk_port.h
"
/* underlying real-time kernel port */
253
#include "
qf.h
"
/* QF platform-independent public interface */
254
255
#endif
/* QF_PORT_H */
qf.h
QF/C platform-independent public interface.
qk_port.h
QK/C sample port with all configurable options.
ports
sample
qf_port.h
© 2005-2023 Quantum Leaps
|
Using Online Help
|
QP/C 7.2.2
| Updated on Sat May 13 2023
© 2005-2023 Quantum Leaps
|
Using Online Help
|
QP/C 7.2.2
| Updated on Sat May 13 2023