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

View as plain text