xref: /kvm-unit-tests/s390x/snippets/c/cstart.S (revision 796217d86bec2b342b5db6a0bb6a179bfd7a180b)
1dcb58231SJanosch Frank/* SPDX-License-Identifier: GPL-2.0-only */
2dcb58231SJanosch Frank/*
3dcb58231SJanosch Frank * Start assembly for snippets
4dcb58231SJanosch Frank *
5dcb58231SJanosch Frank * Copyright (c) 2021 IBM Corp.
6dcb58231SJanosch Frank *
7dcb58231SJanosch Frank * Authors:
8dcb58231SJanosch Frank *  Janosch Frank <frankja@linux.ibm.com>
9dcb58231SJanosch Frank */
10acc93cbfSJanosch Frank#include <asm/sigp.h>
11acc93cbfSJanosch Frank
12acc93cbfSJanosch Frank.section .init
13acc93cbfSJanosch Frank	.globl start
14acc93cbfSJanosch Frankstart:
15df8d7ad7SJanosch Frank	larl	%r1, initial_cr0
16df8d7ad7SJanosch Frank	lctlg	%c0, %c0, 0(%r1)
17acc93cbfSJanosch Frank	/* XOR all registers with themselves to clear them fully. */
18*796217d8SThomas Huth	.irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14
19acc93cbfSJanosch Frank	xgr \i,\i
20acc93cbfSJanosch Frank	.endr
21acc93cbfSJanosch Frank	sam64
22*796217d8SThomas Huth	/* 0x3000 is the stack page for now */
23*796217d8SThomas Huth	larl	%r15, stackptr
24acc93cbfSJanosch Frank	brasl	%r14, main
25478996b1SThomas Huth	/*
26478996b1SThomas Huth	 * If main() returns, we stop the CPU with the code below. We also
27478996b1SThomas Huth	 * route some functions that are required by the libc (but not usable
28478996b1SThomas Huth	 * from snippets) to the CPU stop code below, so that snippets can
29478996b1SThomas Huth	 * still be linked against the libc code (to use non-related functions
30478996b1SThomas Huth	 * like memset() etc.)
31478996b1SThomas Huth	 */
32478996b1SThomas Huth.global puts
33478996b1SThomas Huth.global exit
34478996b1SThomas Huthputs:
35478996b1SThomas Huthexit:
36acc93cbfSJanosch Frank	/* For now let's only use cpu 0 in snippets so this will always work. */
37acc93cbfSJanosch Frank	xgr	%r0, %r0
38acc93cbfSJanosch Frank	sigp    %r2, %r0, SIGP_STOP
39df8d7ad7SJanosch Frank
40*796217d8SThomas Huth	.align 8
41df8d7ad7SJanosch Frankinitial_cr0:
42df8d7ad7SJanosch Frank	/* enable AFP-register control, so FP regs (+BFP instr) can be used */
43df8d7ad7SJanosch Frank	.quad	0x0000000000040000
44