spl_data.c 661 B

1234567891011121314151617181920212223242526272829
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2020 NXP
  4. */
  5. #include <common.h>
  6. #include <spl.h>
  7. char __data_save_start[0] __section(.__data_save_start);
  8. char __data_save_end[0] __section(.__data_save_end);
  9. u32 cold_reboot_flag = 1;
  10. void spl_save_restore_data(void)
  11. {
  12. u32 data_size = __data_save_end - __data_save_start;
  13. if (cold_reboot_flag == 1) {
  14. /* Save data section to data_save section */
  15. memcpy(__data_save_start, __data_save_start - data_size,
  16. data_size);
  17. } else {
  18. /* Restore the data_save section to data section */
  19. memcpy(__data_save_start - data_size, __data_save_start,
  20. data_size);
  21. }
  22. cold_reboot_flag++;
  23. }