...
Run Format

Text file src/syscall/asm_linux_arm.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 calls for arm, Linux
    10	//
    11	
    12	// func Syscall(syscall uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr);
    13	TEXT ·Syscall(SB),NOSPLIT,$0-28
    14		BL	runtime·entersyscall(SB)
    15		MOVW	trap+0(FP), R7
    16		MOVW	a1+4(FP), R0
    17		MOVW	a2+8(FP), R1
    18		MOVW	a3+12(FP), R2
    19		MOVW	$0, R3
    20		MOVW	$0, R4
    21		MOVW	$0, R5
    22		SWI	$0
    23		MOVW	$0xfffff001, R1
    24		CMP	R1, R0
    25		BLS	ok
    26		MOVW	$-1, R1
    27		MOVW	R1, r1+16(FP)
    28		MOVW	$0, R2
    29		MOVW	R2, r2+20(FP)
    30		RSB	$0, R0, R0
    31		MOVW	R0, err+24(FP)
    32		BL	runtime·exitsyscall(SB)
    33		RET
    34	ok:
    35		MOVW	R0, r1+16(FP)
    36		MOVW	$0, R0
    37		MOVW	R0, r2+20(FP)
    38		MOVW	R0, err+24(FP)
    39		BL	runtime·exitsyscall(SB)
    40		RET
    41	
    42	// func Syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
    43	// Actually Syscall5 but the rest of the code expects it to be named Syscall6.
    44	TEXT ·Syscall6(SB),NOSPLIT,$0-40
    45		BL	runtime·entersyscall(SB)
    46		MOVW	trap+0(FP), R7	// syscall entry
    47		MOVW	a1+4(FP), R0
    48		MOVW	a2+8(FP), R1
    49		MOVW	a3+12(FP), R2
    50		MOVW	a4+16(FP), R3
    51		MOVW	a5+20(FP), R4
    52		MOVW	a6+24(FP), R5
    53		SWI	$0
    54		MOVW	$0xfffff001, R6
    55		CMP	R6, R0
    56		BLS	ok6
    57		MOVW	$-1, R1
    58		MOVW	R1, r1+28(FP)
    59		MOVW	$0, R2
    60		MOVW	R2, r2+32(FP)
    61		RSB	$0, R0, R0
    62		MOVW	R0, err+36(FP)
    63		BL	runtime·exitsyscall(SB)
    64		RET
    65	ok6:
    66		MOVW	R0, r1+28(FP)
    67		MOVW	R1, r2+32(FP)
    68		MOVW	$0, R0
    69		MOVW	R0, err+36(FP)
    70		BL	runtime·exitsyscall(SB)
    71		RET
    72	
    73	// func RawSyscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
    74	// Actually RawSyscall5 but the rest of the code expects it to be named RawSyscall6.
    75	TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
    76		MOVW	trap+0(FP), R7	// syscall entry
    77		MOVW	a1+4(FP), R0
    78		MOVW	a2+8(FP), R1
    79		MOVW	a3+12(FP), R2
    80		MOVW	a4+16(FP), R3
    81		MOVW	a5+20(FP), R4
    82		MOVW	a6+24(FP), R5
    83		SWI	$0
    84		MOVW	$0xfffff001, R6
    85		CMP	R6, R0
    86		BLS	ok2
    87		MOVW	$-1, R1
    88		MOVW	R1, r1+28(FP)
    89		MOVW	$0, R2
    90		MOVW	R2, r2+32(FP)
    91		RSB	$0, R0, R0
    92		MOVW	R0, err+36(FP)
    93		RET
    94	ok2:
    95		MOVW	R0, r1+28(FP)
    96		MOVW	R1, r2+32(FP)
    97		MOVW	$0, R0
    98		MOVW	R0, err+36(FP)
    99		RET
   100	
   101	#define SYS__LLSEEK 140  /* from zsysnum_linux_arm.go */
   102	// func seek(fd int, offset int64, whence int) (newoffset int64, errno int)
   103	// Implemented in assembly to avoid allocation when
   104	// taking the address of the return value newoffset.
   105	// Underlying system call is
   106	//	llseek(int fd, int offhi, int offlo, int64 *result, int whence)
   107	TEXT ·seek(SB),NOSPLIT,$0-28
   108		BL	runtime·entersyscall(SB)
   109		MOVW	$SYS__LLSEEK, R7	// syscall entry
   110		MOVW	fd+0(FP), R0
   111		MOVW	offset_hi+8(FP), R1
   112		MOVW	offset_lo+4(FP), R2
   113		MOVW	$newoffset_lo+16(FP), R3
   114		MOVW	whence+12(FP), R4
   115		SWI	$0
   116		MOVW	$0xfffff001, R6
   117		CMP	R6, R0
   118		BLS	okseek
   119		MOVW	$0, R1
   120		MOVW	R1, newoffset_lo+16(FP)
   121		MOVW	R1, newoffset_hi+20(FP)
   122		RSB	$0, R0, R0
   123		MOVW	R0, err+24(FP)
   124		BL	runtime·exitsyscall(SB)
   125		RET
   126	okseek:
   127		// system call filled in newoffset already
   128		MOVW	$0, R0
   129		MOVW	R0, err+24(FP)
   130		BL	runtime·exitsyscall(SB)
   131		RET
   132	
   133	// func RawSyscall(trap uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr);
   134	TEXT ·RawSyscall(SB),NOSPLIT,$0-28
   135		MOVW	trap+0(FP), R7	// syscall entry
   136		MOVW	a1+4(FP), R0
   137		MOVW	a2+8(FP), R1
   138		MOVW	a3+12(FP), R2
   139		SWI	$0
   140		MOVW	$0xfffff001, R1
   141		CMP	R1, R0
   142		BLS	ok1
   143		MOVW	$-1, R1
   144		MOVW	R1, r1+16(FP)
   145		MOVW	$0, R2
   146		MOVW	R2, r2+20(FP)
   147		RSB	$0, R0, R0
   148		MOVW	R0, err+24(FP)
   149		RET
   150	ok1:
   151		MOVW	R0, r1+16(FP)
   152		MOVW	$0, R0
   153		MOVW	R0, r2+20(FP)
   154		MOVW	R0, err+24(FP)
   155		RET
   156	
   157	// func rawSyscallNoError(trap uintptr, a1, a2, a3 uintptr) (r1, r2 uintptr);
   158	TEXT ·rawSyscallNoError(SB),NOSPLIT,$0-24
   159		MOVW	trap+0(FP), R7	// syscall entry
   160		MOVW	a1+4(FP), R0
   161		MOVW	a2+8(FP), R1
   162		MOVW	a3+12(FP), R2
   163		SWI	$0
   164		MOVW	R0, r1+16(FP)
   165		MOVW	$0, R0
   166		MOVW	R0, r2+20(FP)
   167		RET

View as plain text