1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2020 Loongson Technology Co., Ltd.
4  */
5 
6 #include <linux/linkage.h>
7 #include <asm/addrspace.h>
8 #include <asm/asm.h>
9 #include <asm/loongarchregs.h>
10 #include <asm/regdef.h>
11 
12 SYM_CODE_START(start)
13 	/* Save boot rom start args */
14 	move	s0, a0
15 	move	s1, a1
16 	move	s2, a2
17 	move	s3, a3 /* for kdump */
18 
19 	/* Config Direct Mapping */
20 	li.d	t0, CSR_DMW0_INIT
21 	csrwr	t0, LOONGARCH_CSR_DMWIN0
22 	li.d	t0, CSR_DMW1_INIT
23 	csrwr	t0, LOONGARCH_CSR_DMWIN1
24 
25 	/* Clear BSS */
26 	la.pcrel a0, _edata
27 	la.pcrel a2, _end
28 1:	st.d	zero, a0, 0
29 	addi.d	a0, a0, 8
30 	bne	a2, a0, 1b
31 
32 	la.pcrel a0, .heap	   /* heap address */
33 	la.pcrel sp, .stack + 8192  /* stack address */
34 
35 	la.pcrel a0, .heap	  /* heap address */
36 	move	a1, a3		  /* kdump relocate offset */
37 	bnez	a3, 2f
38 	li.w	a1, 0
39 	li.w	s3, 0
40 2:
41 	la.pcrel ra, 3f
42 	la.pcrel t4, decompress_kernel
43 	jirl	zero, t4, 0
44 3:
45 	move	a0, s0
46 	move	a1, s1
47 	move	a2, s2
48 	move	a3, s3
49 	PTR_LI	t4, KERNEL_ENTRY
50 	add.d	t4, t4, a3
51 	jirl	zero, t4, 0
52 4:
53 	b	4b
54 SYM_CODE_END(start)
55 
56 	.comm .heap,BOOT_HEAP_SIZE,4
57 	.comm .stack,4096*2,4
58