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/+/6751

-- gerrit

commit 620afb0c83d1d9f4a4b0c0b50118daefd147c222
Author: Tomas Vanek <van...@fbl.cz>
Date:   Thu Nov 25 06:13:31 2021 +0100

    target/cortex_m: add Cortex-M part number getter
    
    The getter checks the magic numbers in arch_info to detect eventual
    type mismatch.
    
    Change-Id: I61134b05310a97ae9831517d0516c7b4240d35a5
    Signed-off-by: Tomas Vanek <van...@fbl.cz>

diff --git a/src/target/cortex_m.h b/src/target/cortex_m.h
index 8fb34f46c..555401416 100644
--- a/src/target/cortex_m.h
+++ b/src/target/cortex_m.h
@@ -46,6 +46,7 @@
 #define ARM_CPUID_PARTNO_MASK  (0xFFF << ARM_CPUID_PARTNO_POS)
 
 enum cortex_m_partno {
+       CORTEX_M_PARTNO_INVALID,
        CORTEX_M0_PARTNO   = 0xC20,
        CORTEX_M1_PARTNO   = 0xC21,
        CORTEX_M3_PARTNO   = 0xC23,
@@ -294,6 +295,23 @@ target_to_cortex_m_safe(struct target *target)
        return cortex_m;
 }
 
+/**
+ * @returns cached value of Cortex-M part number
+ * or CORTEX_M_PARTNO_INVALID if the magic number does not match
+ * or core_info is not initialised.
+ */
+static inline enum cortex_m_partno cortex_m_get_partno_safe(struct target 
*target)
+{
+       struct cortex_m_common *cortex_m = target_to_cortex_m_safe(target);
+       if (!cortex_m)
+               return CORTEX_M_PARTNO_INVALID;
+
+       if (!cortex_m->core_info)
+               return CORTEX_M_PARTNO_INVALID;
+
+       return cortex_m->core_info->partno;
+}
+
 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);

-- 

Reply via email to