summaryrefslogtreecommitdiff
path: root/documentation/syscalls.txt
blob: 15aabfac15ab2a488147974eee2cf5453a404a2f (plain) (blame)
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
70
71
72
on application entry:
  there is a 1MiB - 8KiB area mapped writable and not
  executable with guard pages on either side, and rsp is
  set to the top of that. all other registers are set to 0.

for all system calls:
  rax, rdi, rsi, rdx are in/out paramters.
  rbx, rbp, rsp, r12-r15 are preserved.
  rcx, rflags, r8-r11 are clobbered.

file result:
  0 = success
  1 = bad file handle
  2 = device error
  3 = file system corrupt
  4 = tried to read out of bounds
  5 = file does not exist
  6 = tried to open directory

encode color:
  rax in: 0
  edi in: r + g * 256 + b * 65536
  eax out: encoded color

get framebuffer:
  rax in: 1
  rax out: pointer to framebuffer
  rdi out: width + height * 2 ** 32
  esi out: pitch
  framebuffer is always 32 bpp. use the encode color syscall
  to encode colors. pitch is in dwords, not in bytes.

open file:
  rax in: 2
  rdi in: pointer to file path
  rsi in: file path length
  rax out: file result
  rdi out: file handle (if rax = success)

get file length:
  rax in: 3
  rdi in: file handle
  rax out: file result
  rdi out: file length (if rax = success)

read from file:
  rax in: 4
  rdi in: pointer to request struct
  rax out: file result
  request struct:
    qword: file handle
    qword: start offset in bytes
    qword: length in bytes
    qword: pointer to buffer

end this process:
  rax in: 5
  edi in: exit code (signed)

get new pages:
  rax in: 6
  rdi in: number of pages to allocate
  rax out: start of first page
  the allocated pages are next to each other, writable, and not executable.

close file:
  rax in: 7
  rdi in: file handle

read key packet:
  rax in: 8
  eax out: key packet