OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include "386/asm.h" | 5 #include "386/asm.h" |
6 | 6 |
7 // void *stdcall_raw(void *fn, int32 count, uintptr *args) | 7 // void *stdcall_raw(void *fn, int32 count, uintptr *args) |
8 TEXT runtime·stdcall_raw(SB),7,$4 | 8 TEXT runtime·stdcall_raw(SB),7,$4 |
9 // Copy arguments from stack. | 9 // Copy arguments from stack. |
10 MOVL fn+0(FP), AX | 10 MOVL fn+0(FP), AX |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // call windows default handler early | 84 // call windows default handler early |
85 MOVL 4(SP), BX // our SEH frame | 85 MOVL 4(SP), BX // our SEH frame |
86 MOVL 0(BX), BX // SEH frame of default handler | 86 MOVL 0(BX), BX // SEH frame of default handler |
87 MOVL 4(BX), AX // handler function pointer | 87 MOVL 4(BX), AX // handler function pointer |
88 MOVL BX, 4(SP) // set establisher frame | 88 MOVL BX, 4(SP) // set establisher frame |
89 CALL AX | 89 CALL AX |
90 | 90 |
91 sigdone: | 91 sigdone: |
92 RET | 92 RET |
93 | 93 |
| 94 // Called from dynamic function created by ../thread.c compilecallback, |
| 95 // running on Windows stack (not Go stack). |
| 96 // Returns straight to DLL. |
| 97 // EBX, ESI, EDI registers and DF flag are preserved |
| 98 // as required by windows callback convention. |
| 99 // On entry to the function the stack looks like: |
| 100 // |
| 101 // 0(SP) - return address to callback |
| 102 // 4(SP) - address of go func we need to call |
| 103 // 8(SP) - total size of arguments |
| 104 // 12(SP) - room to save BX register |
| 105 // 16(SP) - room to save SI |
| 106 // 20(SP) - room to save DI |
| 107 // 24(SP) - return address to DLL |
| 108 // 28(SP) - beginning of arguments |
| 109 // |
| 110 TEXT runtime·callbackasm+0(SB),7,$0 |
| 111 MOVL BX, 12(SP) // save registers as required for window
s callback |
| 112 MOVL SI, 16(SP) |
| 113 MOVL DI, 20(SP) |
| 114 |
| 115 LEAL args+28(SP), AX |
| 116 MOVL AX, 0(SP) |
| 117 |
| 118 CLD |
| 119 |
| 120 CALL runtime·callback(SB) |
| 121 |
| 122 MOVL 12(SP), BX // restore registers as required for win
dows callback |
| 123 MOVL 16(SP), SI |
| 124 MOVL 20(SP), DI |
| 125 CLD |
| 126 |
| 127 MOVL ret+24(SP), CX |
| 128 MOVL size+8(SP), DX |
| 129 ADDL $28, DX |
| 130 ADDL DX, SP |
| 131 JMP CX |
| 132 |
94 // void tstart(M *newm); | 133 // void tstart(M *newm); |
95 TEXT runtime·tstart(SB),7,$0 | 134 TEXT runtime·tstart(SB),7,$0 |
96 MOVL newm+4(SP), CX // m | 135 MOVL newm+4(SP), CX // m |
97 MOVL m_g0(CX), DX // g | 136 MOVL m_g0(CX), DX // g |
98 | 137 |
99 // Set up SEH frame | 138 // Set up SEH frame |
100 PUSHL $runtime·sigtramp(SB) | 139 PUSHL $runtime·sigtramp(SB) |
101 PUSHL 0(FS) | 140 PUSHL 0(FS) |
102 MOVL SP, 0(FS) | 141 MOVL SP, 0(FS) |
103 | 142 |
104 // Layout new m scheduler stack on os stack. | 143 // Layout new m scheduler stack on os stack. |
105 MOVL SP, AX | 144 MOVL SP, AX |
106 SUBL $256, AX // just some space for ourselves | 145 SUBL $256, AX // just some space for ourselves |
107 MOVL AX, g_stackbase(DX) | 146 MOVL AX, g_stackbase(DX) |
108 » SUBL» $8192, AX» » // stack size | 147 » SUBL» $(16*1024), AX» » // stack size |
109 MOVL AX, g_stackguard(DX) | 148 MOVL AX, g_stackguard(DX) |
110 | 149 |
111 // Set up tls. | 150 // Set up tls. |
112 LEAL m_tls(CX), SI | 151 LEAL m_tls(CX), SI |
113 MOVL SI, 0x2c(FS) | 152 MOVL SI, 0x2c(FS) |
114 MOVL CX, m(SI) | 153 MOVL CX, m(SI) |
115 MOVL DX, g(SI) | 154 MOVL DX, g(SI) |
116 | 155 |
117 // Use scheduler stack now. | 156 // Use scheduler stack now. |
118 MOVL g_stackbase(DX), SP | 157 MOVL g_stackbase(DX), SP |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 RET | 194 RET |
156 | 195 |
157 // for now, return 0,0. only used for internal performance monitoring. | 196 // for now, return 0,0. only used for internal performance monitoring. |
158 TEXT runtime·gettime(SB),7,$0 | 197 TEXT runtime·gettime(SB),7,$0 |
159 MOVL sec+0(FP), DI | 198 MOVL sec+0(FP), DI |
160 MOVL $0, (DI) | 199 MOVL $0, (DI) |
161 MOVL $0, 4(DI) // zero extend 32 -> 64 bits | 200 MOVL $0, 4(DI) // zero extend 32 -> 64 bits |
162 MOVL usec+4(FP), DI | 201 MOVL usec+4(FP), DI |
163 MOVL $0, (DI) | 202 MOVL $0, (DI) |
164 RET | 203 RET |
OLD | NEW |