...

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)
    10TEXT runtime·setldt(SB),NOSPLIT,$0
    11	RET
    12
    13TEXT runtime·open(SB),NOSPLIT,$0
    14	MOVL    $14, AX
    15	INT     $64
    16	MOVL	AX, ret+12(FP)
    17	RET
    18
    19TEXT runtime·pread(SB),NOSPLIT,$0
    20	MOVL    $50, AX
    21	INT     $64
    22	MOVL	AX, ret+20(FP)
    23	RET
    24
    25TEXT 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)
    32TEXT _seek<>(SB),NOSPLIT,$0
    33	MOVL	$39, AX
    34	INT	$64
    35	RET
    36
    37TEXT 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
    55TEXT runtime·closefd(SB),NOSPLIT,$0
    56	MOVL	$4, AX
    57	INT	$64
    58	MOVL	AX, ret+4(FP)
    59	RET
    60
    61TEXT runtime·exits(SB),NOSPLIT,$0
    62	MOVL    $8, AX
    63	INT     $64
    64	RET
    65
    66TEXT runtime·brk_(SB),NOSPLIT,$0
    67	MOVL    $24, AX
    68	INT     $64
    69	MOVL	AX, ret+4(FP)
    70	RET
    71
    72TEXT runtime·sleep(SB),NOSPLIT,$0
    73	MOVL    $17, AX
    74	INT     $64
    75	MOVL	AX, ret+4(FP)
    76	RET
    77
    78TEXT runtime·plan9_semacquire(SB),NOSPLIT,$0
    79	MOVL	$37, AX
    80	INT	$64
    81	MOVL	AX, ret+8(FP)
    82	RET
    83
    84TEXT runtime·plan9_tsemacquire(SB),NOSPLIT,$0
    85	MOVL	$52, AX
    86	INT	$64
    87	MOVL	AX, ret+8(FP)
    88	RET
    89
    90TEXT nsec<>(SB),NOSPLIT,$0
    91	MOVL	$53, AX
    92	INT	$64
    93	RET
    94
    95TEXT 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)
   106TEXT runtime·walltime(SB),NOSPLIT,$8-12
   107	CALL	runtime·nanotime1(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
   118TEXT runtime·notify(SB),NOSPLIT,$0
   119	MOVL	$28, AX
   120	INT	$64
   121	MOVL	AX, ret+4(FP)
   122	RET
   123
   124TEXT runtime·noted(SB),NOSPLIT,$0
   125	MOVL	$29, AX
   126	INT	$64
   127	MOVL	AX, ret+4(FP)
   128	RET
   129
   130TEXT runtime·plan9_semrelease(SB),NOSPLIT,$0
   131	MOVL	$38, AX
   132	INT	$64
   133	MOVL	AX, ret+8(FP)
   134	RET
   135
   136TEXT runtime·rfork(SB),NOSPLIT,$0
   137	MOVL	$19, AX
   138	INT	$64
   139	MOVL	AX, ret+4(FP)
   140	RET
   141
   142TEXT runtime·tstart_plan9(SB),NOSPLIT,$4
   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	// Exit the thread.
   167	MOVL	$0, 0(SP)
   168	CALL	runtime·exits(SB)
   169	JMP	0(PC)
   170
   171// void sigtramp(void *ureg, int8 *note)
   172TEXT runtime·sigtramp(SB),NOSPLIT,$0
   173	get_tls(AX)
   174
   175	// check that g exists
   176	MOVL	g(AX), BX
   177	CMPL	BX, $0
   178	JNE	3(PC)
   179	CALL	runtime·badsignal2(SB) // will exit
   180	RET
   181
   182	// save args
   183	MOVL	ureg+0(FP), CX
   184	MOVL	note+4(FP), DX
   185
   186	// change stack
   187	MOVL	g_m(BX), BX
   188	MOVL	m_gsignal(BX), BP
   189	MOVL	(g_stack+stack_hi)(BP), BP
   190	MOVL	BP, SP
   191
   192	// make room for args and g
   193	SUBL	$24, SP
   194
   195	// save g
   196	MOVL	g(AX), BP
   197	MOVL	BP, 20(SP)
   198
   199	// g = m->gsignal
   200	MOVL	m_gsignal(BX), DI
   201	MOVL	DI, g(AX)
   202
   203	// load args and call sighandler
   204	MOVL	CX, 0(SP)
   205	MOVL	DX, 4(SP)
   206	MOVL	BP, 8(SP)
   207
   208	CALL	runtime·sighandler(SB)
   209	MOVL	12(SP), AX
   210
   211	// restore g
   212	get_tls(BX)
   213	MOVL	20(SP), BP
   214	MOVL	BP, g(BX)
   215
   216	// call noted(AX)
   217	MOVL	AX, 0(SP)
   218	CALL	runtime·noted(SB)
   219	RET
   220
   221// Only used by the 64-bit runtime.
   222TEXT runtime·setfpmasks(SB),NOSPLIT,$0
   223	RET
   224
   225#define ERRMAX 128	/* from os_plan9.h */
   226
   227// void errstr(int8 *buf, int32 len)
   228TEXT errstr<>(SB),NOSPLIT,$0
   229	MOVL    $41, AX
   230	INT     $64
   231	RET
   232
   233// func errstr() string
   234// Only used by package syscall.
   235// Grab error string due to a syscall made
   236// in entersyscall mode, without going
   237// through the allocator (issue 4994).
   238// See ../syscall/asm_plan9_386.s:/·Syscall/
   239TEXT runtime·errstr(SB),NOSPLIT,$8-8
   240	get_tls(AX)
   241	MOVL	g(AX), BX
   242	MOVL	g_m(BX), BX
   243	MOVL	(m_mOS+mOS_errstr)(BX), CX
   244	MOVL	CX, 0(SP)
   245	MOVL	$ERRMAX, 4(SP)
   246	CALL	errstr<>(SB)
   247	CALL	runtime·findnull(SB)
   248	MOVL	4(SP), AX
   249	MOVL	AX, ret_len+4(FP)
   250	MOVL	0(SP), AX
   251	MOVL	AX, ret_base+0(FP)
   252	RET
   253
   254// never called on this platform
   255TEXT ·sigpanictramp(SB),NOSPLIT,$0-0
   256	UNDEF

View as plain text