<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>P {MARGIN-TOP: 0mm; MARGIN-BOTTOM: 0mm}</style>
</head>
<body>
<div style="FONT-FAMILY: 굴림; FONT-SIZE: 10pt" id="ezFormProc_div">
<div id="msgbody">
<div>
<div style="LINE-HEIGHT: 15pt">Hi,</div>
<div style="LINE-HEIGHT: 15pt"><br>
below is a code snippet from arch/sparc/kernel/entry.S. I can't understand a part of it (I think I once understood it but forgot..).</div>
<div style="LINE-HEIGHT: 15pt">#define LINUX_SYSCALL_TRAP \<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sethi %hi(sys_call_table), %l7; \<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or %l7, %lo(sys_call_table), %l7; \<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b linux_sparc_syscall; \ <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rd %psr, %l0;<br>
....<br>
linux_sparc_syscall:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sethi&nbsp;&nbsp; %hi(PSR_SYSCALL), %l4<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; %l0, %l4, %l0<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Direct access to user regs, must faster. */<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmp&nbsp;&nbsp;&nbsp;&nbsp; %g1, NR_syscalls<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bgeu&nbsp;&nbsp;&nbsp; linux_sparc_ni_syscall<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sll&nbsp;&nbsp;&nbsp; %g1, 2, %l4<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ld&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [%l7 &#43; %l4], %l7<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; andcc&nbsp;&nbsp; %l7, 1, %g0<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bne&nbsp;&nbsp;&nbsp;&nbsp; linux_fast_syscall<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Just do first insn from SAVE_ALL in the delay slot */</div>
<div style="LINE-HEIGHT: 15pt">when linux system call trap is entered, the sys_call_table address is stored in %l7 and %psr in %l0 and it branches to linux_sparc_syscall.
<br>
(%psr is read in branch delayed slot). From the linux_sparc_syscall, the the %l0 (PSR value) is set with system call bit (to indicate it's in system<br>
&nbsp;call later), and if the system call number is compared with the max value, if it is greater or equal, it branches to linux_sparc_ni_syscall (not implemented).<br>
The part I can't understand follows. %l7 contains sys_call_table, so it loads the system call address with corresponding offset (nubmer * 4, or 2 bit shift left). Then what is this &quot;andcc %l7, 1, %g0&quot; doing?</div>
<div style="LINE-HEIGHT: 15pt">&nbsp;</div>
<div style="LINE-HEIGHT: 15pt">Thanks!</div>
<div style="LINE-HEIGHT: 15pt">Chan</div>
</div>
</div>
</div>
</body>
</html>