I’ve got a rough idea on how to implement a syscall for using while in user mode, but I’m not 100% sure.
I plan on using a public function syscall()
which will do…
1. save all of the cpu registers by pushing them onto the stack
2. load any parameters I want to use in my trap handler into a0-a7
3.ECALL
`Trap Handler()`
4. Handle syscall in m-mode
5. pop cpu registers off of stack and restore
6. increment pc by 4 to jump pass the original ECALL
7.set MEPC
8. MRET
Does that make sense, am I missing anything?
One of my goals is to use this to print something over UART from u-mode via a syscall.