...
Run Format

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

View as plain text