1// Copyright 2015 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/*
6 * Apple still insists on underscore prefixes for C function names.
7 */
8#if defined(__APPLE__)
9#define EXT(s) _##s
10#else
11#define EXT(s) s
12#endif
13
14// Apple's ld64 wants 4-byte alignment for ARM code sections.
15// .align in both Apple as and GNU as treat n as aligning to 2**n bytes.
16.align	2
17
18/*
19 * void crosscall1(void (*fn)(void), void (*setg_gcc)(void *g), void *g)
20 *
21 * Calling into the gc tool chain, where all registers are caller save.
22 * Called from standard ARM EABI, where x19-x29 are callee-save, so they
23 * must be saved explicitly, along with x30 (LR).
24 */
25.globl EXT(crosscall1)
26EXT(crosscall1):
27	stp x19, x20, [sp, #-16]!
28	stp x21, x22, [sp, #-16]!
29	stp x23, x24, [sp, #-16]!
30	stp x25, x26, [sp, #-16]!
31	stp x27, x28, [sp, #-16]!
32	stp x29, x30, [sp, #-16]!
33	mov x29, sp
34
35	mov x19, x0
36	mov x20, x1
37	mov x0, x2
38
39	blr x20
40	blr x19
41
42	ldp x29, x30, [sp], #16
43	ldp x27, x28, [sp], #16
44	ldp x25, x26, [sp], #16
45	ldp x23, x24, [sp], #16
46	ldp x21, x22, [sp], #16
47	ldp x19, x20, [sp], #16
48	ret
49
50
51#ifdef __ELF__
52.section .note.GNU-stack,"",%progbits
53#endif
54