Commit ba5045e1 authored by Rob Pike's avatar Rob Pike

go.sys/plan9: just jump to syscall.Syscall etc.

Don't re-implement these functions.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/124350045
parent 4faa336c
......@@ -2,163 +2,29 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// TODO(rsc): Rewrite all nn(SP) references into name+(nn-8)(FP)
// so that go vet can check that they are correct.
#include "textflag.h"
//
// System call support for 386, Plan 9
//
//func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err string)
//func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err string)
//func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
//func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
// Just jump to package syscall's implementation for all these functions.
// The runtime may know about them.
// Trap # in AX, args on stack above caller pc.
TEXT ·Syscall(SB),NOSPLIT,$0-32
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
LEAL 4(SP), DI
CLD
MOVSL
MOVSL
MOVSL
INT $64
MOVL AX, r1+20(SP)
MOVL $0, r2+24(SP)
CMPL AX, $-1
JNE ok3
SUBL $8, SP
CALL runtime·errstr(SB)
MOVL SP, SI
ADDL $8, SP
JMP copyresult3
ok3:
LEAL runtime·emptystring(SB), SI
copyresult3:
LEAL err+28(SP), DI
CLD
MOVSL
MOVSL
CALL runtime·exitsyscall(SB)
RET
JMP syscall·Syscall(SB)
TEXT ·Syscall6(SB),NOSPLIT,$0-44
CALL runtime·entersyscall(SB)
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
LEAL 4(SP), DI
CLD
MOVSL
MOVSL
MOVSL
MOVSL
MOVSL
MOVSL
INT $64
MOVL AX, r1+32(SP)
MOVL $0, r2+36(SP)
CMPL AX, $-1
JNE ok4
SUBL $8, SP
CALL runtime·errstr(SB)
MOVL SP, SI
ADDL $8, SP
JMP copyresult4
ok4:
LEAL runtime·emptystring(SB), SI
copyresult4:
LEAL err+40(SP), DI
CLD
MOVSL
MOVSL
CALL runtime·exitsyscall(SB)
RET
JMP syscall·Syscall6(SB)
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
LEAL 4(SP), DI
CLD
MOVSL
MOVSL
MOVSL
INT $64
MOVL AX, r1+20(SP)
MOVL AX, r2+24(SP)
MOVL AX, err+28(SP)
RET
JMP syscall·RawSyscall(SB)
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
MOVL 4(SP), AX // syscall entry
// slide args down on top of system call number
LEAL 8(SP), SI
LEAL 4(SP), DI
CLD
MOVSL
MOVSL
MOVSL
MOVSL
MOVSL
MOVSL
INT $64
MOVL AX, r1+32(SP)
MOVL AX, r2+36(SP)
MOVL AX, err+40(SP)
RET
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
JMP syscall·RawSyscall6(SB)
#define SYS_SEEK 39 /* from zsysnum_plan9_386.go */
//func seek(placeholder uintptr, fd int, offset int64, whence int) (newoffset int64, err string)
TEXT ·seek(SB),NOSPLIT,$0-36
LEAL newoffset+24(SP), AX
MOVL AX, placeholder+4(SP)
MOVL $SYS_SEEK, AX // syscall entry
INT $64
CMPL AX, $-1
JNE ok6
MOVL AX, 24(SP) // newoffset low
MOVL AX, 28(SP) // newoffset high
SUBL $8, SP
CALL plan9·errstr(SB)
MOVL SP, SI
ADDL $8, SP
JMP copyresult6
ok6:
LEAL runtime·emptystring(SB), SI
copyresult6:
LEAL err+32(SP), DI
CLD
MOVSL
MOVSL
RET
JMP syscall·seek(SB)
//func exit(code int)
// Import runtime·exit for cleanly exiting.
TEXT ·exit(SB),NOSPLIT,$4-4
MOVL code+0(FP), AX
MOVL AX, 0(SP)
CALL runtime·exit(SB)
RET
JMP syscall·exit(SB)
......@@ -2,161 +2,29 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// TODO(rsc): Rewrite all nn(SP) references into name+(nn-8)(FP)
// so that go vet can check that they are correct.
#include "textflag.h"
//
// System call support for Plan 9
// System call support for amd64, Plan 9
//
//func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err string)
//func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err string)
//func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
//func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
// Just jump to package syscall's implementation for all these functions.
// The runtime may know about them.
TEXT ·Syscall(SB),NOSPLIT,$0-64
CALL runtime·entersyscall(SB)
MOVQ 8(SP), BP // syscall entry
// slide args down on top of system call number
LEAQ 16(SP), SI
LEAQ 8(SP), DI
CLD
MOVSQ
MOVSQ
MOVSQ
SYSCALL
MOVQ AX, r1+40(SP)
MOVQ $0, r2+48(SP)
CMPL AX, $-1
JNE ok3
SUBQ $16, SP
CALL runtime·errstr(SB)
MOVQ SP, SI
ADDQ $16, SP
JMP copyresult3
ok3:
LEAQ runtime·emptystring(SB), SI
copyresult3:
LEAQ err+56(SP), DI
CLD
MOVSQ
MOVSQ
CALL runtime·exitsyscall(SB)
RET
JMP syscall·Syscall(SB)
TEXT ·Syscall6(SB),NOSPLIT,$0-88
CALL runtime·entersyscall(SB)
MOVQ 8(SP), BP // syscall entry
// slide args down on top of system call number
LEAQ 16(SP), SI
LEAQ 8(SP), DI
CLD
MOVSQ
MOVSQ
MOVSQ
MOVSQ
MOVSQ
MOVSQ
SYSCALL
MOVQ AX, r1+64(SP)
MOVQ $0, r2+72(SP)
CMPL AX, $-1
JNE ok4
SUBQ $16, SP
CALL runtime·errstr(SB)
MOVQ SP, SI
ADDQ $16, SP
JMP copyresult4
ok4:
LEAQ runtime·emptystring(SB), SI
copyresult4:
LEAQ err+80(SP), DI
CLD
MOVSQ
MOVSQ
CALL runtime·exitsyscall(SB)
RET
JMP syscall·Syscall6(SB)
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
MOVQ 8(SP), BP // syscall entry
// slide args down on top of system call number
LEAQ 16(SP), SI
LEAQ 8(SP), DI
CLD
MOVSQ
MOVSQ
MOVSQ
SYSCALL
MOVQ AX, r1+40(SP)
MOVQ AX, r2+48(SP)
MOVQ AX, err+56(SP)
RET
JMP syscall·RawSyscall(SB)
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
MOVQ 8(SP), BP // syscall entry
// slide args down on top of system call number
LEAQ 16(SP), SI
LEAQ 8(SP), DI
CLD
MOVSQ
MOVSQ
MOVSQ
MOVSQ
MOVSQ
MOVSQ
SYSCALL
MOVQ AX, r1+64(SP)
MOVQ AX, r2+72(SP)
MOVQ AX, err+80(SP)
RET
JMP syscall·RawSyscall6(SB)
#define SYS_SEEK 39 /* from zsysnum_plan9_amd64.go */
//func seek(placeholder uintptr, fd int, offset int64, whence int) (newoffset int64, err string)
TEXT ·seek(SB),NOSPLIT,$0-56
LEAQ newoffset+40(SP), AX
MOVQ AX, placeholder+8(SP)
MOVQ $SYS_SEEK, BP // syscall entry
SYSCALL
CMPL AX, $-1
JNE ok6
MOVQ $-1, newoffset+40(SP)
SUBQ $16, SP
CALL plan9·errstr(SB)
MOVQ SP, SI
ADDQ $16, SP
JMP copyresult6
ok6:
LEAQ runtime·emptystring(SB), SI
copyresult6:
LEAQ err+48(SP), DI
CLD
MOVSQ
MOVSQ
RET
JMP syscall·seek(SB)
//func exit(code int)
// Import runtime·exit for cleanly exiting.
TEXT ·exit(SB),NOSPLIT,$8-8
MOVQ code+0(FP), AX
MOVQ AX, 0(SP)
CALL runtime·exit(SB)
RET
JMP syscall·exit(SB)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment