A little bit wondering about how a syscall works
- Reply: Mitchell Horne : "Re: A little bit wondering about how a syscall works"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 30 Jan 2024 14:00:15 UTC
I am wondering about the function ecall_handler(https://github.com/freebsd/freebsd-src/blob/main/sys/riscv/riscv/trap.c#L195), which later executing syscallenter, where &td->td_sa Is used. I have no idea where the value of td->td_sa is being set. It is a little bit confusing. Someone asks me to read cpu_fetch_syscall_args(https://github.com/freebsd/freebsd-src/blob/main/sys/riscv/riscv/trap.c#L99), and it indeed explains how td->td_sa is being set. But however, I still have no idea how it works. It is called as a function member in elf64_freebsd_sysvec(https://github.com/freebsd/freebsd-src/blob/7aa4e4eb36171d349c7f3948e16c09ff7540c241/sys/riscv/riscv/elf_machdep.c#L61C25-L61C45), and I think there is nothing to do with syscall here. Could somebody please figure it out? How does a system call works? Where the value of td->td_sa is being set. Thank you very much. Best Regards, Lin Lee