mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* system calls-(query)
@ 2004-07-06  8:00 Susheel Raj
  2004-07-06  9:14 ` FabF
  2004-07-06  9:24 ` Jan-Benedict Glaw
  0 siblings, 2 replies; 3+ messages in thread
From: Susheel Raj @ 2004-07-06  8:00 UTC (permalink / raw)
  To: linux-kernel

i have been trying to understand how the system calls
are being made by applications and how the kernel
reacts to them...this is what i got into my brain....
when an application makes a system call ( for i386)
%eax register is filled with the system call number
and some other registers are to be given some
appropriate values..for example ..if i amke an exit ()
system call.. then its system call number "1" is
filled in %eax and the status code is filled in
%ebx...
 
so i want to know what are the requirements for other
systems calls to execute ...what all registers they
access..any documentation would be a great help.... 

________________________________________________________________________
Yahoo! India Careers: Over 50,000 jobs online
Go to: http://yahoo.naukri.com/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: system calls-(query)
  2004-07-06  8:00 system calls-(query) Susheel Raj
@ 2004-07-06  9:14 ` FabF
  2004-07-06  9:24 ` Jan-Benedict Glaw
  1 sibling, 0 replies; 3+ messages in thread
From: FabF @ 2004-07-06  9:14 UTC (permalink / raw)
  To: Susheel Raj; +Cc: linux-kernel

On Tue, 2004-07-06 at 10:00, Susheel Raj wrote:
> i have been trying to understand how the system calls
> are being made by applications and how the kernel
> reacts to them...this is what i got into my brain....
> when an application makes a system call ( for i386)
> %eax register is filled with the system call number
> and some other registers are to be given some
> appropriate values..for example ..if i amke an exit ()
> system call.. then its system call number "1" is
> filled in %eax and the status code is filled in
> %ebx...
>  
> so i want to know what are the requirements for other
> systems calls to execute ...what all registers they
> access..any documentation would be a great help.... 
You missed the main point here.It does software interrupt using eax,
ebx, ecx, edx, esi, edi in that order.

C program:
 syscall (100, 0, 1, 2, 3, 4, 5, 6);

Function call :
 8048200:       6a 06                   push   $0x6
 8048202:       6a 05                   push   $0x5
 8048204:       6a 04                   push   $0x4
 8048206:       6a 03                   push   $0x3
 8048208:       6a 02                   push   $0x2
 804820a:       6a 01                   push   $0x1
 804820c:       6a 00                   push   $0x0
 804820e:       6a 64                   push   $0x64
 8048210:       e8 1b 5d 00 00          call   804df30 <syscall>

Syscall release :
 804df33:       8b 7c 24 24             mov    0x24(%esp),%edi
 804df37:       8b 74 24 20             mov    0x20(%esp),%esi
 804df3b:       8b 54 24 1c             mov    0x1c(%esp),%edx
 804df3f:       8b 4c 24 18             mov    0x18(%esp),%ecx
 804df43:       8b 5c 24 14             mov    0x14(%esp),%ebx
 804df47:       8b 44 24 10             mov    0x10(%esp),%eax
 804df4b:       cd 80                   int    $0x80

(further args works with struct passing)

Best regards,
FabF


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: system calls-(query)
  2004-07-06  8:00 system calls-(query) Susheel Raj
  2004-07-06  9:14 ` FabF
@ 2004-07-06  9:24 ` Jan-Benedict Glaw
  1 sibling, 0 replies; 3+ messages in thread
From: Jan-Benedict Glaw @ 2004-07-06  9:24 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1670 bytes --]

On Tue, 2004-07-06 09:00:30 +0100, Susheel Raj <susheel_nuguru@yahoo.co.in>
wrote in message <20040706080030.35778.qmail@web8310.mail.in.yahoo.com>:
> i have been trying to understand how the system calls
> are being made by applications and how the kernel
> reacts to them...this is what i got into my brain....
> when an application makes a system call ( for i386)
> %eax register is filled with the system call number
> and some other registers are to be given some
> appropriate values..for example ..if i amke an exit ()
> system call.. then its system call number "1" is
> filled in %eax and the status code is filled in
> %ebx...
>  
> so i want to know what are the requirements for other
> systems calls to execute ...what all registers they
> access..any documentation would be a great help.... 

Userland has to place arguments where the kernel expects them. Have a
look at ./linux/asm-$ARCH/unistd.h to see how syscalls can be made. You
can think of the _syscallX() macros as the lowest-level "function" to
get access to a system call slot. From there, the syscall is usually
dispatched from entry.S.

Syscalls trigger some kind of interrupt or exception; an exception
handler then gets the system call number and dispatches it through the
syscall function pointer's addresses in sys_call_table (in entry.S).

MfG, JBG


-- 
   Jan-Benedict Glaw       jbglaw@lug-owl.de    . +49-172-7608481
   "Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg
    fuer einen Freien Staat voll Freier Bürger" | im Internet! |   im Irak!
   ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-07-06 10:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-06  8:00 system calls-(query) Susheel Raj
2004-07-06  9:14 ` FabF
2004-07-06  9:24 ` Jan-Benedict Glaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®