[parisc-linux] system calls

Matthew Wilcox willy@debian.org
Mon, 3 Sep 2001 05:16:40 +0100


On Mon, Sep 03, 2001 at 05:10:34AM +0100, Admin wrote:
> How does PA-RISC trap to the OS during syscalls.
> 
> x86 uses trapgates and long-jumps, sparc uses traps and MIPs uses jumps.
> 
> I'm wondering what the set of instructions are to initiate a system call.

we use a gateway page in a different space.  Here's glibc's implementation
of syscall:

int
syscall (int sysnum, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5)
{
  long __sys_res;
  {
    register unsigned long __res asm("r28");
    LOAD_ARGS_6(arg0, arg1, arg2, arg3, arg4, arg5)
      asm volatile ("ble  0x100(%%sr2, %%r0)\n\t"
                    "copy %1, %%r20"
                    : "=r" (__res)
                    : "r" (sysnum) ASM_ARGS_6);
    __sys_res = __res;
  }
  if ((unsigned long) __sys_res >= (unsigned long)-4095)
    {
    __set_errno(-__sys_res);
    __sys_res = -1;
  }
  return __sys_res;
}

if you're interested in discussion of what/how/why/etc, there's lots of
material in the mailing list archives going all the way back to 99.

-- 
Revolutions do not require corporate support.