Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* How the Alpha/OSF1 system call work ???
@ 1997-09-17  4:00 Chung-min Hung
  1997-09-19  4:00 ` Eric Werme
  0 siblings, 1 reply; 2+ messages in thread
From: Chung-min Hung @ 1997-09-17  4:00 UTC (permalink / raw)



Could you tell me how the Alpha/OSF1 open() system call work ?
1. How the Alpha/OSF1 system pass the arguments to the kernel open()
routine ?
2. How the kernel open() routine get the "filename" argument ?

Thanks !
C. M. Hung




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

* Re: How the Alpha/OSF1 system call work ???
  1997-09-17  4:00 How the Alpha/OSF1 system call work ??? Chung-min Hung
@ 1997-09-19  4:00 ` Eric Werme
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Werme @ 1997-09-19  4:00 UTC (permalink / raw)



Chung-min Hung <hjm@cwb.gov.tw> writes:

>Could you tell me how the Alpha/OSF1 open() system call work ?
>1. How the Alpha/OSF1 system pass the arguments to the kernel open()
>routine ?
>2. How the kernel open() routine get the "filename" argument ?

All the system calls you call from C actually go to small assembly
language routines in libc.

For open(2), the code calls:
>*[__open, 0x120030100]         addq    r31, 0x2d, r0
  [__open, 0x120030104]         call_pal        callsys
  [__open, 0x120030108]         beq     r19, 0x120030120
  [__open, 0x12003010c]         br      gp, 0x120030110
  [__open, 0x120030110]         ldah    gp, 8190(gp)
  [__open, 0x120030114]         lda     gp, -16192(gp)
  [__open, 0x120030118]         ldq     r28, -26736(gp)
  [__open, 0x12003011c]         bsr     r31, _cerror
  [__open, 0x120030120]         ret     r31, (r26), 1

This code is created from the SYSCALL macro in /usr/include/alpha/asm.s.
All it does is load the system call number (see /usr/include/syscall.h) in
R0 and traps to the kernel.

When you called open(), the arguments were loaded in R16, R17, and R18.
The PAL code callsys instruction switches to the kernel stack and jumps
to the system call handler (see the Alpha Architecture manual).  That
saves R16-R19 in a local vector and dispatches to a kernel routine named
"open" (oddly enough).  Each system call generally casts the argument
vector to a structure specific for the system call.

Routines, (like open), which take arguments that point in user's memory
access that memory through special bcopy-like routines that catch bogus
addresses and return EFAULT.

When the system call exits, R19 is zero on success. On error, the error
code is in R0 and cerror() stores it in errno.

This is typically how all Unixes handle system calls, Linux might be
a little different since it isn't derived from the classic sources.

Note - if think you need to know these details to write user level code, you
don't.  Even libc and kernel programmers rarely look at these code paths.
-- 
  <>    Eric (Ric) Werme   <>    DEC's back!  (As an officially approved  <>
  <>  <werme@zk3.dec.com>  <>     nickname, we're really still DIGITAL.)  <>



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

end of thread, other threads:[~1997-09-19  4:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-09-17  4:00 How the Alpha/OSF1 system call work ??? Chung-min Hung
1997-09-19  4:00 ` Eric Werme

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