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