1 // Copyright 2022 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.
7 // Set the x_crosscall2_ptr C function pointer variable point to crosscall2.
8 // It's such a pointer chain: _crosscall2_ptr -> x_crosscall2_ptr -> crosscall2
9 TEXT ·set_crosscall2(SB),NOSPLIT,$0-0
10 MOVV _crosscall2_ptr(SB), R5
11 MOVV $crosscall2(SB), R6
15 // Called by C code generated by cmd/cgo.
16 // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
17 // Saves C callee-saved registers and calls cgocallback with three arguments.
18 // fn is the PC of a func(a unsafe.Pointer) function.
19 TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
21 * We still need to save all callee save register as before, and then
22 * push 3 args for fn (R4, R5, R7), skipping R6.
23 * Also note that at procedure entry in gc world, 8(R29) will be the
28 MOVV R4, (8*1)(R3) // fn unsafe.Pointer
29 MOVV R5, (8*2)(R3) // a unsafe.Pointer
30 MOVV R7, (8*3)(R3) // ctxt uintptr
50 // Initialize Go ABI environment
51 JAL runtime·load_g(SB)
53 JAL runtime·cgocallback(SB)