68 lines
1.6 KiB
Text
68 lines
1.6 KiB
Text
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
|