URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [arch/] [parisc/] [hpux/] [wrappers.S] - Rev 1765
Compare with Previous | Blame | View Log
/** Linux/PARISC Project (http://www.parisc-linux.org/)** HP-UX System Call Wrapper routines and System Call Return Path** Copyright (C) 2000 Hewlett-Packard (John Marvin)** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License as published by* the Free Software Foundation; either version 2, or (at your option)* any later version.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* GNU General Public License for more details.** You should have received a copy of the GNU General Public License* along with this program; if not, write to the Free Software* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*/#ifdef __LP64__#warning Must be changed for PA64#endif#include <asm/offset.h>.level 1.1.text#include <asm/assembly.h>#include <asm/signal.h>/* These should probably go in a header file somewhere.* They are duplicated in kernel/wrappers.S* Possibly we should consider consolidating these* register save/restore macros.*/.macro reg_save regs#ifdef __LP64__#warning NEEDS WORK for 64-bit#endifstw %r3, PT_GR3(\regs)stw %r4, PT_GR4(\regs)stw %r5, PT_GR5(\regs)stw %r6, PT_GR6(\regs)stw %r7, PT_GR7(\regs)stw %r8, PT_GR8(\regs)stw %r9, PT_GR9(\regs)stw %r10,PT_GR10(\regs)stw %r11,PT_GR11(\regs)stw %r12,PT_GR12(\regs)stw %r13,PT_GR13(\regs)stw %r14,PT_GR14(\regs)stw %r15,PT_GR15(\regs)stw %r16,PT_GR16(\regs)stw %r17,PT_GR17(\regs)stw %r18,PT_GR18(\regs).endm.macro reg_restore regsldw PT_GR3(\regs), %r3ldw PT_GR4(\regs), %r4ldw PT_GR5(\regs), %r5ldw PT_GR6(\regs), %r6ldw PT_GR7(\regs), %r7ldw PT_GR8(\regs), %r8ldw PT_GR9(\regs), %r9ldw PT_GR10(\regs),%r10ldw PT_GR11(\regs),%r11ldw PT_GR12(\regs),%r12ldw PT_GR13(\regs),%r13ldw PT_GR14(\regs),%r14ldw PT_GR15(\regs),%r15ldw PT_GR16(\regs),%r16ldw PT_GR17(\regs),%r17ldw PT_GR18(\regs),%r18.endm.export hpux_fork_wrapper.export hpux_child_return.import sys_forkhpux_fork_wrapper:ldo TASK_REGS-TASK_SZ_ALGN-64(%r30),%r1 ;! get pt regs;! pointer in taskreg_save %r1stw %r2,-20(%r30)ldo 64(%r30),%r30stw %r2,PT_GR19(%r1) ;! save for childstw %r30,PT_GR21(%r1) ;! save for childldw PT_GR30(%r1),%r25mtctl %r25,%cr29copy %r1,%r24bl sys_clone,%r2ldi SIGCHLD,%r26ldw -84(%r30),%r2fork_return:ldo -64(%r30),%r30ldo TASK_REGS-TASK_SZ_ALGN-64(%r30),%r1 ;! get pt regsreg_restore %r1/** HP-UX wants pid (child gets parent pid, parent gets child pid)* in r28 and a flag in r29 (r29 == 1 for child, 0 for parent).* Linux fork returns 0 for child, pid for parent. Since HP-UX* libc stub throws away parent pid and returns 0 for child,* we'll just return 0 for parent pid now. Only applications* that jump directly to the gateway page (not supported) will* know the difference. We can fix this later if necessary.*/ldo -1024(%r0),%r1comb,>>=,n %r28,%r1,fork_exit /* just let the syscall exit handle it */or,= %r28,%r0,%r0or,tr %r0,%r0,%r29 /* r28 <> 0, we are parent, set r29 to 0 */ldo 1(%r0),%r29 /* r28 == 0, we are child, set r29 to 1 */fork_exit:bv %r0(%r2)nop/* Set the return value for the child */hpux_child_return:bl schedule_tail, %r2nopldw TASK_PT_GR19-TASK_SZ_ALGN-128(%r30),%r2b fork_returncopy %r0,%r28.export hpux_execve_wrapper.export hpux_execv_wrapper.import hpux_execvehpux_execv_wrapper:copy %r0,%r24 /* NULL environment */hpux_execve_wrapper:ldo TASK_REGS-TASK_SZ_ALGN-64(%r30),%r1 ;! get pt regs/** Do we need to save/restore r3-r18 here?* I don't think so. why would new thread need old* threads registers?*//* Store arg0, arg1 and arg2 so that hpux_execve will find them */stw %r26,PT_GR26(%r1)stw %r25,PT_GR25(%r1)stw %r24,PT_GR24(%r1)stw %r2,-20(%r30)ldo 64(%r30),%r30bl hpux_execve,%r2copy %r1,%arg0ldo -64(%r30),%r30ldw -20(%r30),%r2/* If exec succeeded we need to load the args */ldo -1024(%r0),%r1comb,>>= %r28,%r1,exec_errorcopy %r2,%r19ldo -TASK_SZ_ALGN-64(%r30),%r1 ;! get task ptrldw TASK_PT_GR26(%r1),%r26ldw TASK_PT_GR25(%r1),%r25ldw TASK_PT_GR24(%r1),%r24ldw TASK_PT_GR23(%r1),%r23copy %r0,%r2 /* Flag to syscall_exit not to clear args */exec_error:bv %r0(%r19)nop.export hpux_pipe_wrapper.import hpux_pipe/* HP-UX expects pipefd's returned in r28 & r29 */hpux_pipe_wrapper:stw %r2,-20(%r30)ldo 64(%r30),%r30bl hpux_pipe,%r2ldo -56(%r30),%r26 /* pass local array to hpux_pipe */ldo -1024(%r0),%r1comb,>>= %r28,%r1,pipe_exit /* let syscall exit handle it */ldw -84(%r30),%r2/* if success, load fd's from stack array */ldw -56(%r30),%r28ldw -52(%r30),%r29pipe_exit:bv %r0(%r2)ldo -64(%r30),%r30.export hpux_syscall_exit.import syscall_exithpux_syscall_exit:/*** HP-UX call return conventions:** if error:* r22 = 1* r28 = errno value* r29 = secondary return value* else* r22 = 0* r28 = return value* r29 = secondary return value** For now, we'll just check to see if r28 is < (unsigned long)-1024* (to handle addresses > 2 Gb) and if so set r22 to zero. If not,* we'll complement r28 and set r22 to 1. Wrappers will be* needed for syscalls that care about the secondary return value.* The wrapper may also need a way of avoiding the following code,* but we'll deal with that when it becomes necessary.*/ldo -1024(%r0),%r1comb,<< %r28,%r1,no_errorcopy %r0,%r22subi 0,%r28,%r28ldo 1(%r0),%r22no_error:b syscall_exitnop.export hpux_unimplemented_wrapper.import hpux_unimplementedhpux_unimplemented_wrapper:b hpux_unimplementedstw %r22,-64(%r30) /* overwrite arg8 with syscall number */
