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-05-15 14:47:53 -06:00
|
|
|
// TODO(rsc): Rewrite all nn(SP) references into name+(nn-8)(FP)
|
|
|
|
// so that go vet can check that they are correct.
|
|
|
|
|
2014-08-12 18:04:45 -06:00
|
|
|
#include "textflag.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
|
2014-09-11 22:23:03 -06:00
|
|
|
GO_ARGS
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·entersyscall(SB)
|
2009-06-04 14:33:40 -06:00
|
|
|
MOVL 4(SP), AX // syscall entry
|
|
|
|
MOVL 8(SP), BX
|
|
|
|
MOVL 12(SP), CX
|
|
|
|
MOVL 16(SP), 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 ok
|
|
|
|
MOVL $-1, 20(SP) // r1
|
|
|
|
MOVL $0, 24(SP) // r2
|
|
|
|
NEGL AX
|
|
|
|
MOVL AX, 28(SP) // errno
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·exitsyscall(SB)
|
2009-06-04 14:33:40 -06:00
|
|
|
RET
|
|
|
|
ok:
|
|
|
|
MOVL AX, 20(SP) // r1
|
|
|
|
MOVL DX, 24(SP) // r2
|
|
|
|
MOVL $0, 28(SP) // errno
|
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
|
2014-09-11 22:23:03 -06:00
|
|
|
GO_ARGS
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·entersyscall(SB)
|
2009-06-04 14:33:40 -06:00
|
|
|
MOVL 4(SP), AX // syscall entry
|
|
|
|
MOVL 8(SP), BX
|
|
|
|
MOVL 12(SP), CX
|
|
|
|
MOVL 16(SP), DX
|
|
|
|
MOVL 20(SP), SI
|
|
|
|
MOVL 24(SP), DI
|
2011-04-01 18:46:01 -06:00
|
|
|
MOVL 28(SP), 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
|
|
|
|
MOVL $-1, 32(SP) // r1
|
|
|
|
MOVL $0, 36(SP) // r2
|
|
|
|
NEGL AX
|
|
|
|
MOVL AX, 40(SP) // errno
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·exitsyscall(SB)
|
2009-06-04 14:33:40 -06:00
|
|
|
RET
|
|
|
|
ok6:
|
|
|
|
MOVL AX, 32(SP) // r1
|
|
|
|
MOVL DX, 36(SP) // r2
|
|
|
|
MOVL $0, 40(SP) // errno
|
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
|
2014-09-11 22:23:03 -06:00
|
|
|
GO_ARGS
|
2009-06-04 14:33:40 -06:00
|
|
|
MOVL 4(SP), AX // syscall entry
|
|
|
|
MOVL 8(SP), BX
|
|
|
|
MOVL 12(SP), CX
|
|
|
|
MOVL 16(SP), 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 ok1
|
|
|
|
MOVL $-1, 20(SP) // r1
|
|
|
|
MOVL $0, 24(SP) // r2
|
|
|
|
NEGL AX
|
|
|
|
MOVL AX, 28(SP) // errno
|
|
|
|
RET
|
|
|
|
ok1:
|
|
|
|
MOVL AX, 20(SP) // r1
|
|
|
|
MOVL DX, 24(SP) // r2
|
|
|
|
MOVL $0, 28(SP) // errno
|
|
|
|
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
|
2014-09-11 22:23:03 -06:00
|
|
|
GO_ARGS
|
2011-03-16 20:03:01 -06:00
|
|
|
MOVL 4(SP), AX // syscall entry
|
|
|
|
MOVL 8(SP), BX
|
|
|
|
MOVL 12(SP), CX
|
|
|
|
MOVL 16(SP), DX
|
|
|
|
MOVL 20(SP), SI
|
|
|
|
MOVL 24(SP), DI
|
2011-04-01 20:26:57 -06:00
|
|
|
MOVL 28(SP), 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
|
|
|
|
MOVL $-1, 32(SP) // r1
|
|
|
|
MOVL $0, 36(SP) // r2
|
|
|
|
NEGL AX
|
|
|
|
MOVL AX, 40(SP) // errno
|
|
|
|
RET
|
|
|
|
ok2:
|
|
|
|
MOVL AX, 32(SP) // r1
|
|
|
|
MOVL DX, 36(SP) // r2
|
|
|
|
MOVL $0, 40(SP) // errno
|
|
|
|
RET
|
|
|
|
|
2009-06-04 14:33:40 -06:00
|
|
|
#define SYS_SOCKETCALL 102 /* from zsysnum_linux_386.go */
|
|
|
|
|
|
|
|
// func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, errno int)
|
|
|
|
// 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
|
|
|
|
MOVL 4(SP), BX // socket call number
|
|
|
|
LEAL 8(SP), CX // pointer to call arguments
|
|
|
|
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
|
2009-06-16 18:17:02 -06:00
|
|
|
MOVL $-1, 32(SP) // n
|
2009-06-04 14:33:40 -06:00
|
|
|
NEGL AX
|
2009-06-16 18:17:02 -06:00
|
|
|
MOVL AX, 36(SP) // errno
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·exitsyscall(SB)
|
2009-06-04 14:33:40 -06:00
|
|
|
RET
|
|
|
|
oksock:
|
2009-06-16 18:17:02 -06:00
|
|
|
MOVL AX, 32(SP) // n
|
|
|
|
MOVL $0, 36(SP) // errno
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·exitsyscall(SB)
|
2009-06-16 18:17:02 -06:00
|
|
|
RET
|
|
|
|
|
2011-03-16 20:03:01 -06:00
|
|
|
// func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, errno int)
|
|
|
|
// 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
|
|
|
|
MOVL 4(SP), BX // socket call number
|
|
|
|
LEAL 8(SP), CX // pointer to call arguments
|
|
|
|
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
|
|
|
|
MOVL $-1, 32(SP) // n
|
|
|
|
NEGL AX
|
|
|
|
MOVL AX, 36(SP) // errno
|
|
|
|
RET
|
|
|
|
oksock1:
|
|
|
|
MOVL AX, 32(SP) // n
|
|
|
|
MOVL $0, 36(SP) // errno
|
|
|
|
RET
|
|
|
|
|
2009-06-16 18:17:02 -06:00
|
|
|
#define SYS__LLSEEK 140 /* from zsysnum_linux_386.go */
|
|
|
|
// func Seek(fd int, offset int64, whence int) (newoffset int64, errno int)
|
|
|
|
// 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
|
|
|
|
MOVL 4(SP), BX // fd
|
|
|
|
MOVL 12(SP), CX // offset-high
|
|
|
|
MOVL 8(SP), DX // offset-low
|
|
|
|
LEAL 20(SP), SI // result pointer
|
|
|
|
MOVL 16(SP), DI // whence
|
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
|
|
|
|
MOVL $-1, 20(SP) // newoffset low
|
|
|
|
MOVL $-1, 24(SP) // newoffset high
|
|
|
|
NEGL AX
|
|
|
|
MOVL AX, 28(SP) // errno
|
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
|
|
|
|
MOVL $0, 28(SP) // errno
|
2009-10-16 00:10:49 -06:00
|
|
|
CALL runtime·exitsyscall(SB)
|
2009-06-04 14:33:40 -06:00
|
|
|
RET
|