Re: Assembly code for calling a function on amd machine

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

 



On Wed, Jul 16, 2008 at 11:57 PM, Asim <linkasim@xxxxxxxxx> wrote:
> 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?
>

correct me please, are u intending to write assembly for 64 or 32 bit
CPU (intel or AMD does not matter)?

Your previous post on PAGE_NX implied 64bit, but here below the
assembly is for 32 bit.

In userspace, if u have 32bit packages on the 64bit kernel, u can
still execute and run 32bit applications.
But not in kernel, as all must be the same bit size.

> 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))
>

--
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