32 lines
599 B
C
32 lines
599 B
C
#include "process.h"
|
|
|
|
uint32_t **current_sp;
|
|
|
|
extern void puts(const char *s);
|
|
|
|
void start_task(Process *pentry) {
|
|
__asm volatile(
|
|
"mov %0, sp"
|
|
: "=r" (*current_sp)
|
|
);
|
|
__asm volatile(
|
|
"mov sp, %0\n"
|
|
:: "r" (STACK_START(pentry->stack))
|
|
);
|
|
pentry->entrypoint();
|
|
__asm volatile(
|
|
"mov sp, %0\n"
|
|
:: "r" (*current_sp)
|
|
);
|
|
}
|
|
|
|
void run(ProcessTable *ptable) {
|
|
while(1) {
|
|
for (int i = 0; i<ptable->entries; i++) {
|
|
Process *pentry = &ptable->process_list[i];
|
|
|
|
start_task(pentry);
|
|
}
|
|
}
|
|
}
|