-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Method to add syscalls? #15
Comments
You can add syscalls by editing the syscalls.py file. I added some instructions at the bottom of docs/syscalls.md. I'll leave this issue open if you have any further questions! |
Oh, I was kind of hoping not to have to modify the files in the distro... |
I haven't tested this yet, but you could probably do it like this: import riscemu.syscall as syscall
from riscemu import UserModeCPU, RV32M, RV32I, RV32A, RunConfig
syscall.SYSCALLS[42] = 'somesyscall'
class MySyscallInterface(syscall.SyscallInterface):
def somesyscall(self, scall: syscall.Syscall):
print(scall)
scall.ret(-1)
cpu = UserModeCPU([RV32M, RV32I, RV32A], RunConfig())
cpu.syscall_int = MySyscallInterface()
# ... You should keep in mind, that the registers don't work with integers, but with a wrapper around them called Int32 (and UInt32). They behave just like integers, but you must unwrap them if you wish to use "normal" integers to e.g. read memory at an address, or set the CPU pc. |
This looks pretty boilerplate heavy though, maybe I should add an easier method to add syscalls at runtime... |
Yah -- also just assigning syscall_int wouldn't add the symbols. It's ok to restrict adding syscalls to config time. Once the processor runs, it's probably a bad idea to add syscalls :> |
Could you add a method to add syscalls to the CPU? Thanks!
The text was updated successfully, but these errors were encountered: