diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-09-11 19:04:49 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-09-11 19:53:23 -0700 |
commit | ecfbbfb5b58aaba9f9265cb13b9fb4a914bdcf37 (patch) | |
tree | 486cd5f4ee75323b5c733912c7a58501d65b0325 /049init.linux | |
parent | 4d53de8afa0d44e29d3caeb01ccdd02bc2e4cd70 (diff) | |
download | mu-ecfbbfb5b58aaba9f9265cb13b9fb4a914bdcf37.tar.gz |
5647 - experimental support for swapping OS
Diffstat (limited to '049init.linux')
-rw-r--r-- | 049init.linux | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/049init.linux b/049init.linux new file mode 100644 index 00000000..4dcb77be --- /dev/null +++ b/049init.linux @@ -0,0 +1,68 @@ +# Some OS-specific preliminaries for Linux. + +# Memory layout +# +# 0 - 0x08047ffff - reserved for the kernel +# 0x08048000 - 0xbffffffff - available for user programs +# 0xc0000000 - 0xfffffffff - reserved for the kernel +== code 0x09000000 +== data 0x0a000000 + +# Syscalls +# +# We don't have libc, so we need to know Linux's precise syscall layout. +== code + +# http://man7.org/linux/man-pages/man2/exit.2.html +syscall_exit: # status/ebx : int + b8/copy-to-eax 1/imm32 + cd/syscall 0x80/imm8 + +# http://man7.org/linux/man-pages/man2/read.2.html +syscall_read: # fd/ebx : int, buf/ecx : address, size/edx : int -> nbytes-or-error/eax : int + b8/copy-to-eax 3/imm32 + cd/syscall 0x80/imm8 + c3/return + +# http://man7.org/linux/man-pages/man2/write.2.html +syscall_write: # fd/ebx : int, buf/ecx : address, size/edx : int -> nbytes-or-error/eax : int + b8/copy-to-eax 4/imm32 + cd/syscall 0x80/imm8 + c3/return + +# http://man7.org/linux/man-pages/man2/open.2.html +syscall_open: # filename/ebx : (address null-terminated-string), flags/ecx : int -> fd-or-error/eax : int + b8/copy-to-eax 5/imm32 + cd/syscall 0x80/imm8 + c3/return + +# http://man7.org/linux/man-pages/man2/close.2.html +syscall_close: # fd/ebx : int -> status/eax + b8/copy-to-eax 6/imm32 + cd/syscall 0x80/imm8 + c3/return + +# http://man7.org/linux/man-pages/man2/creat.2.html +syscall_creat: # filename/ebx : (address null-terminated-string) -> fd-or-error/eax : int + b8/copy-to-eax 8/imm32 + cd/syscall 0x80/imm8 + c3/return + +# http://man7.org/linux/man-pages/man2/unlink.2.html +syscall_unlink: # filename/ebx : (address null-terminated-string) -> status/eax : int + b8/copy-to-eax 0xa/imm32 + cd/syscall 0x80/imm8 + c3/return + +# http://man7.org/linux/man-pages/man2/rename.2.html +syscall_rename: # source/ebx : (address null-terminated-string), dest/ecx : (address null-terminated-string) -> status/eax : int + b8/copy-to-eax 0x26/imm32 + cd/syscall 0x80/imm8 + c3/return + +# https://github.com/torvalds/linux/blob/fa121bb3fed6313b1f0af23952301e06cf6d32ed/mm/nommu.c#L1352 +syscall_mmap: # arg/ebx : (address mmap_arg_struct) -> status/eax : int + # the important thing: ebx+4 contains the 32-bit size to be allocated + b8/copy-to-eax 0x5a/imm32 + cd/syscall 0x80/imm8 + c3/return |