riscemu.syscall module
RiscEmu (c) 2021 Anton Lydike
SPDX-License-Identifier: MIT
- riscemu.syscall.SYSCALLS = {63: 'read', 64: 'write', 93: 'exit', 192: 'mmap2', 1024: 'open', 1025: 'close'}
This dict contains a mapping for all available syscalls (code->name)
If you wish to add a syscall to the built-in system, you can extend this dictionary and implement a method with the same name on the SyscallInterface class.
- riscemu.syscall.ADDITIONAL_SYMBOLS = {'MAP_ANON': 4, 'MAP_ANONYMOUS': 4, 'MAP_PRIVATE': 1, 'MAP_SHARED': 2, 'PROT_READ': 1, 'PROT_WRITE': 2}
A set of additional symbols that are used by various syscalls.
- riscemu.syscall.OPEN_MODES = {0: 'rb', 1: 'wb', 2: 'r+b', 3: 'x', 4: 'ab'}
All available file open modes
- class riscemu.syscall.Syscall(id: int, cpu: CPU)
Bases:
object
Represents a syscall
- id: int
The syscall number (e.g. 64 - write)
- property name
- riscemu.syscall.get_syscall_symbols()
Generate global syscall symbols (such as SCALL_READ, SCALL_EXIT etc)
- Returns:
dictionary of all syscall symbols (SCALL_<name> -> id)
- class riscemu.syscall.SyscallInterface
Bases:
object
Handles syscalls
- open_files: Dict[int, IO]
- next_open_handle: int
- read(scall: Syscall)
read syscall (63): read from file no a0, into addr a1, at most a2 bytes on return a0 will be the number of read bytes or -1 if an error occured
- write(scall: Syscall)
write syscall (64): write a2 bytes from addr a1 into fileno a0 on return a0 will hold the number of bytes written or -1 if an error occured
- open(scall: Syscall)
open syscall (1024): read path of a2 bytes from addr a1, in mode a0 returns the file no in a0
- modes:
0: read
1: write (truncate)
2: read/write (no truncate)
3: only create
4: append
Requires running with flag scall-fs