mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-13 06:42:56 +00:00
6aead23323
When doing partition reboot, the boot image won't be reloaded by ROM, it is just CPU reset to boot entry. The SW has to keep the boot image inside the RAM unchanged. It includes both the TEXT section and DATA section. For SPL, the problem is DATA section will be updated at runtime, so in next partition reboot the data is not same as the initial value from cold boot. If any code depends on the initial value, then it will have problem. This patch introduces a mechanism to recover the data section for partition reboot. It adds a new section in image for saving data section. When from cold boot, the data section will be saved to that new section at SPL early phase. When from partition reboot, the data section will be restored from the new section. Signed-off-by: Ye Li <ye.li@nxp.com> Signed-off-by: Peng Fan <peng.fan@nxp.com>
29 lines
661 B
C
29 lines
661 B
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright 2020 NXP
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <spl.h>
|
|
|
|
char __data_save_start[0] __section(.__data_save_start);
|
|
char __data_save_end[0] __section(.__data_save_end);
|
|
|
|
u32 cold_reboot_flag = 1;
|
|
|
|
void spl_save_restore_data(void)
|
|
{
|
|
u32 data_size = __data_save_end - __data_save_start;
|
|
|
|
if (cold_reboot_flag == 1) {
|
|
/* Save data section to data_save section */
|
|
memcpy(__data_save_start, __data_save_start - data_size,
|
|
data_size);
|
|
} else {
|
|
/* Restore the data_save section to data section */
|
|
memcpy(__data_save_start - data_size, __data_save_start,
|
|
data_size);
|
|
}
|
|
|
|
cold_reboot_flag++;
|
|
}
|