mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-08-14 19:26:58 +02:00
Introduce a new symbol in the beginning of .data section in the common ARMv8 linker script and use that as a reference for data save and restore. Previously, the code would rely on calculating the start of the .data section address via data size, however, we observed that the data size does not really reflect the SPL mapped addresses. In our case, the binman_sym section size was not included in the data size, which will result in a wrong address for the .data start section, which prevents us from properly saving and restoring SPL data. This approach skips the calculation for the starting address of the .data section, and instead just defines the beginning address of the .data section and calling the symbol as needed, in which we think as a simpler and much more robust method. Signed-off-by: Alif Zakuan Yuslaimi <alif.zakuan.yuslaimi@altera.com> Signed-off-by: Tien Fong Chee <tien.fong.chee@altera.com> Reviewed-by: Tien Fong Chee <tien.fong.chee@altera.com>
34 lines
720 B
C
34 lines
720 B
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright 2020 NXP
|
|
*/
|
|
|
|
#include <spl.h>
|
|
|
|
char __data_start[0] __section(".__data_start");
|
|
char __data_save_start[0] __section(".__data_save_start");
|
|
char __data_save_end[0] __section(".__data_save_end");
|
|
|
|
u32 cold_reboot_flag = 1;
|
|
|
|
u32 __weak reset_flag(void)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
void spl_save_restore_data(void)
|
|
{
|
|
u32 data_size = __data_save_end - __data_save_start;
|
|
cold_reboot_flag = reset_flag();
|
|
|
|
if (cold_reboot_flag == 1) {
|
|
/* Save data section to data_save section */
|
|
memcpy(__data_save_start, __data_start, data_size);
|
|
} else {
|
|
/* Restore the data_save section to data section */
|
|
memcpy(__data_start, __data_save_start, data_size);
|
|
}
|
|
|
|
cold_reboot_flag++;
|
|
}
|