Skip site navigation (1)Skip section navigation (2)
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>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
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

[-- Attachment #2 --]
<html xmlns="http://www.w3.org/1999/xhtml">;
<head>
<title></title>
</head>
<body>
<div name="messageBodySection">
<div dir="auto">I am wondering about the function ecall_handler(<a href="https://github.com/freebsd/freebsd-src/blob/main/sys/riscv/riscv/trap.c#L195" target="_blank">https://github.com/freebsd/freebsd-src/blob/main/sys/riscv/riscv/trap.c#L195</a>), which later executing syscallenter, where&#160;<span style="color:#000000;font-family:Helvetica Neue;font-size: 13px">&amp;td-&gt;td_sa</span><span style="font-size: 13px"><br /></span>&#160;Is used. I have no idea where the value of&#160;<span style="color:#000000;font-family:Helvetica Neue;font-size: 13px">td-&gt;td_sa is&#160;</span><span style="color:#000000;font-family:Helvetica Neue;font-size: small">being set. It is a little bit confusing.</span><span style="font-size: small"><br /></span><span style="font-size: small"><br /></span><span style="color:#000000;font-family:Helvetica Neue;font-size: small">Someone asks me to read&#160;</span>cpu_fetch_syscall_args(<a href="https://github.com/freebsd/freebsd-src/blob/main/sys/riscv/riscv/trap.c#L99" target="_blank">https://github.com/freebsd/freebsd-src/blob/main/sys/riscv/riscv/trap.c#L99</a>), and it indeed explains how&#160;<span style="color:#000000;font-family:Helvetica Neue;font-size: small">td-&gt;td_sa is being set. But however, I still have no idea how it works.</span><span style="font-size: small"><br /></span><span style="font-size: small"><br /></span><span style="color:#000000;font-family:Helvetica Neue;font-size: small">It is called as a function member in&#160;</span>elf64_freebsd_sysvec<span style="color:#000000;font-family:Helvetica Neue;font-size: small">(</span><a href="https://github.com/freebsd/freebsd-src/blob/7aa4e4eb36171d349c7f3948e16c09ff7540c241/sys/riscv/riscv/elf_machdep.c#L61C25-L61C45" target="_blank">https://github.com/freebsd/freebsd-src/blob/7aa4e4eb36171d349c7f3948e16c09ff7540c241/sys/riscv/riscv/elf_machdep.c#L61C25-L61C45</a>), and I think there is nothing to do with syscall here.<br />
<br />
Could somebody please figure it out?<br />
How does a system call works? Where the value of&#160;<span style="color:#000000;font-family:Helvetica Neue;font-size: 13px">td-&gt;td_sa is&#160;</span><span style="color:#000000;font-family:Helvetica Neue;font-size: small">being set.</span><span style="font-size: small"><br /></span><span style="font-size: small"><br /></span><span style="font-size: small"><br /></span><span style="color:#000000;font-family:Helvetica Neue;font-size: small">Thank you very much.</span></div>
</div>
<div name="messageSignatureSection"><br />
<div class="matchFont">Best Regards,
<div dir="auto">Lin Lee</div>
</div>
</div>
</body>
</html>
home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8f66f3ed-2a49-4ebc-89eb-66c53e6d22bb>