xref: /linux/arch/alpha/boot/compressed/trampoline.S (revision 742f62b63904cdc20a364a49d2861e32464a0af7)
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copy the decompressed kernel onto START_ADDR, clear its bss and jump to
4 * its entry point. See relocate_and_jump() in misc.c for why this cannot
5 * run from the stub itself. It is position independent (no data or
6 * rodata references, no gp) and clobbers only its argument registers and
7 * $1, so misc.c can copy it anywhere and call it there.
8 */
9
10	.set noreorder
11
12	.globl	trampoline_start
13	.globl	trampoline_end
14	.ent	trampoline_start
15trampoline_start:
16	/* $16 = dest, $17 = src, $18 = p_filesz, $19 = p_memsz, $20 = entry */
17
18	/*
19	 * dest and src are both page aligned, and everything above
20	 * p_filesz is bss, so round both lengths up and work in quadwords
21	 * only, using instructions every Alpha implements.
22	 */
23	addq	$18,7,$18
24	bic	$18,7,$18
25	addq	$19,7,$19
26	bic	$19,7,$19
27	subq	$19,$18,$19		/* bytes to zero after the copy */
28
291:	beq	$18,2f
30	ldq	$1,0($17)
31	stq	$1,0($16)
32	addq	$17,8,$17
33	addq	$16,8,$16
34	subq	$18,8,$18
35	br	$31,1b
36
372:	beq	$19,3f
38	stq	$31,0($16)
39	addq	$16,8,$16
40	subq	$19,8,$19
41	br	$31,2b
42
433:	imb
44	jmp	$31,($20)
45	.end trampoline_start
46trampoline_end:
47