github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/src/pkg/runtime/sys_plan9_386.s (about)

     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 "zasm_GOOS_GOARCH.h"
     6  
     7  // setldt(int entry, int address, int limit)
     8  TEXT runtime·setldt(SB),7,$0
     9  	RET
    10  
    11  TEXT runtime·open(SB),7,$0
    12  	MOVL    $14, AX
    13  	INT     $64
    14  	RET
    15  
    16  TEXT runtime·pread(SB),7,$0
    17  	MOVL    $50, AX
    18  	INT     $64
    19  	RET
    20  
    21  TEXT runtime·pwrite(SB),7,$0
    22  	MOVL    $51, AX
    23  	INT     $64
    24  	RET
    25  
    26  TEXT runtime·seek(SB),7,$0
    27  	MOVL	$39, AX
    28  	INT	$64
    29  	CMPL	AX, $-1
    30  	JNE	4(PC)
    31  	MOVL	a+0(FP), CX
    32  	MOVL	AX, 0(CX)
    33  	MOVL	AX, 4(CX)
    34  	RET
    35  
    36  TEXT runtime·close(SB),7,$0
    37  	MOVL	$4, AX
    38  	INT	$64
    39  	RET
    40  
    41  TEXT runtime·exits(SB),7,$0
    42  	MOVL    $8, AX
    43  	INT     $64
    44  	RET
    45  
    46  TEXT runtime·brk_(SB),7,$0
    47  	MOVL    $24, AX
    48  	INT     $64
    49  	RET
    50  
    51  TEXT runtime·sleep(SB),7,$0
    52  	MOVL    $17, AX
    53  	INT     $64
    54  	RET
    55  
    56  TEXT runtime·plan9_semacquire(SB),7,$0
    57  	MOVL	$37, AX
    58  	INT	$64
    59  	RET
    60  
    61  TEXT runtime·plan9_tsemacquire(SB),7,$0
    62  	MOVL	$52, AX
    63  	INT	$64
    64  	RET
    65  
    66  TEXT runtime·notify(SB),7,$0
    67  	MOVL	$28, AX
    68  	INT	$64
    69  	RET
    70  
    71  TEXT runtime·noted(SB),7,$0
    72  	MOVL	$29, AX
    73  	INT	$64
    74  	RET
    75  	
    76  TEXT runtime·plan9_semrelease(SB),7,$0
    77  	MOVL	$38, AX
    78  	INT	$64
    79  	RET
    80  	
    81  TEXT runtime·rfork(SB),7,$0
    82  	MOVL    $19, AX // rfork
    83  	INT     $64
    84  
    85  	// In parent, return.
    86  	CMPL	AX, $0
    87  	JEQ	2(PC)
    88  	RET
    89  
    90  	// In child on old stack.
    91  	MOVL	mm+12(SP), BX	// m
    92  	MOVL	gg+16(SP), DX	// g
    93  	MOVL	fn+20(SP), SI	// fn
    94  
    95  	// set SP to be on the new child stack
    96  	MOVL	stack+8(SP), CX
    97  	MOVL	CX, SP
    98  
    99  	// Initialize m, g.
   100  	get_tls(AX)
   101  	MOVL	DX, g(AX)
   102  	MOVL	BX, m(AX)
   103  
   104  	// Initialize AX from TOS struct.
   105  	MOVL	procid(AX), AX
   106  	MOVL	AX, m_procid(BX)	// save pid as m->procid
   107  	
   108  	CALL	runtime·stackcheck(SB)	// smashes AX, CX
   109  	
   110  	MOVL	0(DX), DX	// paranoia; check they are not nil
   111  	MOVL	0(BX), BX
   112  	
   113  	// more paranoia; check that stack splitting code works
   114  	PUSHL	SI
   115  	CALL	runtime·emptyfunc(SB)
   116  	POPL	SI
   117  	
   118  	CALL	SI	// fn()
   119  	CALL	runtime·exit(SB)
   120  	RET
   121  
   122  // void sigtramp(void *ureg, int8 *note)
   123  TEXT runtime·sigtramp(SB),7,$0
   124  	get_tls(AX)
   125  
   126  	// check that m exists
   127  	MOVL	m(AX), BX
   128  	CMPL	BX, $0
   129  	JNE	3(PC)
   130  	CALL	runtime·badsignal(SB) // will exit
   131  	RET
   132  
   133  	// save args
   134  	MOVL	ureg+4(SP), CX
   135  	MOVL	note+8(SP), DX
   136  
   137  	// change stack
   138  	MOVL	m_gsignal(BX), BP
   139  	MOVL	g_stackbase(BP), BP
   140  	MOVL	BP, SP
   141  
   142  	// make room for args and g
   143  	SUBL	$16, SP
   144  
   145  	// save g
   146  	MOVL	g(AX), BP
   147  	MOVL	BP, 12(SP)
   148  
   149  	// g = m->gsignal
   150  	MOVL	m_gsignal(BX), DI
   151  	MOVL	DI, g(AX)
   152  
   153  	// load args and call sighandler
   154  	MOVL	CX, 0(SP)
   155  	MOVL	DX, 4(SP)
   156  	MOVL	BP, 8(SP)
   157  
   158  	CALL	runtime·sighandler(SB)
   159  
   160  	// restore g
   161  	get_tls(BX)
   162  	MOVL	12(SP), BP
   163  	MOVL	BP, g(BX)
   164  
   165  	// call noted(AX)
   166  	MOVL	AX, 0(SP)
   167  	CALL	runtime·noted(SB)
   168  	RET
   169  
   170  // Only used by the 64-bit runtime.
   171  TEXT runtime·setfpmasks(SB),7,$0
   172  	RET
   173  
   174  #define ERRMAX 128	/* from os_plan9.h */
   175  
   176  // func errstr() String
   177  // Only used by package syscall.
   178  // Grab error string due to a syscall made
   179  // in entersyscall mode, without going
   180  // through the allocator (issue 4994).
   181  // See ../syscall/asm_plan9_386.s:/·Syscall/
   182  TEXT runtime·errstr(SB),7,$0
   183  	get_tls(AX)
   184  	MOVL	m(AX), BX
   185  	MOVL	m_errstr(BX), CX
   186  	MOVL	CX, 4(SP)
   187  	MOVL	$ERRMAX, 8(SP)
   188  	MOVL	$41, AX
   189  	INT	$64
   190  
   191  	// syscall requires caller-save
   192  	MOVL	4(SP), CX
   193  
   194  	// push the argument
   195  	PUSHL	CX
   196  	CALL	runtime·findnull(SB)
   197  	POPL	CX
   198  	MOVL	AX, 8(SP)
   199  	RET