armOS  0.1.0
Minimal ARM Operating System for the Raspberry Pi - Documentation generated for Pi 4.
scheduler.h
Go to the documentation of this file.
1 
9 #ifndef SCHEDULER_H
10 #define SCHEDULER_H
11 
12 #include <stdint.h>
13 
23 #ifdef AARCH_32
24 typedef struct {
25  uint32_t r0;
26  uint32_t r1;
27  uint32_t r2;
28  uint32_t r3;
29  uint32_t r4;
30  uint32_t r5;
31  uint32_t r6;
32  uint32_t r7;
33  uint32_t r8;
34  uint32_t r9;
35  uint32_t r10;
36  uint32_t r11;
37  uint32_t sp;
38  uint32_t cpsr;
39  uint32_t pc;
41 } cpu_context;
42 #elif AARCH_64
43 typedef struct {
44  uint64_t x19;
45  uint64_t x20;
46  uint64_t x21;
47  uint64_t x22;
48  uint64_t x23;
49  uint64_t x24;
50  uint64_t x25;
51  uint64_t x26;
52  uint64_t x27;
53  uint64_t x28;
54  uint64_t fp;
55  uint64_t sp;
56  uint64_t pc;
57 } cpu_context;
58 #endif
59 
72 #ifdef AARCH_32
73 typedef struct {
75  int32_t state;
76  int32_t counter;
77  int32_t priority;
78  int32_t preempt_count;
79 } task_struct;
80 #elif AARCH_64
81 typedef struct {
83  int64_t state;
84  int64_t counter;
85  int64_t priority;
86  int64_t preempt_count;
87 } task_struct;
88 #endif
89 
93 #define TASK_RUNNING 0
94 
97 #define NR_TASKS 64
98 
99 
101 extern task_struct *task[NR_TASKS];
103 extern task_struct *current;
105 extern int nr_tasks;
106 
111 #define FIRST_TASK task[0]
112 
116 #define LAST_TASK task[NR_TASKS-1]
117 
122 #define THREAD_SIZE 4096
123 
135 #ifdef AARCH_32
136 #define INIT_TASK { /* cpu_context */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, /* state etc */ 0,0,1,0 }
137 #elif AARCH_64
138 #define INIT_TASK { /* cpu_context */ {0,0,0,0,0,0,0,0,0,0,0,0,0}, /* state etc */ 0,0,1,0 }
139 #endif
140 
141 
147 void ret_from_fork();
148 
156 extern void cpu_switch_to(task_struct *prev, task_struct *next);
157 
161 extern void preempt_disable();
165 extern void preempt_enable();
166 
173 extern void schedule_tail();
174 
181 extern void switch_to(task_struct* next);
182 
193 extern void schedule();
194 
200 extern void timer_tick();
201 
204 #endif
ret_from_fork
void ret_from_fork()
schedule_tail
void schedule_tail()
Definition: scheduler.c:41
task_struct
Definition: scheduler.h:81
timer_tick
void timer_tick()
Definition: scheduler.c:154
task_struct::cpu_context
cpu_context cpu_context
Definition: scheduler.h:82
switch_to
void switch_to(task_struct *next)
Definition: scheduler.c:46
cpu_context
Definition: scheduler.h:43
cpu_context::x22
uint64_t x22
Definition: scheduler.h:47
task
task_struct * task[NR_TASKS]
Definition: scheduler.c:25
cpu_context::x28
uint64_t x28
Definition: scheduler.h:53
preempt_enable
void preempt_enable()
Definition: scheduler.c:36
preempt_disable
void preempt_disable()
Definition: scheduler.c:31
cpu_context::x23
uint64_t x23
Definition: scheduler.h:48
current
task_struct * current
Definition: scheduler.c:23
cpu_context::pc
uint64_t pc
Definition: scheduler.h:56
task_struct::state
int64_t state
Definition: scheduler.h:83
nr_tasks
int nr_tasks
Definition: scheduler.c:28
task_struct::counter
int64_t counter
Definition: scheduler.h:84
cpu_context::x26
uint64_t x26
Definition: scheduler.h:51
cpu_context::sp
uint64_t sp
Definition: scheduler.h:55
task_struct::priority
int64_t priority
Definition: scheduler.h:85
cpu_context::x25
uint64_t x25
Definition: scheduler.h:50
schedule
void schedule()
Definition: scheduler.c:146
task_struct::preempt_count
int64_t preempt_count
Definition: scheduler.h:86
cpu_context::x20
uint64_t x20
Definition: scheduler.h:45
cpu_context::x21
uint64_t x21
Definition: scheduler.h:46
cpu_context::x24
uint64_t x24
Definition: scheduler.h:49
cpu_context::x27
uint64_t x27
Definition: scheduler.h:52
cpu_context::x19
uint64_t x19
Definition: scheduler.h:44
cpu_switch_to
void cpu_switch_to(task_struct *prev, task_struct *next)
cpu_context::fp
uint64_t fp
Definition: scheduler.h:54
NR_TASKS
#define NR_TASKS
Definition: scheduler.h:97