Date: Tue, 30 Jan 2024 22:00:15 +0800 From: Lin Lee <leelin2602@gmail.com> To: freebsd-riscv@freebsd.org Subject: A little bit wondering about how a syscall works Message-ID: <8f66f3ed-2a49-4ebc-89eb-66c53e6d22bb@Spark> In-Reply-To: <9204b5c5-63bc-4c29-af19-1f1bb85f74e8@Spark> References: <9204b5c5-63bc-4c29-af19-1f1bb85f74e8@Spark>
next in thread | previous in thread | raw e-mail | index | archive | help
--65b900f5_63760c8f_4d5 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I am wondering about the function ecall=5Fhandler(https://github.com/free= bsd/freebsd-src/blob/main/sys/riscv/riscv/trap.c=23L195), which later exe= cuting syscallenter, where=C2=A0&td->td=5Fsa =C2=A0Is used. I have no idea where the value of=C2=A0td->td=5Fsa is=C2=A0= being set. It is a little bit confusing. Someone asks me to read=C2=A0cpu=5Ffetch=5Fsyscall=5Fargs(https://github.= com/freebsd/freebsd-src/blob/main/sys/riscv/riscv/trap.c=23L99), and it i= ndeed explains how=C2=A0td->td=5Fsa is being set. But however, I still ha= ve no idea how it works. It is called as a function member in=C2=A0elf64=5Ffreebsd=5Fsysvec(https:= //github.com/freebsd/freebsd-src/blob/7aa4e4eb36171d349c7f3948e16c09ff754= 0c241/sys/riscv/riscv/elf=5Fmachdep.c=23L61C25-L61C45), and I think there= is nothing to do with syscall here. Could somebody please figure it out=3F How does a system call works=3F Where the value of=C2=A0td->td=5Fsa is=C2= =A0being set. Thank you very much. Best Regards, Lin Lee --65b900f5_63760c8f_4d5 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline <html xmlns=3D=22http://www.w3.org/1999/xhtml=22> <head> <title></title> </head> <body> <div name=3D=22messageBodySection=22> <div dir=3D=22auto=22>I am wondering about the function ecall=5Fhandler(<= a href=3D=22https://github.com/freebsd/freebsd-src/blob/main/sys/riscv/ri= scv/trap.c=23L195=22 target=3D=22=5Fblank=22>https://github.com/freebsd/f= reebsd-src/blob/main/sys/riscv/riscv/trap.c=23L195</a>), which later exec= uting syscallenter, where&=23160;<span style=3D=22color:=23000000;font-fa= mily:Helvetica Neue;font-size: 13px=22>&td->td=5Fsa</span><span st= yle=3D=22font-size: 13px=22><br /></span>&=23160;Is used. I have no idea = where the value of&=23160;<span style=3D=22color:=23000000;font-family:He= lvetica Neue;font-size: 13px=22>td->td=5Fsa is&=23160;</span><span sty= le=3D=22color:=23000000;font-family:Helvetica Neue;font-size: small=22>be= ing set. It is a little bit confusing.</span><span style=3D=22font-size: = small=22><br /></span><span style=3D=22font-size: small=22><br /></span><= span style=3D=22color:=23000000;font-family:Helvetica Neue;font-size: sma= ll=22>Someone asks me to read&=23160;</span>cpu=5Ffetch=5Fsyscall=5Fargs(= <a href=3D=22https://github.com/freebsd/freebsd-src/blob/main/sys/riscv/r= iscv/trap.c=23L99=22 target=3D=22=5Fblank=22>https://github.com/freebsd/f= reebsd-src/blob/main/sys/riscv/riscv/trap.c=23L99</a>), and it indeed exp= lains how&=23160;<span style=3D=22color:=23000000;font-family:Helvetica N= eue;font-size: small=22>td->td=5Fsa is being set. But however, I still= have no idea how it works.</span><span style=3D=22font-size: small=22><b= r /></span><span style=3D=22font-size: small=22><br /></span><span style=3D= =22color:=23000000;font-family:Helvetica Neue;font-size: small=22>It is c= alled as a function member in&=23160;</span>elf64=5Ffreebsd=5Fsysvec<span= style=3D=22color:=23000000;font-family:Helvetica Neue;font-size: small=22= >(</span><a href=3D=22https://github.com/freebsd/freebsd-src/blob/7aa4e4e= b36171d349c7f3948e16c09ff7540c241/sys/riscv/riscv/elf=5Fmachdep.c=23L61C2= 5-L61C45=22 target=3D=22=5Fblank=22>https://github.com/freebsd/freebsd-sr= c/blob/7aa4e4eb36171d349c7f3948e16c09ff7540c241/sys/riscv/riscv/elf=5Fmac= hdep.c=23L61C25-L61C45</a>), and I think there is nothing to do with sysc= all here.<br /> <br /> Could somebody please figure it out=3F<br /> How does a system call works=3F Where the value of&=23160;<span style=3D=22= color:=23000000;font-family:Helvetica Neue;font-size: 13px=22>td->td=5F= sa is&=23160;</span><span style=3D=22color:=23000000;font-family:Helvetic= a Neue;font-size: small=22>being set.</span><span style=3D=22font-size: s= mall=22><br /></span><span style=3D=22font-size: small=22><br /></span><s= pan style=3D=22font-size: small=22><br /></span><span style=3D=22color:=23= 000000;font-family:Helvetica Neue;font-size: small=22>Thank you very much= .</span></div> </div> <div name=3D=22messageSignatureSection=22><br /> <div class=3D=22match=46ont=22>Best Regards, <div dir=3D=22auto=22>Lin Lee</div> </div> </div> </body> </html> --65b900f5_63760c8f_4d5--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8f66f3ed-2a49-4ebc-89eb-66c53e6d22bb>