Re: Assembly code for calling a function on amd machine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I suspect this may be because it is using the fast call calling
convention calling the function in the driver. (I'm using this to call
functions in the driver). But I dont see any fastcall decleration in
the kernel code (I'm using it to call get_stats for a network driver
for example). Can anyone help me here?

Below is the code for intel machines. it is for calling a function
using arguments for the stack. Any obvious mistakes for an AMD
machine. Is there any recourse for me for calling kernel driver
functions? Please help.

#define FUNCTONCALL(f, n, r) \
  asm ( \
        "movl %0, %%eax\n" \
        "subl %%eax, %%esp\n" \
        "pushl %%esi\n" \
        "pushl %%edi\n" \
        "movl %%esp, %%edi\n" \
        "movl %%ebp, %%esi\n" \
        "addl $8, %%edi\n" \
        "addl $8, %%esi\n" \
        "shr  $2, %%eax\n" \
        "movl %%eax, %%ecx\n" \
        "repz movsd\n" \
        "popl %%edi\n" \
        "popl %%esi\n" \
        : : "r" (n*4) : "esi","edi","eax","ecx","esp" ); \
  r ( (int (*)(void)) f)(); \
  asm ("addl %0, %%esp\n" : : "r" (n*4))

-Asim


On 7/15/08, Peter Teoh <htmldeveloper@xxxxxxxxx> wrote:
> Yes, I think so too.   Based on your earlier posting I suspect it is a
> AMD 64bit CPU, vs Intel 32bit CPU compiled codes.   And if assembly
> does not worked in kernel, it should not worked in your userspace
> compilation too.
>
> Check it up again?   Thanks.
>
> On Wed, Jul 16, 2008 at 9:01 AM, Erik Mouw <mouw@xxxxxxxxxxxx> wrote:
>> On Tue, Jul 15, 2008 at 06:51:46PM -0500, Asim wrote:
>>> I have an AMD Opteron(tm) Processor. I want to write assembly code for
>>> calling a function say f with n arguments already in stack and store
>>> the result in res. I can write on Intel but on AMD machines the
>>> arguments are not being passed correctly. Does anyone know what
>>> changes I need to make for processor specification. I'm not getting
>>> any good document online.
>>
>> The nice thing about AMD and Intel processors is that they have fully
>> compatible instruction sets (minus the extensions like SSE3 etc.). IOW:
>> if it works on an Intel CPU, it will work on an AMD CPU. Without source
>> it is impossible to tell why it doesn't work for you.
>>
>> BTW, is this really a kernel related question?
>>
>>
>> Erik
>>
>> --
>> Erik Mouw -- mouw@xxxxxxxxxxxx
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.6 (GNU/Linux)
>>
>> iD8DBQFIfUhX/PlVHJtIto0RAkl0AJ0dJm8Unj+b1WwCrPpPDp/xdHIyyACbBsSQ
>> aPG12ZiYHBAu26XGHcidQUI=
>> =pkXW
>> -----END PGP SIGNATURE-----
>>
>>
>
>
>
> --
> Regards,
> Peter Teoh
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux