<div dir="ltr"><div>> Is this correct for all architectures?<br><br></div><div>I guess not, asmlinkage is undefined for arm, so I assume this mechanism is not there for arm.<br></div><div><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Fri, Jan 4, 2013 at 2:24 PM, ²·ß®Ìì <span dir="ltr"><<a href="mailto:buyit@live.cn" target="_blank">buyit@live.cn</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="auto"><div><br><br>ÔÚ 2013-1-4£¬15:38£¬"Rajat Sharma" <<a href="mailto:fs.rajat@gmail.com" target="_blank">fs.rajat@gmail.com</a>> дµÀ£º<br><br></div><div class="im"><blockquote type="cite"><div><div dir="ltr">
<div><div><div><div>> So with asmlinkage we request 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><div> Is this correct for all architectures?</div><div><br></div><div> 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><div class="h5"><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"><<a href="mailto:rpal143@gmail.com" target="_blank">rpal143@gmail.com</a>></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 asmlinkage we request 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><br><br><div class="gmail_quote">
On Thu, Jan 3, 2013 at 9:34 PM, Mulyadi Santosa <span dir="ltr"><<a href="mailto:mulyadi.santosa@gmail.com" target="_blank">mulyadi.santosa@gmail.com</a>></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 <<a href="mailto:rpal143@gmail.com" target="_blank">rpal143@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> I was searching for asmlinkage and found that it is already explained at<br>
> <a href="http://kernelnewbies.org/FAQ/asmlinkage" target="_blank">http://kernelnewbies.org/FAQ/asmlinkage</a><br>
><br>
> 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" target="_blank">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" target="_blank">Kernelnewbies@kernelnewbies.org</a></span><br>
<span><a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a></span><br></div></blockquote></div></div></div></blockquote></div>
<br></div>