...
Run Format

Text file src/syscall/asm_plan9_amd64.s

Documentation: syscall

     1// Copyright 2009 The Go Authors. All rights reserved.
     2// Use of this source code is governed by a BSD-style
     3// license that can be found in the LICENSE file.
     4
     5#include "textflag.h"
     6#include "funcdata.h"
     7
     8//
     9// System call support for Plan 9
    10//
    11
    12//func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err string)
    13//func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err string)
    14//func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
    15//func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
    16
    17#define SYS_ERRSTR 41	/* from zsysnum_plan9.go */
    18
    19TEXT	·Syscall(SB),NOSPLIT,$168-64
    20	NO_LOCAL_POINTERS
    21	CALL	runtime·entersyscall(SB)
    22	MOVQ	trap+0(FP), BP	// syscall entry
    23	// copy args down
    24	LEAQ	a1+8(FP), SI
    25	LEAQ	sysargs-160(SP), DI
    26	CLD
    27	MOVSQ
    28	MOVSQ
    29	MOVSQ
    30	SYSCALL
    31	MOVQ	AX, r1+32(FP)
    32	MOVQ	$0, r2+40(FP)
    33	CMPL	AX, $-1
    34	JNE	ok3
    35
    36	LEAQ	errbuf-128(SP), AX
    37	MOVQ	AX, sysargs-160(SP)
    38	MOVQ	$128, sysargs1-152(SP)
    39	MOVQ	$SYS_ERRSTR, BP
    40	SYSCALL
    41	CALL	runtime·exitsyscall(SB)
    42	MOVQ	sysargs-160(SP), AX
    43	MOVQ	AX, errbuf-168(SP)
    44	CALL	runtime·gostring(SB)
    45	LEAQ	str-160(SP), SI
    46	JMP	copyresult3
    47
    48ok3:
    49	CALL	runtime·exitsyscall(SB)
    50	LEAQ	·emptystring(SB), SI
    51
    52copyresult3:
    53	LEAQ	err+48(FP), DI
    54
    55	CLD
    56	MOVSQ
    57	MOVSQ
    58
    59	RET
    60
    61TEXT	·Syscall6(SB),NOSPLIT,$168-88
    62	NO_LOCAL_POINTERS
    63	CALL	runtime·entersyscall(SB)
    64	MOVQ	trap+0(FP), BP	// syscall entry
    65	// copy args down
    66	LEAQ	a1+8(FP), SI
    67	LEAQ	sysargs-160(SP), DI
    68	CLD
    69	MOVSQ
    70	MOVSQ
    71	MOVSQ
    72	MOVSQ
    73	MOVSQ
    74	MOVSQ
    75	SYSCALL
    76	MOVQ	AX, r1+56(FP)
    77	MOVQ	$0, r2+64(FP)
    78	CMPL	AX, $-1
    79	JNE	ok4
    80
    81	LEAQ	errbuf-128(SP), AX
    82	MOVQ	AX, sysargs-160(SP)
    83	MOVQ	$128, sysargs1-152(SP)
    84	MOVQ	$SYS_ERRSTR, BP
    85	SYSCALL
    86	CALL	runtime·exitsyscall(SB)
    87	MOVQ	sysargs-160(SP), AX
    88	MOVQ	AX, errbuf-168(SP)
    89	CALL	runtime·gostring(SB)
    90	LEAQ	str-160(SP), SI
    91	JMP	copyresult4
    92
    93ok4:
    94	CALL	runtime·exitsyscall(SB)
    95	LEAQ	·emptystring(SB), SI
    96
    97copyresult4:
    98	LEAQ	err+72(FP), DI
    99
   100	CLD
   101	MOVSQ
   102	MOVSQ
   103
   104	RET
   105
   106TEXT ·RawSyscall(SB),NOSPLIT,$0-56
   107	MOVQ	trap+0(FP), BP	// syscall entry
   108	// slide args down on top of system call number
   109	LEAQ	a1+8(FP), SI
   110	LEAQ	trap+0(FP), DI
   111	CLD
   112	MOVSQ
   113	MOVSQ
   114	MOVSQ
   115	SYSCALL
   116	MOVQ	AX, r1+32(FP)
   117	MOVQ	AX, r2+40(FP)
   118	MOVQ	AX, err+48(FP)
   119	RET
   120
   121TEXT	·RawSyscall6(SB),NOSPLIT,$0-80
   122	MOVQ	trap+0(FP), BP	// syscall entry
   123	// slide args down on top of system call number
   124	LEAQ	a1+8(FP), SI
   125	LEAQ	trap+0(FP), DI
   126	CLD
   127	MOVSQ
   128	MOVSQ
   129	MOVSQ
   130	MOVSQ
   131	MOVSQ
   132	MOVSQ
   133	SYSCALL
   134	MOVQ	AX, r1+56(FP)
   135	MOVQ	AX, r2+64(FP)
   136	MOVQ	AX, err+72(FP)
   137	RET
   138
   139#define SYS_SEEK 39	/* from zsysnum_plan9.go */
   140
   141//func seek(placeholder uintptr, fd int, offset int64, whence int) (newoffset int64, err string)
   142TEXT ·seek(SB),NOSPLIT,$48-56
   143	NO_LOCAL_POINTERS
   144	LEAQ	newoffset+32(FP), AX
   145	MOVQ	AX, placeholder+0(FP)
   146
   147	// copy args down
   148	LEAQ	placeholder+0(FP), SI
   149	LEAQ	sysargs-40(SP), DI
   150	CLD
   151	MOVSQ
   152	MOVSQ
   153	MOVSQ
   154	MOVSQ
   155	MOVSQ
   156	MOVQ	$SYS_SEEK, BP	// syscall entry
   157	SYSCALL
   158
   159	CMPL	AX, $-1
   160	JNE	ok6
   161	MOVQ	AX, newoffset+32(FP)
   162
   163	CALL	syscall·errstr(SB)
   164	MOVQ	SP, SI
   165	JMP	copyresult6
   166
   167ok6:
   168	LEAQ	·emptystring(SB), SI
   169
   170copyresult6:
   171	LEAQ	err+40(FP), DI
   172
   173	CLD
   174	MOVSQ
   175	MOVSQ
   176	RET

View as plain text