2009-06-04 14:33:40 -06:00
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2014-08-12 18:04:45 -06:00
|
|
|
#include "textflag.h"
|
2014-09-11 22:55:24 -06:00
|
|
|
#include "funcdata.h"
|
2013-08-12 11:24:30 -06:00
|
|
|
|
2009-06-04 14:33:40 -06:00
|
|
|
//
|
|
|
|
// System calls for 386, Linux
|
|
|
|
//
|
|
|
|
|
2009-06-16 18:17:02 -06:00
|
|
|
// func Syscall(trap uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr);
|
2009-06-04 14:33:40 -06:00
|
|
|
// Trap # in AX, args in BX CX DX SI DI, return in AX
|
|
|
|
|
2014-05-15 14:47:53 -06:00
|
|
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·entersyscall(SB)
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL trap+0(FP), AX // syscall entry
|
|
|
|
MOVL a1+4(FP), BX
|
|
|
|
MOVL a2+8(FP), CX
|
|
|
|
MOVL a3+12(FP), DX
|
2009-06-04 14:33:40 -06:00
|
|
|
MOVL $0, SI
|
|
|
|
MOVL $0, DI
|
2011-08-29 08:36:06 -06:00
|
|
|
CALL *runtime·_vdso(SB)
|
2009-06-04 14:33:40 -06:00
|
|
|
CMPL AX, $0xfffff001
|
|
|
|
JLS ok
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL $-1, r1+16(FP)
|
|
|
|
MOVL $0, r2+20(FP)
|
2009-06-04 14:33:40 -06:00
|
|
|
NEGL AX
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL AX, err+24(FP)
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·exitsyscall(SB)
|
2009-06-04 14:33:40 -06:00
|
|
|
RET
|
|
|
|
ok:
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL AX, r1+16(FP)
|
|
|
|
MOVL DX, r2+20(FP)
|
|
|
|
MOVL $0, err+24(FP)
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·exitsyscall(SB)
|
2009-06-04 14:33:40 -06:00
|
|
|
RET
|
|
|
|
|
2009-06-16 18:17:02 -06:00
|
|
|
// func Syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
|
2014-05-15 14:47:53 -06:00
|
|
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·entersyscall(SB)
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL trap+0(FP), AX // syscall entry
|
|
|
|
MOVL a1+4(FP), BX
|
|
|
|
MOVL a2+8(FP), CX
|
|
|
|
MOVL a3+12(FP), DX
|
|
|
|
MOVL a4+16(FP), SI
|
|
|
|
MOVL a5+20(FP), DI
|
|
|
|
MOVL a6+24(FP), BP
|
2011-08-29 08:36:06 -06:00
|
|
|
CALL *runtime·_vdso(SB)
|
2009-06-04 14:33:40 -06:00
|
|
|
CMPL AX, $0xfffff001
|
|
|
|
JLS ok6
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL $-1, r1+28(FP)
|
|
|
|
MOVL $0, r2+32(FP)
|
2009-06-04 14:33:40 -06:00
|
|
|
NEGL AX
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL AX, err+36(FP)
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·exitsyscall(SB)
|
2009-06-04 14:33:40 -06:00
|
|
|
RET
|
|
|
|
ok6:
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL AX, r1+28(FP)
|
|
|
|
MOVL DX, r2+32(FP)
|
|
|
|
MOVL $0, err+36(FP)
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·exitsyscall(SB)
|
2009-06-04 14:33:40 -06:00
|
|
|
RET
|
|
|
|
|
2009-06-16 18:17:02 -06:00
|
|
|
// func RawSyscall(trap uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr);
|
2014-05-15 14:47:53 -06:00
|
|
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL trap+0(FP), AX // syscall entry
|
|
|
|
MOVL a1+4(FP), BX
|
|
|
|
MOVL a2+8(FP), CX
|
|
|
|
MOVL a3+12(FP), DX
|
2009-06-04 14:33:40 -06:00
|
|
|
MOVL $0, SI
|
|
|
|
MOVL $0, DI
|
2011-08-29 08:36:06 -06:00
|
|
|
CALL *runtime·_vdso(SB)
|
2009-06-04 14:33:40 -06:00
|
|
|
CMPL AX, $0xfffff001
|
|
|
|
JLS ok1
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL $-1, r1+16(FP)
|
|
|
|
MOVL $0, r2+20(FP)
|
2009-06-04 14:33:40 -06:00
|
|
|
NEGL AX
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL AX, err+24(FP)
|
2009-06-04 14:33:40 -06:00
|
|
|
RET
|
|
|
|
ok1:
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL AX, r1+16(FP)
|
|
|
|
MOVL DX, r2+20(FP)
|
|
|
|
MOVL $0, err+24(FP)
|
2009-06-04 14:33:40 -06:00
|
|
|
RET
|
|
|
|
|
2011-03-16 20:03:01 -06:00
|
|
|
// func RawSyscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
|
2014-05-15 14:47:53 -06:00
|
|
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL trap+0(FP), AX // syscall entry
|
|
|
|
MOVL a1+4(FP), BX
|
|
|
|
MOVL a2+8(FP), CX
|
|
|
|
MOVL a3+12(FP), DX
|
|
|
|
MOVL a4+16(FP), SI
|
|
|
|
MOVL a5+20(FP), DI
|
|
|
|
MOVL a6+24(FP), BP
|
2011-08-29 08:36:06 -06:00
|
|
|
CALL *runtime·_vdso(SB)
|
2011-03-16 20:03:01 -06:00
|
|
|
CMPL AX, $0xfffff001
|
|
|
|
JLS ok2
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL $-1, r1+28(FP)
|
|
|
|
MOVL $0, r2+32(FP)
|
2011-03-16 20:03:01 -06:00
|
|
|
NEGL AX
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL AX, err+36(FP)
|
2011-03-16 20:03:01 -06:00
|
|
|
RET
|
|
|
|
ok2:
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL AX, r1+28(FP)
|
|
|
|
MOVL DX, r2+32(FP)
|
|
|
|
MOVL $0, err+36(FP)
|
2011-03-16 20:03:01 -06:00
|
|
|
RET
|
|
|
|
|
2009-06-04 14:33:40 -06:00
|
|
|
#define SYS_SOCKETCALL 102 /* from zsysnum_linux_386.go */
|
|
|
|
|
2015-01-14 12:39:41 -07:00
|
|
|
// func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err int)
|
2009-06-04 14:33:40 -06:00
|
|
|
// Kernel interface gets call sub-number and pointer to a0.
|
2014-05-15 14:47:53 -06:00
|
|
|
TEXT ·socketcall(SB),NOSPLIT,$0-36
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·entersyscall(SB)
|
2009-06-04 14:33:40 -06:00
|
|
|
MOVL $SYS_SOCKETCALL, AX // syscall entry
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL call+0(FP), BX // socket call number
|
|
|
|
LEAL a0+4(FP), CX // pointer to call arguments
|
2009-06-04 14:33:40 -06:00
|
|
|
MOVL $0, DX
|
|
|
|
MOVL $0, SI
|
|
|
|
MOVL $0, DI
|
2011-08-29 08:36:06 -06:00
|
|
|
CALL *runtime·_vdso(SB)
|
2009-06-04 14:33:40 -06:00
|
|
|
CMPL AX, $0xfffff001
|
|
|
|
JLS oksock
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL $-1, n+28(FP)
|
2009-06-04 14:33:40 -06:00
|
|
|
NEGL AX
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL AX, err+32(FP)
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·exitsyscall(SB)
|
2009-06-04 14:33:40 -06:00
|
|
|
RET
|
|
|
|
oksock:
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL AX, n+28(FP)
|
|
|
|
MOVL $0, err+32(FP)
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·exitsyscall(SB)
|
2009-06-16 18:17:02 -06:00
|
|
|
RET
|
|
|
|
|
2015-01-14 12:39:41 -07:00
|
|
|
// func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err int)
|
2011-03-16 20:03:01 -06:00
|
|
|
// Kernel interface gets call sub-number and pointer to a0.
|
2014-05-15 14:47:53 -06:00
|
|
|
TEXT ·rawsocketcall(SB),NOSPLIT,$0-36
|
2011-03-16 20:03:01 -06:00
|
|
|
MOVL $SYS_SOCKETCALL, AX // syscall entry
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL call+0(FP), BX // socket call number
|
|
|
|
LEAL a0+4(FP), CX // pointer to call arguments
|
2011-03-16 20:03:01 -06:00
|
|
|
MOVL $0, DX
|
|
|
|
MOVL $0, SI
|
|
|
|
MOVL $0, DI
|
2011-08-29 08:36:06 -06:00
|
|
|
CALL *runtime·_vdso(SB)
|
2011-03-16 20:03:01 -06:00
|
|
|
CMPL AX, $0xfffff001
|
|
|
|
JLS oksock1
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL $-1, n+28(FP)
|
2011-03-16 20:03:01 -06:00
|
|
|
NEGL AX
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL AX, err+32(FP)
|
2011-03-16 20:03:01 -06:00
|
|
|
RET
|
|
|
|
oksock1:
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL AX, n+28(FP)
|
|
|
|
MOVL $0, err+32(FP)
|
2011-03-16 20:03:01 -06:00
|
|
|
RET
|
|
|
|
|
2009-06-16 18:17:02 -06:00
|
|
|
#define SYS__LLSEEK 140 /* from zsysnum_linux_386.go */
|
2015-01-14 12:39:41 -07:00
|
|
|
// func Seek(fd int, offset int64, whence int) (newoffset int64, err int)
|
2009-06-16 18:17:02 -06:00
|
|
|
// Implemented in assembly to avoid allocation when
|
|
|
|
// taking the address of the return value newoffset.
|
|
|
|
// Underlying system call is
|
|
|
|
// llseek(int fd, int offhi, int offlo, int64 *result, int whence)
|
2014-05-16 10:15:32 -06:00
|
|
|
TEXT ·seek(SB),NOSPLIT,$0-28
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·entersyscall(SB)
|
2009-06-16 18:17:02 -06:00
|
|
|
MOVL $SYS__LLSEEK, AX // syscall entry
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL fd+0(FP), BX
|
|
|
|
MOVL offset_hi+8(FP), CX
|
|
|
|
MOVL offset_lo+4(FP), DX
|
|
|
|
LEAL newoffset_lo+16(FP), SI // result pointer
|
|
|
|
MOVL whence+12(FP), DI
|
2011-08-29 08:36:06 -06:00
|
|
|
CALL *runtime·_vdso(SB)
|
2009-06-16 18:17:02 -06:00
|
|
|
CMPL AX, $0xfffff001
|
|
|
|
JLS okseek
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL $-1, newoffset_lo+16(FP)
|
|
|
|
MOVL $-1, newoffset_hi+20(FP)
|
2009-06-16 18:17:02 -06:00
|
|
|
NEGL AX
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL AX, err+24(FP)
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·exitsyscall(SB)
|
2009-06-16 18:17:02 -06:00
|
|
|
RET
|
|
|
|
okseek:
|
|
|
|
// system call filled in newoffset already
|
2015-01-14 12:39:41 -07:00
|
|
|
MOVL $0, err+24(FP)
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·exitsyscall(SB)
|
2009-06-04 14:33:40 -06:00
|
|
|
RET
|