summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/plan9/386/sys.s
blob: 1cb570b68c371703a42cff87fcbe4c9370cc5351 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#include "defs.h"
#include "386/asm.h"

// setldt(int entry, int address, int limit)
TEXT runtime·setldt(SB),7,$0
	RET

TEXT runtime·open(SB),7,$0
	MOVL    $14, AX
	INT     $64
	RET

TEXT runtime·write(SB),7,$0
	MOVL    $20, AX
	INT     $64
	RET

TEXT runtime·exits(SB),7,$0
	MOVL    $8, AX
	INT     $64
	RET

TEXT runtime·brk_(SB),7,$0
	MOVL    $24, AX
	INT     $64
	RET

TEXT runtime·plan9_semacquire(SB),7,$0
	MOVL	$37, AX
	INT	$64
	RET
	
TEXT runtime·plan9_semrelease(SB),7,$0
	MOVL	$38, AX
	INT	$64
	RET
	
TEXT runtime·rfork(SB),7,$0
	MOVL    $19, AX // rfork
	INT     $64

	// In parent, return.
	CMPL	AX, $0
	JEQ	2(PC)
	RET

	// In child on old stack.
	MOVL	mm+12(SP), BX	// m
	MOVL	gg+16(SP), DX	// g
	MOVL	fn+20(SP), SI	// fn

	// set SP to be on the new child stack
	MOVL	stack+8(SP), CX
	MOVL	CX, SP

	// Initialize m, g.
	get_tls(AX)
	MOVL	DX, g(AX)
	MOVL	BX, m(AX)

	// Initialize AX from _tos->pid
	MOVL	_tos(SB), AX
	MOVL	tos_pid(AX), AX
	MOVL	AX, m_procid(BX)	// save pid as m->procid
	
	CALL	runtime·stackcheck(SB)	// smashes AX, CX
	
	MOVL	0(DX), DX	// paranoia; check they are not nil
	MOVL	0(BX), BX
	
	// more paranoia; check that stack splitting code works
	PUSHAL
	CALL	runtime·emptyfunc(SB)
	POPAL
	
	CALL	SI	// fn()
	CALL	runtime·exit(SB)
	RET