...
Run Format

Text file src/runtime/sys_plan9_amd64.s

Documentation: runtime

     1	// Copyright 2010 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 "go_asm.h"
     6	#include "go_tls.h"
     7	#include "textflag.h"
     8	
     9	// setldt(int entry, int address, int limit)
    10	TEXT runtime·setldt(SB),NOSPLIT,$0
    11		RET
    12	
    13	TEXT runtime·open(SB),NOSPLIT,$0
    14		MOVQ	$14, BP
    15		SYSCALL
    16		MOVL	AX, ret+16(FP)
    17		RET
    18	
    19	TEXT runtime·pread(SB),NOSPLIT,$0
    20		MOVQ	$50, BP
    21		SYSCALL
    22		MOVL	AX, ret+32(FP)
    23		RET
    24	
    25	TEXT runtime·pwrite(SB),NOSPLIT,$0
    26		MOVQ	$51, BP
    27		SYSCALL
    28		MOVL	AX, ret+32(FP)
    29		RET
    30	
    31	// int32 _seek(int64*, int32, int64, int32)
    32	TEXT _seek<>(SB),NOSPLIT,$0
    33		MOVQ	$39, BP
    34		SYSCALL
    35		RET
    36	
    37	// int64 seek(int32, int64, int32)
    38	// Convenience wrapper around _seek, the actual system call.
    39	TEXT runtime·seek(SB),NOSPLIT,$32
    40		LEAQ	ret+24(FP), AX
    41		MOVL	fd+0(FP), BX
    42		MOVQ	offset+8(FP), CX
    43		MOVL	whence+16(FP), DX
    44		MOVQ	AX, 0(SP)
    45		MOVL	BX, 8(SP)
    46		MOVQ	CX, 16(SP)
    47		MOVL	DX, 24(SP)
    48		CALL	_seek<>(SB)
    49		CMPL	AX, $0
    50		JGE	2(PC)
    51		MOVQ	$-1, ret+24(FP)
    52		RET
    53	
    54	TEXT runtime·closefd(SB),NOSPLIT,$0
    55		MOVQ	$4, BP
    56		SYSCALL
    57		MOVL	AX, ret+8(FP)
    58		RET
    59	
    60	TEXT runtime·exits(SB),NOSPLIT,$0
    61		MOVQ	$8, BP
    62		SYSCALL
    63		RET
    64	
    65	TEXT runtime·brk_(SB),NOSPLIT,$0
    66		MOVQ	$24, BP
    67		SYSCALL
    68		MOVL	AX, ret+8(FP)
    69		RET
    70	
    71	TEXT runtime·sleep(SB),NOSPLIT,$0
    72		MOVQ	$17, BP
    73		SYSCALL
    74		MOVL	AX, ret+8(FP)
    75		RET
    76	
    77	TEXT runtime·plan9_semacquire(SB),NOSPLIT,$0
    78		MOVQ	$37, BP
    79		SYSCALL
    80		MOVL	AX, ret+16(FP)
    81		RET
    82	
    83	TEXT runtime·plan9_tsemacquire(SB),NOSPLIT,$0
    84		MOVQ	$52, BP
    85		SYSCALL
    86		MOVL	AX, ret+16(FP)
    87		RET
    88	
    89	TEXT runtime·nsec(SB),NOSPLIT,$0
    90		MOVQ	$53, BP
    91		SYSCALL
    92		MOVQ	AX, ret+8(FP)
    93		RET
    94	
    95	// func walltime() (sec int64, nsec int32)
    96	TEXT runtime·walltime(SB),NOSPLIT,$8-12
    97		CALL	runtime·nanotime(SB)
    98		MOVQ	0(SP), AX
    99	
   100		// generated code for
   101		//	func f(x uint64) (uint64, uint64) { return x/1000000000, x%100000000 }
   102		// adapted to reduce duplication
   103		MOVQ	AX, CX
   104		MOVQ	$1360296554856532783, AX
   105		MULQ	CX
   106		ADDQ	CX, DX
   107		RCRQ	$1, DX
   108		SHRQ	$29, DX
   109		MOVQ	DX, sec+0(FP)
   110		IMULQ	$1000000000, DX
   111		SUBQ	DX, CX
   112		MOVL	CX, nsec+8(FP)
   113		RET
   114	
   115	TEXT runtime·notify(SB),NOSPLIT,$0
   116		MOVQ	$28, BP
   117		SYSCALL
   118		MOVL	AX, ret+8(FP)
   119		RET
   120	
   121	TEXT runtime·noted(SB),NOSPLIT,$0
   122		MOVQ	$29, BP
   123		SYSCALL
   124		MOVL	AX, ret+8(FP)
   125		RET
   126		
   127	TEXT runtime·plan9_semrelease(SB),NOSPLIT,$0
   128		MOVQ	$38, BP
   129		SYSCALL
   130		MOVL	AX, ret+16(FP)
   131		RET
   132	
   133	TEXT runtime·rfork(SB),NOSPLIT,$0
   134		MOVQ	$19, BP
   135		SYSCALL
   136		MOVL	AX, ret+8(FP)
   137		RET
   138	
   139	TEXT runtime·tstart_plan9(SB),NOSPLIT,$0
   140		MOVQ	newm+0(FP), CX
   141		MOVQ	m_g0(CX), DX
   142	
   143		// Layout new m scheduler stack on os stack.
   144		MOVQ	SP, AX
   145		MOVQ	AX, (g_stack+stack_hi)(DX)
   146		SUBQ	$(64*1024), AX		// stack size
   147		MOVQ	AX, (g_stack+stack_lo)(DX)
   148		MOVQ	AX, g_stackguard0(DX)
   149		MOVQ	AX, g_stackguard1(DX)
   150	
   151		// Initialize procid from TOS struct.
   152		MOVQ	_tos(SB), AX
   153		MOVL	64(AX), AX
   154		MOVQ	AX, m_procid(CX)	// save pid as m->procid
   155	
   156		// Finally, initialize g.
   157		get_tls(BX)
   158		MOVQ	DX, g(BX)
   159	
   160		CALL	runtime·stackcheck(SB)	// smashes AX, CX
   161		CALL	runtime·mstart(SB)
   162	
   163		MOVQ	$0x1234, 0x1234		// not reached
   164		RET
   165	
   166	// This is needed by asm_amd64.s
   167	TEXT runtime·settls(SB),NOSPLIT,$0
   168		RET
   169	
   170	// void sigtramp(void *ureg, int8 *note)
   171	TEXT runtime·sigtramp(SB),NOSPLIT,$0
   172		get_tls(AX)
   173	
   174		// check that g exists
   175		MOVQ	g(AX), BX
   176		CMPQ	BX, $0
   177		JNE	3(PC)
   178		CALL	runtime·badsignal2(SB) // will exit
   179		RET
   180	
   181		// save args
   182		MOVQ	ureg+0(FP), CX
   183		MOVQ	note+8(FP), DX
   184	
   185		// change stack
   186		MOVQ	g_m(BX), BX
   187		MOVQ	m_gsignal(BX), R10
   188		MOVQ	(g_stack+stack_hi)(R10), BP
   189		MOVQ	BP, SP
   190	
   191		// make room for args and g
   192		SUBQ	$128, SP
   193	
   194		// save g
   195		MOVQ	g(AX), BP
   196		MOVQ	BP, 32(SP)
   197	
   198		// g = m->gsignal
   199		MOVQ	R10, g(AX)
   200	
   201		// load args and call sighandler
   202		MOVQ	CX, 0(SP)
   203		MOVQ	DX, 8(SP)
   204		MOVQ	BP, 16(SP)
   205	
   206		CALL	runtime·sighandler(SB)
   207		MOVL	24(SP), AX
   208	
   209		// restore g
   210		get_tls(BX)
   211		MOVQ	32(SP), R10
   212		MOVQ	R10, g(BX)
   213	
   214		// call noted(AX)
   215		MOVQ	AX, 0(SP)
   216		CALL	runtime·noted(SB)
   217		RET
   218	
   219	TEXT runtime·setfpmasks(SB),NOSPLIT,$8
   220		STMXCSR	0(SP)
   221		MOVL	0(SP), AX
   222		ANDL	$~0x3F, AX
   223		ORL	$(0x3F<<7), AX
   224		MOVL	AX, 0(SP)
   225		LDMXCSR	0(SP)
   226		RET
   227	
   228	#define ERRMAX 128	/* from os_plan9.h */
   229	
   230	// void errstr(int8 *buf, int32 len)
   231	TEXT errstr<>(SB),NOSPLIT,$0
   232		MOVQ    $41, BP
   233		SYSCALL
   234		RET
   235	
   236	// func errstr() string
   237	// Only used by package syscall.
   238	// Grab error string due to a syscall made
   239	// in entersyscall mode, without going
   240	// through the allocator (issue 4994).
   241	// See ../syscall/asm_plan9_amd64.s:/·Syscall/
   242	TEXT runtime·errstr(SB),NOSPLIT,$16-16
   243		get_tls(AX)
   244		MOVQ	g(AX), BX
   245		MOVQ	g_m(BX), BX
   246		MOVQ	(m_mOS+mOS_errstr)(BX), CX
   247		MOVQ	CX, 0(SP)
   248		MOVQ	$ERRMAX, 8(SP)
   249		CALL	errstr<>(SB)
   250		CALL	runtime·findnull(SB)
   251		MOVQ	8(SP), AX
   252		MOVQ	AX, ret_len+8(FP)
   253		MOVQ	0(SP), AX
   254		MOVQ	AX, ret_base+0(FP)
   255		RET

View as plain text