/*1* Linux/PARISC Project (http://www.parisc-linux.org/)2*3* HP-UX System Call Wrapper routines and System Call Return Path4*5* Copyright (C) 2000 Hewlett-Packard (John Marvin)6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License as published by9* the Free Software Foundation; either version 2, or (at your option)10* any later version.11*12* This program is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15* GNU General Public License for more details.16*17* You should have received a copy of the GNU General Public License18* along with this program; if not, write to the Free Software19* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.20*/2122#ifdef CONFIG_64BIT23#warning PA64 support needs more work...did first cut24#endif2526#include <asm/asm-offsets.h>27#include <asm/assembly.h>28#include <asm/signal.h>29#include <linux/linkage.h>3031.level LEVEL32.text3334/* These should probably go in a header file somewhere.35* They are duplicated in kernel/wrappers.S36* Possibly we should consider consolidating these37* register save/restore macros.38*/39.macro reg_save regs40#ifdef CONFIG_64BIT41#warning NEEDS WORK for 64-bit42#endif43STREG %r3, PT_GR3(\regs)44STREG %r4, PT_GR4(\regs)45STREG %r5, PT_GR5(\regs)46STREG %r6, PT_GR6(\regs)47STREG %r7, PT_GR7(\regs)48STREG %r8, PT_GR8(\regs)49STREG %r9, PT_GR9(\regs)50STREG %r10,PT_GR10(\regs)51STREG %r11,PT_GR11(\regs)52STREG %r12,PT_GR12(\regs)53STREG %r13,PT_GR13(\regs)54STREG %r14,PT_GR14(\regs)55STREG %r15,PT_GR15(\regs)56STREG %r16,PT_GR16(\regs)57STREG %r17,PT_GR17(\regs)58STREG %r18,PT_GR18(\regs)59.endm6061.macro reg_restore regs62LDREG PT_GR3(\regs), %r363LDREG PT_GR4(\regs), %r464LDREG PT_GR5(\regs), %r565LDREG PT_GR6(\regs), %r666LDREG PT_GR7(\regs), %r767LDREG PT_GR8(\regs), %r868LDREG PT_GR9(\regs), %r969LDREG PT_GR10(\regs),%r1070LDREG PT_GR11(\regs),%r1171LDREG PT_GR12(\regs),%r1272LDREG PT_GR13(\regs),%r1373LDREG PT_GR14(\regs),%r1474LDREG PT_GR15(\regs),%r1575LDREG PT_GR16(\regs),%r1676LDREG PT_GR17(\regs),%r1777LDREG PT_GR18(\regs),%r1878.endm798081.import sys_fork8283ENTRY(hpux_fork_wrapper)84ldo TASK_REGS-TASK_SZ_ALGN-64(%r30),%r1 ;! get pt regs85;! pointer in task86reg_save %r18788STREG %r2,-20(%r30)89ldo 64(%r30),%r3090STREG %r2,PT_GR19(%r1) ;! save for child91STREG %r30,PT_GR21(%r1) ;! save for child9293LDREG PT_GR30(%r1),%r2594mtctl %r25,%cr2995copy %r1,%r2496bl sys_clone,%r297ldi SIGCHLD,%r269899LDREG -84(%r30),%r2100fork_return:101ldo -64(%r30),%r30102ldo TASK_REGS-TASK_SZ_ALGN-64(%r30),%r1 ;! get pt regs103104reg_restore %r1105106/*107* HP-UX wants pid (child gets parent pid, parent gets child pid)108* in r28 and a flag in r29 (r29 == 1 for child, 0 for parent).109* Linux fork returns 0 for child, pid for parent. Since HP-UX110* libc stub throws away parent pid and returns 0 for child,111* we'll just return 0 for parent pid now. Only applications112* that jump directly to the gateway page (not supported) will113* know the difference. We can fix this later if necessary.114*/115116ldo -1024(%r0),%r1117comb,>>=,n %r28,%r1,fork_exit /* just let the syscall exit handle it */118or,= %r28,%r0,%r0119or,tr %r0,%r0,%r29 /* r28 <> 0, we are parent, set r29 to 0 */120ldo 1(%r0),%r29 /* r28 == 0, we are child, set r29 to 1 */121122fork_exit:123bv %r0(%r2)124nop125ENDPROC(hpux_fork_wrapper)126127/* Set the return value for the child */128129ENTRY(hpux_child_return)130#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)131bl,n schedule_tail, %r2132#endif133134LDREG TASK_PT_GR19-TASK_SZ_ALGN-128(%r30),%r2135b fork_return136copy %r0,%r28137ENDPROC(hpux_child_return)138139.import hpux_execve140141ENTRY(hpux_execv_wrapper)142copy %r0,%r24 /* NULL environment */143144ENTRY(hpux_execve_wrapper)145146ldo TASK_REGS-TASK_SZ_ALGN-64(%r30),%r1 ;! get pt regs147148/*149* Do we need to save/restore r3-r18 here?150* I don't think so. why would new thread need old151* threads registers?152*/153154/* Store arg0, arg1 and arg2 so that hpux_execve will find them */155156STREG %r26,PT_GR26(%r1)157STREG %r25,PT_GR25(%r1)158STREG %r24,PT_GR24(%r1)159160STREG %r2,-20(%r30)161ldo 64(%r30),%r30162bl hpux_execve,%r2163copy %r1,%arg0164165ldo -64(%r30),%r30166LDREG -20(%r30),%r2167168/* If exec succeeded we need to load the args */169170ldo -1024(%r0),%r1171comb,>>= %r28,%r1,exec_error172copy %r2,%r19173ldo -TASK_SZ_ALGN-64(%r30),%r1 ;! get task ptr174LDREG TASK_PT_GR26(%r1),%r26175LDREG TASK_PT_GR25(%r1),%r25176LDREG TASK_PT_GR24(%r1),%r24177LDREG TASK_PT_GR23(%r1),%r23178copy %r0,%r2 /* Flag to syscall_exit not to clear args */179180exec_error:181bv %r0(%r19)182nop183ENDPROC(hpux_execv_wrapper)184185.import hpux_pipe186187/* HP-UX expects pipefd's returned in r28 & r29 */188189ENTRY(hpux_pipe_wrapper)190STREG %r2,-20(%r30)191ldo 64(%r30),%r30192bl hpux_pipe,%r2193ldo -56(%r30),%r26 /* pass local array to hpux_pipe */194195196ldo -1024(%r0),%r1197comb,>>= %r28,%r1,pipe_exit /* let syscall exit handle it */198LDREG -84(%r30),%r2199200/* if success, load fd's from stack array */201202LDREG -56(%r30),%r28203LDREG -52(%r30),%r29204205pipe_exit:206bv %r0(%r2)207ldo -64(%r30),%r30208ENDPROC(hpux_pipe_wrapper)209210.import syscall_exit211212ENTRY(hpux_syscall_exit)213/*214*215* HP-UX call return conventions:216*217* if error:218* r22 = 1219* r28 = errno value220* r29 = secondary return value221* else222* r22 = 0223* r28 = return value224* r29 = secondary return value225*226* For now, we'll just check to see if r28 is < (unsigned long)-1024227* (to handle addresses > 2 Gb) and if so set r22 to zero. If not,228* we'll complement r28 and set r22 to 1. Wrappers will be229* needed for syscalls that care about the secondary return value.230* The wrapper may also need a way of avoiding the following code,231* but we'll deal with that when it becomes necessary.232*/233234ldo -1024(%r0),%r1235comb,<< %r28,%r1,no_error236copy %r0,%r22237subi 0,%r28,%r28238ldo 1(%r0),%r22239240no_error:241b,n syscall_exit242ENDPROC(hpux_syscall_exit)243244.import hpux_unimplemented245246ENTRY(hpux_unimplemented_wrapper)247b hpux_unimplemented248STREG %r22,-64(%r30) /* overwrite arg8 with syscall number */249ENDPROC(hpux_unimplemented_wrapper)250251252