1/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Copyright 2017 NXP
4 */
5
6#include <config.h>
7
8.align 8
9.global rom_pointer
10rom_pointer:
11	.space 256
12
13/*
14 * Routine: save_boot_params (called after reset from start.S)
15 */
16
17.global save_boot_params
18save_boot_params:
19	/* The firmware provided ATAG/FDT address can be found in r2/x0 */
20	adr	x0, rom_pointer
21	stp	x1, x2, [x0], #16
22	stp	x3, x4, [x0], #16
23	stp	x5, x6, [x0], #16
24	stp	x7, x8, [x0], #16
25	stp	x9, x10, [x0], #16
26	stp	x11, x12, [x0], #16
27	stp	x13, x14, [x0], #16
28	stp	x15, x16, [x0], #16
29	stp	x17, x18, [x0], #16
30	stp	x19, x20, [x0], #16
31	stp	x21, x22, [x0], #16
32	stp	x23, x24, [x0], #16
33	stp	x25, x26, [x0], #16
34	stp	x27, x28, [x0], #16
35	stp	x29, x30, [x0], #16
36	mov	x30, sp
37	str	x30, [x0], #8
38
39	/* Returns */
40	b	save_boot_params_ret
41
42.global restore_boot_params
43restore_boot_params:
44	adr	x0, rom_pointer
45	ldp	x1, x2, [x0], #16
46	ldp	x3, x4, [x0], #16
47	ldp	x5, x6, [x0], #16
48	ldp	x7, x8, [x0], #16
49	ldp	x9, x10, [x0], #16
50	ldp	x11, x12, [x0], #16
51	ldp	x13, x14, [x0], #16
52	ldp	x15, x16, [x0], #16
53	ldp	x17, x18, [x0], #16
54	ldp	x19, x20, [x0], #16
55	ldp	x21, x22, [x0], #16
56	ldp	x23, x24, [x0], #16
57	ldp	x25, x26, [x0], #16
58	ldp	x27, x28, [x0], #16
59	ldp	x29, x30, [x0], #16
60	ldr	x0, [x0]
61	mov	sp, x0
62	ret
63