CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
Loading...
Searching...
No Matches
FreeRTOS.h
Go to the documentation of this file.
1#pragma once
2#include "cdefs.h"
3#include <assert.h>
4#include <stdint.h>
5#include <tick_macros.h>
6#include <timeout.h>
7
8/**
9 * \file
10 * \brief FreeRTOS porting layer.
11 *
12 * This file defines the top-level include for FreeRTOS. FreeRTOS supports
13 * including either this file, or the individual headers that this includes.
14 * The individual API families (event groups, queues, streams) are exposed in
15 * headers matching their FreeRTOS counterparts.
16 */
17
18#define pdMS_TO_TICKS(x) MS_TO_TICKS((x))
19
20/**
21 * Guard macro. Checked in other headers, CHERIoT RTOS prefers `#pragma once`
22 * for include guards and avoids header dependency orders.
23 */
24#define INC_FREERTOS_H
25
26/**
27 * Macro used to define a privileged function. This concept does not map to
28 * CHERIoT RTOS, where no compartment is privileged, and so is discarded.
29 */
30#define PRIVILEGED_FUNCTION
31
32/**
33 * Value used to indicate a little-endian system. `pdFREERTOS_LITTLE_ENDIAN`
34 * and `pdFREERTOS_BIG_ENDIAN` form an enumeration but are exposed in FreeRTOS
35 * as macros with integer values.
36 */
37#define pdFREERTOS_LITTLE_ENDIAN 0
38/**
39 * Value used to indicate a big-endian system. `pdFREERTOS_LITTLE_ENDIAN` and
40 * `pdFREERTOS_BIG_ENDIAN` form an enumeration but are exposed in FreeRTOS as
41 * macros with integer values.
42 */
43#define pdFREERTOS_BIG_ENDIAN 1
44
45/**
46 * FreeRTOS definition of false.
47 */
48#define pdFALSE ((BaseType_t)0)
49/**
50 * FreeRTOS definition of true.
51 */
52#define pdTRUE ((BaseType_t)1)
53
54/**
55 * FreeRTOS definition indicating failure.
56 */
57#define pdFAIL pdFALSE
58/**
59 * FreeRTOS definition indicating success.
60 */
61#define pdPASS pdTRUE
62
63#ifdef NDEBUG
64/**
65 * FreeRTOS assertion macro, which behaves identically to the standard
66 * `assert()`.
67 */
68# define configASSERT(x) \
69 do \
70 { \
71 } while (0)
72#else
73# define configASSERT(x) \
74 ((x) ? ((void)0) \
75 : (printf("Assertion failure in %s() %s:%d: %s\n", \
76 __func__, \
77 __FILE_NAME__, \
78 __LINE__, \
79 #x), \
80 panic(), \
81 (void)0))
82#endif
83
84#define configTICK_RATE_HZ TICK_RATE_HZ
85#define portMAX_DELAY UINT32_MAX
86#define portTICK_PERIOD_MS MS_PER_TICK
87
88#ifndef traceENTER_vListInitialise
89# define traceENTER_vListInitialise(...) \
90 do \
91 { \
92 } while (0)
93#endif
94
95#ifndef traceRETURN_vListInitialise
96# define traceRETURN_vListInitialise(...) \
97 do \
98 { \
99 } while (0)
100#endif
101
102#ifndef traceENTER_vListInitialiseItem
103# define traceENTER_vListInitialiseItem(...) \
104 do \
105 { \
106 } while (0)
107#endif
108
109#ifndef traceRETURN_vListInitialiseItem
110# define traceRETURN_vListInitialiseItem(...) \
111 do \
112 { \
113 } while (0)
114#endif
115
116#ifndef traceENTER_vListInsertEnd
117# define traceENTER_vListInsertEnd(...) \
118 do \
119 { \
120 } while (0)
121#endif
122
123#ifndef traceRETURN_vListInsertEnd
124# define traceRETURN_vListInsertEnd(...) \
125 do \
126 { \
127 } while (0)
128#endif
129
130#ifndef mtCOVERAGE_TEST_DELAY
131# define mtCOVERAGE_TEST_DELAY() \
132 do \
133 { \
134 } while (0)
135#endif
136
137#ifndef mtCOVERAGE_TEST_MARKER
138# define mtCOVERAGE_TEST_MARKER() \
139 do \
140 { \
141 } while (0)
142#endif
143
144#ifndef traceENTER_vListInsert
145# define traceENTER_vListInsert(...) \
146 do \
147 { \
148 } while (0)
149#endif
150
151#ifndef traceRETURN_vListInsert
152# define traceRETURN_vListInsert(...) \
153 do \
154 { \
155 } while (0)
156#endif
157
158#ifndef traceENTER_uxListRemove
159# define traceENTER_uxListRemove(...) \
160 do \
161 { \
162 } while (0)
163#endif
164
165#ifndef traceRETURN_uxListRemove
166# define traceRETURN_uxListRemove(...) \
167 do \
168 { \
169 } while (0)
170#endif
171
172/**
173 * FreeRTOS type for durations expressed in ticks.
174 */
176/**
177 * FreeRTOS default signed integer type.
178 */
179typedef int32_t BaseType_t;
180/**
181 * FreeRTOS default unsigned integer type.
182 */
183typedef uint32_t UBaseType_t;
184/**
185 * FreeRTOS type representing a task handle, mapped to a thread ID in CHERIoT
186 * RTOS.
187 */
188typedef uint16_t TaskHandle_t;
189/**
190 * FreeRTOS type for a duration expressed in large numbers of ticks.
191 */
192typedef uint64_t TimeOut_t;
193
194// Some things include this file expecting to get other FreeRTOS headers,
195// others include those files directly.
196#include "event_groups.h"
197#include "queue.h"
198#include "stream_buffer.h"
199#include "task.h"
200
201// Some things expect this to include list.h. This is an incredibly complex
202// data structure that it is not worth reimplementing, so include it if it
203// exists and allow components to copy it from FreeRTOS if they want it (it's
204// MIT licensed).
205#if __has_include(<list.h>)
206# include <list.h>
207#endif
FreeRTOS queue compatibility APIs.
int32_t BaseType_t
FreeRTOS default signed integer type.
Definition FreeRTOS.h:179
Ticks TickType_t
FreeRTOS type for durations expressed in ticks.
Definition FreeRTOS.h:175
uint32_t UBaseType_t
FreeRTOS default unsigned integer type.
Definition FreeRTOS.h:183
uint16_t TaskHandle_t
FreeRTOS type representing a task handle, mapped to a thread ID in CHERIoT RTOS.
Definition FreeRTOS.h:188
uint64_t TimeOut_t
FreeRTOS type for a duration expressed in large numbers of ticks.
Definition FreeRTOS.h:192
FreeRTOS event-group compatibility APIs.
FreeRTOS stream compatibility APIs.
Minimal FreeRTOS task compatibility APIs.
This file contains the types used for timeouts across scheduler APIs.
uint32_t Ticks
Quantity used for measuring time for timeouts.
Definition timeout.h:19