diff options
author | Anson Huang <Anson.Huang@nxp.com> | 2020-03-27 10:10:37 +0800 |
---|---|---|
committer | Anson Huang <Anson.Huang@nxp.com> | 2020-03-27 10:51:24 +0800 |
commit | 17de03937e6b082d5ed350bd761cad810eb31809 (patch) | |
tree | 64f89ec2f5c93703e30363e39ebe4bd199537ec2 | |
parent | ebeb5ca6793fefdcbefb8b3b6b1ccff06ecf693b (diff) |
plat: imx: Add data section restore for i.MX8 SoCs with partition reboot
i.MX8 SoC with SCU inside support partition reboot, the partition reboot
will NOT reload the bl31.bin, so the data section could have some dirty
data of previous boot up, it will impact the reboot, so need to restore
the data section for partition reboot.
Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
-rw-r--r-- | plat/imx/imx8dxl/imx8dxl_bl31_setup.c | 17 | ||||
-rw-r--r-- | plat/imx/imx8qm/imx8qm_bl31_setup.c | 17 | ||||
-rw-r--r-- | plat/imx/imx8qx/imx8qx_bl31_setup.c | 17 |
3 files changed, 51 insertions, 0 deletions
diff --git a/plat/imx/imx8dxl/imx8dxl_bl31_setup.c b/plat/imx/imx8dxl/imx8dxl_bl31_setup.c index 147e7c02..daea57d1 100644 --- a/plat/imx/imx8dxl/imx8dxl_bl31_setup.c +++ b/plat/imx/imx8dxl/imx8dxl_bl31_setup.c @@ -29,6 +29,7 @@ #include <imx_sip_svc.h> #include <string.h> +#define DATA_SECTION_RESTORE_FLAG 0x11223344 #define TRUSTY_PARAMS_LEN_BYTES (4096*2) IMPORT_SYM(unsigned long, __COHERENT_RAM_START__, BL31_COHERENT_RAM_START); @@ -37,6 +38,8 @@ IMPORT_SYM(unsigned long, __RO_START__, BL31_RO_START); IMPORT_SYM(unsigned long, __RO_END__, BL31_RO_END); IMPORT_SYM(unsigned long, __RW_START__, BL31_RW_START); IMPORT_SYM(unsigned long, __RW_END__, BL31_RW_END); +IMPORT_SYM(unsigned long, __DATA_START__, BL31_DATA_START); +IMPORT_SYM(unsigned long, __DATA_END__, BL31_DATA_END); #if DEBUG_CONSOLE extern unsigned long console_list; @@ -376,6 +379,20 @@ void imx8_partition_resources(void) void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3) { + unsigned int count = (BL31_DATA_END - BL31_DATA_START) / 4; + unsigned int *data = (unsigned int *)(BL31_LIMIT - (BL31_DATA_END - BL31_DATA_START) - 0x4); + unsigned *ptr = (unsigned int *)BL31_DATA_START; + int i; + + if (*data != DATA_SECTION_RESTORE_FLAG) { + *data = DATA_SECTION_RESTORE_FLAG; + for (i = 0; i < count; i++) + *(++data) = *(ptr++); + } else { + for (i = 0; i < count; i++) + *(ptr++) = *(++data); + } + #if DEBUG_CONSOLE static console_lpuart_t console; diff --git a/plat/imx/imx8qm/imx8qm_bl31_setup.c b/plat/imx/imx8qm/imx8qm_bl31_setup.c index 2634c889..afb07233 100644 --- a/plat/imx/imx8qm/imx8qm_bl31_setup.c +++ b/plat/imx/imx8qm/imx8qm_bl31_setup.c @@ -29,6 +29,7 @@ #include <imx_sip_svc.h> #include <string.h> +#define DATA_SECTION_RESTORE_FLAG 0x11223344 #define TRUSTY_PARAMS_LEN_BYTES (4096*2) IMPORT_SYM(unsigned long, __COHERENT_RAM_START__, BL31_COHERENT_RAM_START); @@ -37,6 +38,8 @@ IMPORT_SYM(unsigned long, __RO_START__, BL31_RO_START); IMPORT_SYM(unsigned long, __RO_END__, BL31_RO_END); IMPORT_SYM(unsigned long, __RW_START__, BL31_RW_START); IMPORT_SYM(unsigned long, __RW_END__, BL31_RW_END); +IMPORT_SYM(unsigned long, __DATA_START__, BL31_DATA_START); +IMPORT_SYM(unsigned long, __DATA_END__, BL31_DATA_END); #if DEBUG_CONSOLE extern unsigned long console_list; @@ -398,6 +401,20 @@ void mx8_partition_resources(void) void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3) { + unsigned int count = (BL31_DATA_END - BL31_DATA_START) / 4; + unsigned int *data = (unsigned int *)(BL31_LIMIT - (BL31_DATA_END - BL31_DATA_START) - 0x4); + unsigned *ptr = (unsigned int *)BL31_DATA_START; + int i; + + if (*data != DATA_SECTION_RESTORE_FLAG) { + *data = DATA_SECTION_RESTORE_FLAG; + for (i = 0; i < count; i++) + *(++data) = *(ptr++); + } else { + for (i = 0; i < count; i++) + *(ptr++) = *(++data); + } + #if DEBUG_CONSOLE static console_lpuart_t console; diff --git a/plat/imx/imx8qx/imx8qx_bl31_setup.c b/plat/imx/imx8qx/imx8qx_bl31_setup.c index 4396846e..165846e5 100644 --- a/plat/imx/imx8qx/imx8qx_bl31_setup.c +++ b/plat/imx/imx8qx/imx8qx_bl31_setup.c @@ -29,6 +29,7 @@ #include <imx_sip_svc.h> #include <string.h> +#define DATA_SECTION_RESTORE_FLAG 0x11223344 #define TRUSTY_PARAMS_LEN_BYTES (4096*2) IMPORT_SYM(unsigned long, __COHERENT_RAM_START__, BL31_COHERENT_RAM_START); @@ -37,6 +38,8 @@ IMPORT_SYM(unsigned long, __RO_START__, BL31_RO_START); IMPORT_SYM(unsigned long, __RO_END__, BL31_RO_END); IMPORT_SYM(unsigned long, __RW_START__, BL31_RW_START); IMPORT_SYM(unsigned long, __RW_END__, BL31_RW_END); +IMPORT_SYM(unsigned long, __DATA_START__, BL31_DATA_START); +IMPORT_SYM(unsigned long, __DATA_END__, BL31_DATA_END); #if DEBUG_CONSOLE extern unsigned long console_list; @@ -376,6 +379,20 @@ void imx8_partition_resources(void) void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3) { + unsigned int count = (BL31_DATA_END - BL31_DATA_START) / 4; + unsigned int *data = (unsigned int *)(BL31_LIMIT - (BL31_DATA_END - BL31_DATA_START) - 0x4); + unsigned *ptr = (unsigned int *)BL31_DATA_START; + int i; + + if (*data != DATA_SECTION_RESTORE_FLAG) { + *data = DATA_SECTION_RESTORE_FLAG; + for (i = 0; i < count; i++) + *(++data) = *(ptr++); + } else { + for (i = 0; i < count; i++) + *(ptr++) = *(++data); + } + #if DEBUG_CONSOLE static console_lpuart_t console; |