xref: /illumos-gate/usr/src/test/os-tests/tests/stackalign/stack_sparcv9.S (revision d48be21240dfd051b689384ce2b23479d757f2d8)
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_sparcv9.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+8 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	.register	%g2, #scratch
37	save    %sp, -SA(MINFRAME), %sp
38	stx	%i0, [%fp + STACK_BIAS + ARGPUSHSIZE]
39	ldx	[%fp + STACK_BIAS + ARGPUSHSIZE], %g1
40	ldx	[%g1], %g1				/* func */
41	ldx	[%fp + STACK_BIAS + ARGPUSHSIZE], %g2
42	ldx	[%g2 + 8], %g2				/* text */
43	mov	%g2, %o1
44	call	%g1, 2
45	add	%sp, STACK_BIAS, %o0
46	ret
47	restore
48	SET_SIZE(get_stack_at_entry)
49
50/*
51 * void
52 * get_stack_at_init(void)
53 *
54 * Passes the stack pointer prior to the invoking call instruction
55 * to initarray() (defined elsewhere).
56 * Tests alignment in section .init_array.
57 */
58	ENTRY(get_stack_at_init)
59	save    %sp, -SA(MINFRAME), %sp
60	call	initarray, 0
61	add	%sp, STACK_BIAS, %o0
62	ret
63	restore
64	SET_SIZE(get_stack_at_init)
65
66/*
67 * Passes the stack pointer during init to initmain() (defined elsewhere).
68 * Tests alignment in section .init.
69 */
70	.section ".init"
71	call	initmain, 0
72	add	%sp, STACK_BIAS, %o0
73
74