xref: /openbmc/qemu/tests/tcg/loongarch64/system/boot.S (revision f0984d40)
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * Minimal LoongArch system boot code.
4 *
5 * Copyright (c) 2021 Loongson Technology Corporation Limited
6 */
7
8#include "regdef.h"
9
10	.global _start
11	.align 16
12_start:
13	la.local t0, stack_end
14	move sp, t0
15	bl main
16
17	.type _start 2
18	.size _start, .-_start
19
20	.global _exit
21	.align 16
22_exit:
232:      /* QEMU ACPI poweroff */
24	li.w  t0, 0xff
25	li.w  t1, 0x10080010
26	st.w  t0, t1, 0
27	idle  0
28	bl    2b
29
30	.type _exit 2
31	.size _exit, .-_exit
32
33	.global __sys_outc
34__sys_outc:
35	li.d t1, 1000000
36loop:
37	lu12i.w	t2, 0x1fe00
38	ori	t0, t2, 0x1e5
39	ld.bu	t0, t0, 0
40	andi	t0, t0, 0x20
41	ext.w.b	t0, t0
42	bnez	t0, in
43	addi.w	t1, t1, -1
44	bnez	t1, loop
45in:
46	ext.w.b	a0, a0
47	lu12i.w	t0, 0x1fe00
48	ori	t0, t0, 0x1e0
49	st.b	a0, t0, 0
50	jirl	$r0, ra, 0
51
52	.data
53	.align 4
54stack:
55	.space	65536
56stack_end:
57