target/cortex_m: cumulate DHCSR sticky bits
authorTomas Vanek <vanekt@fbl.cz>
Thu, 22 Apr 2021 08:41:50 +0000 (10:41 +0200)
committerTomas Vanek <vanekt@fbl.cz>
Thu, 18 Nov 2021 21:08:00 +0000 (21:08 +0000)
commit0dcf95c7171b702d70ec326f8c1a63cbc9255b6f
tree43bdf80d6e513698977d2ac7abf5d456c88e3070
parent111dcbeb1a54f629866449efe0c3b17ec1ab8957
target/cortex_m: cumulate DHCSR sticky bits

DCB DHCSR register contains S_RETIRE_ST and S_RESET_ST bits cleared
on a read.

The change introduces a helper function cortex_m_cumulate_dhcsr_sticky().
Call this function each time DHCSR is read to preserve S_RESET_ST state
in the case of a reset event was detected.

Introduce cortex_m_read_dhcsr_atomic_sticky() convenience helper to
read DHCSR, store it to cortex_m->dcb_dhcsr and cumulate sticky bits.

The cumulated state of S_RESET_ST is read and cleared in cortex_m_poll()

Change-Id: Ib679599f850fd219fb9418c6ff32eed7cf5740da
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/6180
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
src/target/cortex_m.c
src/target/cortex_m.h