Commit aa79421c authored by Manish V Badarkhe's avatar Manish V Badarkhe
Browse files

refactor(plat/arm): use mmio* functions to read/write NVFLAGS registers



Used mmio* functions to read/write NVFLAGS registers to avoid
possibile reordering of instructions by compiler.

Change-Id: Iae50ac30e5413259cf8554f0fff47512ad83b0fd
Signed-off-by: default avatarManish V Badarkhe <Manish.Badarkhe@arm.com>
parent 79d8be3c
/* /*
* Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2015-2021, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -62,11 +62,11 @@ static int is_watchdog_reset(void) ...@@ -62,11 +62,11 @@ static int is_watchdog_reset(void)
******************************************************************************/ ******************************************************************************/
bool plat_arm_bl1_fwu_needed(void) bool plat_arm_bl1_fwu_needed(void)
{ {
const int32_t *nv_flags_ptr = (const int32_t *)V2M_SYS_NVFLAGS_ADDR; int32_t nv_flags = (int32_t)mmio_read_32(V2M_SYS_NVFLAGS_ADDR);
/* Check if TOC is invalid or watchdog reset happened. */ /* Check if TOC is invalid or watchdog reset happened. */
return (!arm_io_is_toc_valid() || (((*nv_flags_ptr == -EAUTH) || return (!arm_io_is_toc_valid() || (((nv_flags == -EAUTH) ||
(*nv_flags_ptr == -ENOENT)) && is_watchdog_reset())); (nv_flags == -ENOENT)) && is_watchdog_reset()));
} }
/******************************************************************************* /*******************************************************************************
...@@ -86,13 +86,11 @@ void bl1_plat_set_ep_info(unsigned int image_id, ...@@ -86,13 +86,11 @@ void bl1_plat_set_ep_info(unsigned int image_id,
******************************************************************************/ ******************************************************************************/
__dead2 void bl1_plat_fwu_done(void *client_cookie, void *reserved) __dead2 void bl1_plat_fwu_done(void *client_cookie, void *reserved)
{ {
unsigned int *nv_flags_clr = (unsigned int *) uint32_t nv_flags = mmio_read_32(V2M_SYS_NVFLAGS_ADDR);
(V2M_SYSREGS_BASE + V2M_SYS_NVFLAGSCLR);
unsigned int *nv_flags_ptr = (unsigned int *)
(V2M_SYSREGS_BASE + V2M_SYS_NVFLAGS);
/* Clear the NV flags register. */ /* Clear the NV flags register. */
*nv_flags_clr = *nv_flags_ptr; mmio_write_32((V2M_SYSREGS_BASE + V2M_SYS_NVFLAGSCLR),
nv_flags);
/* Setup the watchdog to reset the system as soon as possible */ /* Setup the watchdog to reset the system as soon as possible */
sp805_refresh(ARM_SP805_TWDG_BASE, 1U); sp805_refresh(ARM_SP805_TWDG_BASE, 1U);
......
/* /*
* Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2015-2021, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -16,10 +16,8 @@ ...@@ -16,10 +16,8 @@
*/ */
void __dead2 plat_arm_error_handler(int err) void __dead2 plat_arm_error_handler(int err)
{ {
uint32_t *flags_ptr = (uint32_t *)V2M_SYS_NVFLAGS_ADDR;
/* Propagate the err code in the NV-flags register */ /* Propagate the err code in the NV-flags register */
*flags_ptr = err; mmio_write_32(V2M_SYS_NVFLAGS_ADDR, (uint32_t)err);
/* Setup the watchdog to reset the system as soon as possible */ /* Setup the watchdog to reset the system as soon as possible */
sp805_refresh(ARM_SP805_TWDG_BASE, 1U); sp805_refresh(ARM_SP805_TWDG_BASE, 1U);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment