blob: 8fd986a67a219f5f96feb43230de358942a1c2d2 [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
9char __data_save_start[0] __section(.__data_save_start);
10char __data_save_end[0] __section(.__data_save_end);
11
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}