1*09933581SWarner Losh#include <machine/asm.h> 2*09933581SWarner Losh 3*09933581SWarner Losh/* 4*09933581SWarner Losh * Emulate the Linux system call interface. The system call number is set in 5*09933581SWarner Losh * %r0, and %r3 -> %r8 have the 6 system call arguments. errno is returned 6*09933581SWarner Losh * as a negative value, but we use it more as a flag something went wrong 7*09933581SWarner Losh * rather than using its value. 8*09933581SWarner Losh * 9*09933581SWarner Losh * Return value in %r3. If it is positive or < -4096, it's a successful 10*09933581SWarner Losh * system call. If it is between -1 and -4095 then it's an failed system 11*09933581SWarner Losh * call with -x as the errno. Errors from the kernel are signaled via the 12*09933581SWarner Losh * the 'so' bit, but we don't test that here at all. There are at most 6 13*09933581SWarner Losh * arguments to system calls in Linux. 14*09933581SWarner Losh * 15*09933581SWarner Losh * We expose the raw system call result, rather than do the POSIX 16*09933581SWarner Losh * conversion to -1 and setting errno. 17*09933581SWarner Losh * 18*09933581SWarner Losh * Note: The code this replaced used bso to set %r3 to 0 for the read and 19*09933581SWarner Losh * open system calls for reasons that are still under investigation. 20*09933581SWarner Losh */ 21*09933581SWarner LoshENTRY(host_syscall) 22*09933581SWarner Losh mr %r0, %r3 /* SYS_ number in $r0 */ 23*09933581SWarner Losh mr %r3, %r4 /* arg2 -> 1 */ 24*09933581SWarner Losh mr %r4, %r5 /* arg3 -> 2 */ 25*09933581SWarner Losh mr %r5, %r6 /* arg4 -> 3 */ 26*09933581SWarner Losh mr %r6, %r7 /* arg5 -> 4 */ 27*09933581SWarner Losh mr %r7, %r8 /* arg6 -> 5 */ 28*09933581SWarner Losh mr %r8, %r9 /* arg7 -> 6 */ 29*09933581SWarner Losh sc 30*09933581SWarner Losh blr 31*09933581SWarner Losh/* Note: We're exposing the raw return value to the caller */ 32*09933581SWarner LoshEND(host_syscall) 33