blob: 259b49ff3640e1e711b072a85e9dc41ffc66990a [file] [log] [blame]
Peng Fan617fc292020-05-05 20:28:41 +08001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2020 NXP
4 */
5
Peng Fan617fc292020-05-05 20:28:41 +08006#include <spl.h>
7
Marek BehĂșn4bebdd32021-05-20 13:23:52 +02008char __data_save_start[0] __section(".__data_save_start");
9char __data_save_end[0] __section(".__data_save_end");
Peng Fan617fc292020-05-05 20:28:41 +080010
11u32 cold_reboot_flag = 1;
12
13void spl_save_restore_data(void)
14{
15 u32 data_size = __data_save_end - __data_save_start;
16
17 if (cold_reboot_flag == 1) {
18 /* Save data section to data_save section */
19 memcpy(__data_save_start, __data_save_start - data_size,
20 data_size);
21 } else {
22 /* Restore the data_save section to data section */
23 memcpy(__data_save_start - data_size, __data_save_start,
24 data_size);
25 }
26
27 cold_reboot_flag++;
28}