This is an automated email from Gerrit. "Tomas Vanek <van...@fbl.cz>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/6772
-- gerrit commit 88335da9cc9ec917f5d54a53bfdb6f8b40653402 Author: Tomas Vanek <van...@fbl.cz> Date: Fri Dec 10 17:27:54 2021 +0100 target/cortex_m: add address helpers cortex_m_is_execute_never() checks for XN areas. cortex_m_is_magic() checks for magic address used for exception return or lockup. Change-Id: I1dbcfc06aeb63b0c3bd6df6a94965f60d4fe4466 Signed-off-by: Tomas Vanek <van...@fbl.cz> diff --git a/src/target/cortex_m.h b/src/target/cortex_m.h index c2f836a35..426c473a0 100644 --- a/src/target/cortex_m.h +++ b/src/target/cortex_m.h @@ -267,6 +267,36 @@ static inline bool is_cortex_m_with_dap_access(const struct cortex_m_common *cor return !cortex_m->armv7m.is_hla_target; } +/** Check for XN (execute never) address + * ARMv7-M Architecture Reference Manual B3.1 The system address map + * Armv8-M Architecture Reference Manual B8.1 System address map + */ +static inline bool cortex_m_is_execute_never(uint32_t address) +{ + /* Peripheral */ + if ((address & 0xe0000000) == 0x40000000) + return true; + if (address > 0xa0000000) + return true; + return false; +} + +/** Check for magic PC/LR values used for exception return or lockup + * ARMv7-M Architecture Reference Manual B1.5.8 Exception return behavior + * Armv8-M Architecture Reference Manual + * D1.2.95 EXC_RETURN, Exception Return Payload + * B3.33 Lockup + */ +static inline bool cortex_m_is_magic(uint32_t address) +{ + /* Detect only actually used EXC_RETURN space, not reserved area */ + if ((address & 0xffffff80) == 0xffffff80) + return true; + if (address == 0xeffffffe) + return true; + return false; +} + int cortex_m_examine(struct target *target); int cortex_m_set_breakpoint(struct target *target, struct breakpoint *breakpoint); int cortex_m_unset_breakpoint(struct target *target, struct breakpoint *breakpoint); --