-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsyscall.h
More file actions
51 lines (41 loc) · 1.14 KB
/
syscall.h
File metadata and controls
51 lines (41 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef SYSCALL_H
#define SYSCALL_H
#include "sched.h"
// NO API
// Externs
extern struct sched_pcb_s* current_process;
extern void PUT32 ( unsigned int, unsigned int );
// Does an actual reboot (watchdog reset), inline: no stack
static inline __attribute__((always_inline)) void syscall_do_reboot() {
const int PM_RSTC = 0x2010001c;
const int PM_WDOG = 0x20100024;
const int PM_PASSWORD = 0x5a000000;
const int PM_RSTC_WRCFG_FULL_RESET = 0x00000020;
PUT32(PM_WDOG, PM_PASSWORD | 1);
PUT32(PM_RSTC, PM_PASSWORD | PM_RSTC_WRCFG_FULL_RESET);
while(1);
}
// Ask for a wait syscall
static inline __attribute__((always_inline)) void syscall_do_wait(unsigned int quantums) {
current_process->sleepuntil = quantums;
__asm("mov pc, %0" : : "r"(sched_ctx_switch_from_irq));
}
// END NO API
/**
* Asks for a system reboot
*/
void syscall_reboot();
/**
* Asks to put the current process on wait
*
* @param The amount of quantums to wait
*/
void syscall_wait(unsigned int quantums);
/*
* Handles a syscall
*
* @param The syscall's code
* @param The parameters
*/
void syscall_swi_handler(unsigned int code, unsigned int * params);
#endif