<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br><br>在 2013-1-4,15:38,"Rajat Sharma" &lt;<a href="mailto:fs.rajat@gmail.com">fs.rajat@gmail.com</a>&gt; 写道:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div><div><div><div>&gt; So with&nbsp;asmlinkage&nbsp;we request&nbsp;compiler to put args on stack. 
What is advantage of this to start_kernel or in general to other 
functions ?<br><br></div>See its about implementation ease and little of performance too. Assuming the default model of keeping arguments in registers is used. lets say arguments are assumed to be in registers R1, R2, R3, R4, R5, R6 and beyond that in stack. Since system call number is a transparent argument which is chopped off when calling the actual kernel handler and if R1 had the system call number, then you have to shift all register values and stack arguments too.<br>
<br></div></div></div></div></div></blockquote><div>&nbsp; &nbsp;Is this correct for all architectures?</div><div><br></div><div>&nbsp; &nbsp;As I remembered, ARM uses SWI instruction to implement the system call, it will pass system call number by register R7, and use normal register R0~R3 to pass parameters.</div><div><br></div><div><br></div><br><blockquote type="cite"><div><div dir="ltr"><div><div>Now consider that all arguments are pushed on stack (as enforced by asmlinkage), you have all function argument in the beginning of the stack and the system call number on top of the stack. you just need to pop out stack top to remove system call number from function argument.<br>
<br></div>You might argue that why not always keep system call number on stack top and use registers for function arguments? But thats part of the compiler ABI and if you had fewer arguments lets say 2 only and used up R1 and R2 only, you may not jump to stack top directly for storing system call as its turn for R3 as argument.<br>
<br>So, isn't it simpler implementation with everything on stack?<br><br></div>-Rajat<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 4, 2013 at 12:13 PM, Rahul Bedarkar <span dir="ltr">&lt;<a href="mailto:rpal143@gmail.com" target="_blank">rpal143@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks. So with&nbsp;asmlinkage&nbsp;we request&nbsp;compiler to put args on stack. What is advantage of this to start_kernel or in general to other functions ?<div>
<br></div><div>Regards,</div><div>Rahul<div class="im"><br><br><div class="gmail_quote">

On Thu, Jan 3, 2013 at 9:34 PM, Mulyadi Santosa <span dir="ltr">&lt;<a href="mailto:mulyadi.santosa@gmail.com" target="_blank">mulyadi.santosa@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><div>On Thu, Jan 3, 2013 at 7:40 PM, Rahul Bedarkar &lt;<a href="mailto:rpal143@gmail.com" target="_blank">rpal143@gmail.com</a>&gt; wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; I was searching for asmlinkage and found that it is already explained at<br>
&gt; <a href="http://kernelnewbies.org/FAQ/asmlinkage" target="_blank">http://kernelnewbies.org/FAQ/asmlinkage</a><br>
&gt;<br>
&gt; But I didn't get this. Can someone tell me about it in brief ?<br>
<br>
</div></div>the point is, parameters which is usually passed via stack, is passed<br>
using different way.<br>
<br>
A good example is system call.... they are passed using registers IIRC<br>
<span><font color="#888888"><br>
<br>
--<br>
regards,<br>
<br>
Mulyadi Santosa<br>
Freelance Linux trainer and consultant<br>
<br>
blog: <a href="http://the-hydra.blogspot.com" target="_blank">the-hydra.blogspot.com</a><br>
training: <a href="http://mulyaditraining.blogspot.com" target="_blank">mulyaditraining.blogspot.com</a><br>
</font></span></blockquote></div><br></div></div></div>
<br>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
<br></blockquote></div><br></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Kernelnewbies mailing list</span><br><span><a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a></span><br><span><a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a></span><br></div></blockquote></body></html>