xref: /openbmc/qemu/tests/tcg/loongarch64/system/boot.S (revision ed75658a)
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, 0x34
25	li.w  t1, 0x100e001c
26	st.b  t0, t1, 0
27
28	idle  0
29	bl    2b
30
31	.type _exit 2
32	.size _exit, .-_exit
33
34	.global __sys_outc
35__sys_outc:
36	li.d t1, 1000000
37loop:
38	lu12i.w	t2, 0x1fe00
39	ori	t0, t2, 0x1e5
40	ld.bu	t0, t0, 0
41	andi	t0, t0, 0x20
42	ext.w.b	t0, t0
43	bnez	t0, in
44	addi.w	t1, t1, -1
45	bnez	t1, loop
46in:
47	ext.w.b	a0, a0
48	lu12i.w	t0, 0x1fe00
49	ori	t0, t0, 0x1e0
50	st.b	a0, t0, 0
51	jirl	$r0, ra, 0
52
53	.data
54	.align 4
55stack:
56	.space	65536
57stack_end:
58