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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/**
* @file
*
* Fool OS - System Call Interface
* ===============================
*
* Most of the syscalls are loosely based on a very small subset of the
* linux system calls.
*
* They seem enough to back a small C Library as newlib in this case.
*
*
*/
#include <stdint.h>
#include <stdbool.h>
#include "fd.h"
#define SYSCALL_EXIT 60
#define SYSCALL_EXECVE 64
#define SYSCALL_FORK 72
#define SYSCALL_CLOSE 66
#define SYSCALL_OPEN 65
#define SYSCALL_GETPID 78
#define SYSCALL_ISATTY 68 // linux??
#define SYSCALL_LINK 82
#define SYSCALL_LSEEK 69
#define SYSCALL_READ 62
#define SYSCALL_SBRK 70
#define SYSCALL_STAT 74 // need all?
#define SYSCALL_FSTAT 67 // need all?
#define SYSCALL_LSTAT 79 // need all?
#define SYSCALL_TIMES 75
#define SYSCALL_UNLINK 76
#define SYSCALL_WAIT 77
#define SYSCALL_WRITE 61
#define SYSCALL_GETTIMEOFDAY 71
#define SYSCALL_READDIR 63 // linux has getdents
#define SYSCALL_KILL 73
#define SYSCALL_CLONE 83
#define SYSCALL_PIPE 84
#define SYSCALL_DUP2 86
#define SYSCALL_GUI_RECT 87
#define SYSCALL_GUI_WIN 88
/** Todo move somewhere else and init per process , think how to make thread safe */
void fd_init_std_streams(uint32_t pid);
fd *get_fd(uint32_t pid,uint32_t file);
/** returns string representation of the syscall from its number */
char* syscall_get_name(uint32_t num);
/** invoke a syscall from kernel */
uint32_t syscall_generic(uint32_t nr,uint32_t p1, uint32_t p2, uint32_t p3, uint32_t pid);
/** test if a specific syscall is ready to be processed */
uint32_t syscall_generic_test(uint32_t nr,uint32_t p1, uint32_t p2, uint32_t p3, uint32_t pid);
// new planned syscalls for graphx
// TODO: split ncurses and our syscalls??
// int syscall_create_win("title");
// int syscall_kill_win(int descriptor);
// int syscall_update_win(int descriptor, *mem, *rect);
// int syscall_callback(*func, ON_MOUSE);
// int syscall_sleep();
|