Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RISCV Linux Syscall codes

Tags:

linux

riscv

I'm writing RISCV assembly and I need to perform some syscalls. Based on other answers on this site I know I need to load the syscall code into a7 and launch ecall.

How do I know what code to use?

EDIT: I'm trying to use write, read, close,wait4, fork.

I found two sources of syscall codes that are different:

https://github.com/westerndigitalcorporation/RISC-V-Linux/blob/master/linux/arch/s390/kernel/syscalls/syscall.tbl

and directly in the file generated after running make linux using the RISCV toolchain: sysroot/usr/include/asm-generic/unistd.h

Which should I use? (Fork is in the first but not the second)

like image 294
AD S2dios Avatar asked Jun 28 '26 11:06

AD S2dios


1 Answers

it is a late answer, but perhaps someone will find it usefull.

As of now you can find the codes for linux syscall at this website :

https://gpages.juszkiewicz.com.pl/syscalls-table/syscalls.html

just select your architecture.

for the calling convention, there is a post about it there :

RISC-V ecall syscall calling convention on pk/Linux

like image 167
Jules Martin Avatar answered Jul 01 '26 07:07

Jules Martin