Lazuli
task.h
Go to the documentation of this file.
1 /*
2  * SPDX-License-Identifier: GPL-3.0-only
3  * This file is part of Lazuli.
4  */
5 
14 #ifndef LAZULI_SYS_TASK_H
15 #define LAZULI_SYS_TASK_H
16 
17 #include <stdint.h>
18 
19 #include <Lazuli/common.h>
20 #include <Lazuli/lazuli.h>
21 #include <Lazuli/list.h>
22 
24 
36 
40 #define NO_MESSAGE ((lz_task_to_scheduler_message_t)0U)
41 
46 #define WAIT_ACTIVATION ((lz_task_to_scheduler_message_t)1U)
47 
52 #define WAIT_INTERRUPT ((lz_task_to_scheduler_message_t)2U)
53 
57 #define TERMINATE_TASK ((lz_task_to_scheduler_message_t)3U)
58 
63 #define WAIT_MUTEX ((lz_task_to_scheduler_message_t)4U)
64 
71 #define WAIT_SOFTWARE_TIMER ((lz_task_to_scheduler_message_t)5U)
72 
76 typedef struct {
82  const char *name;
83 
89  void (*entryPoint)(void);
90 
102  void *stackOrigin;
103 
109  size_t stackSize;
110 
115 
119  enum Lz_SchedulingPolicy schedulingPolicy;
120 
125 
131 
138 
144 
150 
155 
160 
175 
182 }Task;
183 
188 typedef void (*FuncVoidVoid)(void);
189 
203 typedef struct {
205  volatile uint8_t sreg;
206 
208  volatile uint8_t r0;
209 
211  volatile uint8_t r1;
212 
214  volatile uint8_t r2;
215 
217  volatile uint8_t r3;
218 
220  volatile uint8_t r4;
221 
223  volatile uint8_t r5;
224 
226  volatile uint8_t r6;
227 
229  volatile uint8_t r7;
230 
232  volatile uint8_t r8;
233 
235  volatile uint8_t r9;
236 
238  volatile uint8_t r10;
239 
241  volatile uint8_t r11;
242 
244  volatile uint8_t r12;
245 
247  volatile uint8_t r13;
248 
250  volatile uint8_t r14;
251 
253  volatile uint8_t r15;
254 
256  volatile uint8_t r16;
257 
259  volatile uint8_t r17;
260 
262  volatile uint8_t r18;
263 
265  volatile uint8_t r19;
266 
268  volatile uint8_t r20;
269 
271  volatile uint8_t r21;
272 
274  volatile uint8_t r22;
275 
277  volatile uint8_t r23;
278 
280  volatile uint8_t r24;
281 
283  volatile uint8_t r25;
284 
286  volatile uint8_t r26;
287 
289  volatile uint8_t r27;
290 
292  volatile uint8_t r28;
293 
295  volatile uint8_t r29;
296 
298  volatile uint8_t r30;
299 
301  volatile uint8_t r31;
302 
304  volatile FuncVoidVoid pc;
305 
314 
324 void
325 Task_Abort(void);
326 
328 
329 #endif /* LAZULI_SYS_TASK_H */
volatile uint8_t r13
Register 13.
Definition: task.h:247
volatile uint8_t r23
Register 23.
Definition: task.h:277
volatile uint8_t r25
Register 25.
Definition: task.h:283
size_t stackSize
The stack size of the task.
Definition: task.h:109
volatile uint8_t r27
Register 27.
Definition: task.h:289
volatile uint8_t r29
Register 29.
Definition: task.h:295
volatile uint8_t r24
Register 24.
Definition: task.h:280
volatile uint8_t r22
Register 22.
Definition: task.h:274
volatile FuncVoidVoid pc
Program counter for the task.
Definition: task.h:304
volatile uint8_t r10
Register 10.
Definition: task.h:238
void Task_Abort(void)
Abort the calling task.
#define _EXTERN_C_DECL_BEGIN
Open C++ header file declarations.
Definition: common.h:37
Lz_LinkedListElement stateQueue
The scheduling queue on which the task is stored.
Definition: task.h:124
void * stackPointer
The saved stack pointer of the task.
Definition: task.h:114
volatile uint8_t r7
Register 7.
Definition: task.h:229
volatile uint8_t r3
Register 3.
Definition: task.h:217
volatile uint8_t r31
Register 31.
Definition: task.h:301
Lz_SchedulingPolicy
Defines the possible scheduling policies for a Lazuli user task.
Definition: lazuli.h:44
volatile uint8_t r18
Register 18.
Definition: task.h:262
const char * name
The name of the task.
Definition: task.h:82
void(* FuncVoidVoid)(void)
This type definition is needed to exlude confusion with the &#39;volatile&#39; type qualifier used in the str...
Definition: task.h:188
volatile uint8_t r26
Register 26.
Definition: task.h:286
volatile uint8_t r30
Register 30.
Definition: task.h:298
lz_task_priority_t priority
The task priority.
Definition: task.h:154
lz_u_resolution_unit_t completion
The completion time (C) of the task (worst case execution time), expressed as an integer number of ti...
Definition: task.h:137
lz_u_resolution_unit_t timeUntilCompletion
The number of time units until the task will complete its execution.
Definition: task.h:143
The public API of the Lazuli kernel.
volatile uint8_t r11
Register 11.
Definition: task.h:241
volatile uint8_t r12
Register 12.
Definition: task.h:244
volatile uint8_t r2
Register 2.
Definition: task.h:214
volatile lz_task_to_scheduler_message_t taskToSchedulerMessage
The message the task has to pass to the scheduler for the next scheduling operation (i...
Definition: task.h:174
volatile uint8_t r14
Register 14.
Definition: task.h:250
volatile uint8_t r17
Register 17.
Definition: task.h:259
uint16_t lz_u_resolution_unit_t
Represents the type used for the system clock resolution unit, as an unsigned integer.
Definition: lazuli.h:36
lz_u_resolution_unit_t timeUntilTimerExpiration
The number of time units until the software timer expires for the task.
Definition: task.h:159
Doubly linked lists interface.
void * stackOrigin
The bottom of the allocated stack for the task.
Definition: task.h:102
volatile uint8_t r15
Register 15.
Definition: task.h:253
volatile uint8_t r6
Register 6.
Definition: task.h:226
volatile uint8_t r0
Register 0.
Definition: task.h:208
unsigned char uint8_t
Represents a unsigned integer type with width of exactly 8 bits.
Definition: stdint.h:89
volatile uint8_t r4
Register 4.
Definition: task.h:220
volatile uint8_t r1
Register 1.
Definition: task.h:211
volatile uint8_t sreg
State register.
Definition: task.h:205
volatile uint8_t r5
Register 5.
Definition: task.h:223
volatile uint8_t r9
Register 9.
Definition: task.h:235
volatile FuncVoidVoid terminationCallback
Callback to the scheduler to manage task termination.
Definition: task.h:312
volatile uint8_t r19
Register 19.
Definition: task.h:265
lz_u_resolution_unit_t timeUntilActivation
The number of time units until the task will be activated.
Definition: task.h:149
Basic type definitions and useful macros.
int8_t lz_task_priority_t
Represents the priority of a task, as a signed integer.
Definition: lazuli.h:30
Represents an element of a doubly linked list.
Definition: list.h:25
#define _EXTERN_C_DECL_END
Close C++ header file declarations.
Definition: common.h:42
Represents a task.
Definition: task.h:76
u_read_write_atomic_t lz_task_to_scheduler_message_t
Defines the type used to contain a message that a Task can pass to the scheduler after its time slice...
Definition: task.h:35
uint8_t u_read_write_atomic_t
Represents an unsigned integer that can be read and written atomically.
Definition: common.h:107
void * taskToSchedulerMessageParameter
A parameter that can accompany a taskToSchedulerMessage.
Definition: task.h:181
volatile uint8_t r16
Register 16.
Definition: task.h:256
volatile uint8_t r20
Register 20.
Definition: task.h:268
volatile uint8_t r28
Register 28.
Definition: task.h:292
volatile uint8_t r21
Register 21.
Definition: task.h:271
volatile uint8_t r8
Register 8.
Definition: task.h:232
lz_u_resolution_unit_t period
The period (T) of the task, expressed as an integer number of time units.
Definition: task.h:130
Represents the layout of the stack when saving the context of a task.
Definition: task.h:203