xref: /illumos-gate/usr/src/test/os-tests/tests/stackalign/stack_sparc.S (revision ed093b41a93e8563e6e1e5dae0768dda2a7bcc27)
1/*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source.  A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12/*
13 * Copyright 2021 Tintri by DDN, Inc. All rights reserved.
14 * Copyright 2021 Toomas Soome <tsoome@me.com>
15 */
16
17/*
18 * Get the stack at entry and call a function with it as an argument.
19 */
20
21	.file	"stack_sparc.s"
22
23#include <sys/asm_linkage.h>
24
25/*
26 * void
27 * get_stack_at_entry(test_ctx_t *ctx)
28 *
29 * ctx+0 is void (*)(uintptr_t stack, char *text),
30 * and ctx+4 is the 'text' argument.
31 *
32 * Passes the stack pointer prior to the invoking call instruction
33 * to the specified function.
34 */
35	ENTRY(get_stack_at_entry)
36	save	%sp, -SA(MINFRAME), %sp
37	st	%i0, [%fp + STACK_BIAS + ARGPUSHSIZE]
38	ld	[%fp + STACK_BIAS + ARGPUSHSIZE], %g1
39	ld	[%g1], %g1				/* func */
40	ld	[%fp + STACK_BIAS + ARGPUSHSIZE], %g2
41	ld	[%g2 + 4], %g2				/* text */
42	mov	%g2, %o1
43	call	%g1, 0
44	add	%sp, STACK_BIAS, %o0
45	ret
46	restore
47	SET_SIZE(get_stack_at_entry)
48
49/*
50 * void
51 * get_stack_at_init(void)
52 *
53 * Passes the stack pointer prior to the invoking call instruction
54 * to initarray() (defined elsewhere).
55 * Tests alignment in section .init_array.
56 */
57	ENTRY(get_stack_at_init)
58	save	%sp, -SA(MINFRAME), %sp
59	call	initarray, 0
60	add	%sp, STACK_BIAS, %o0
61	ret
62	restore
63	SET_SIZE(get_stack_at_init)
64
65/*
66 * Passes the stack pointer during init to initmain() (defined elsewhere).
67 * Tests alignment in section .init.
68 */
69	.section ".init"
70	call	initmain, 0
71	add	%sp, STACK_BIAS, %o0
72