Peng Fan | 617fc29 | 2020-05-05 20:28:41 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright 2020 NXP |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <spl.h> |
| 8 | |
Marek BehĂșn | 4bebdd3 | 2021-05-20 13:23:52 +0200 | [diff] [blame] | 9 | char __data_save_start[0] __section(".__data_save_start"); |
| 10 | char __data_save_end[0] __section(".__data_save_end"); |
Peng Fan | 617fc29 | 2020-05-05 20:28:41 +0800 | [diff] [blame] | 11 | |
| 12 | u32 cold_reboot_flag = 1; |
| 13 | |
| 14 | void 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 | } |