target: consolidate existing target/algo common_magic
authorTomas Vanek <vanekt@fbl.cz>
Thu, 26 May 2022 08:01:45 +0000 (10:01 +0200)
committerTomas Vanek <vanekt@fbl.cz>
Sun, 14 Aug 2022 12:02:38 +0000 (12:02 +0000)
Unify common_magic type to unsigned int
Move common_magic to be the first member of the struct
Add unsigned specifier to xxx_COMMON_MAGIC #defines

Change-Id: If961d33232698529514ba3720e04418baf6dc6fe
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/6996
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
23 files changed:
src/target/aarch64.h
src/target/arc.h
src/target/arm.h
src/target/arm720t.h
src/target/arm7_9_common.h
src/target/arm920t.h
src/target/arm926ejs.h
src/target/arm946e.h
src/target/arm966e.h
src/target/armv7a.h
src/target/armv7m.h
src/target/armv8.h
src/target/avr32_ap7k.h
src/target/cortex_a.h
src/target/cortex_m.h
src/target/mips32.h
src/target/mips64.h
src/target/mips_m4k.h
src/target/mips_mips64.h
src/target/nds32.h
src/target/stm8.h
src/target/x86_32_common.h
src/target/xscale.h

index 902a508e4fe583ecf0357c4297c0610c053c1424..52b3bafcdf1864dc3cc6d6771df603cc70fee2ff 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "armv8.h"
 
-#define AARCH64_COMMON_MAGIC 0x411fc082
+#define AARCH64_COMMON_MAGIC 0x411fc082U
 
 #define CPUDBG_CPUID   0xD00
 #define CPUDBG_CTYPR   0xD04
@@ -38,7 +38,7 @@ struct aarch64_brp {
 };
 
 struct aarch64_common {
-       int common_magic;
+       unsigned int common_magic;
 
        /* Context information */
        uint32_t system_control_reg;
index 86d8d09d55eff2d28c0adb6c78c8efe863877090..bb70a598e100a7b4feea7c35be32145485bf66ac 100644 (file)
@@ -27,7 +27,7 @@
 #include "arc_cmd.h"
 #include "arc_mem.h"
 
-#define ARC_COMMON_MAGIC       0xB32EB324  /* just a unique number */
+#define ARC_COMMON_MAGIC       0xB32EB324U  /* just a unique number */
 
 #define AUX_DEBUG_REG                   0x5
 #define AUX_PC_REG                      0x6
@@ -183,7 +183,7 @@ struct arc_actionpoint {
 };
 
 struct arc_common {
-       uint32_t common_magic;
+       unsigned int common_magic;
 
        struct arc_jtag jtag_info;
 
index e264293f4ed1f52055cf91e4254f612e327e2d08..f262255ab353668e63483ae29e354066131cb21e 100644 (file)
@@ -155,7 +155,7 @@ enum arm_vfp_version {
        ARM_VFP_V3,
 };
 
-#define ARM_COMMON_MAGIC 0x0A450A45
+#define ARM_COMMON_MAGIC 0x0A450A45U
 
 /**
  * Represents a generic ARM core, with standard application registers.
@@ -165,7 +165,8 @@ enum arm_vfp_version {
  * registers as traditional ARM cores, and only support Thumb2 instructions.
  */
 struct arm {
-       int common_magic;
+       unsigned int common_magic;
+
        struct reg_cache *core_cache;
 
        /** Handle to the PC; valid in all core modes. */
@@ -252,7 +253,7 @@ static inline bool is_arm(struct arm *arm)
 }
 
 struct arm_algorithm {
-       int common_magic;
+       unsigned int common_magic;
 
        enum arm_mode core_mode;
        enum arm_state core_state;
index 81c6e1f6adcd4e51e053764cc121ab4061629817..65bd78ff080111534ffd716d728c7f40e8ef8baa 100644 (file)
 #include "arm7tdmi.h"
 #include "armv4_5_mmu.h"
 
-#define        ARM720T_COMMON_MAGIC 0xa720a720
+#define        ARM720T_COMMON_MAGIC 0xa720a720U
 
 struct arm720t_common {
+       unsigned int common_magic;
+
        struct arm7_9_common arm7_9_common;
-       uint32_t common_magic;
        struct armv4_5_mmu_common armv4_5_mmu;
        uint32_t cp15_control_reg;
        uint32_t fsr_reg;
index 805fbc918e878c93c37051d5dc49556dd483bd56..92d0fd51a23a173fd84c2cf45eacd0b90a7fce82 100644 (file)
 #include "arm.h"
 #include "arm_jtag.h"
 
-#define        ARM7_9_COMMON_MAGIC 0x0a790a79 /**< */
+#define        ARM7_9_COMMON_MAGIC 0x0a790a79U /**< */
 
 /**
  * Structure for items that are common between both ARM7 and ARM9 targets.
  */
 struct arm7_9_common {
+       unsigned int common_magic;
+
        struct arm arm;
-       uint32_t common_magic;
 
        struct arm_jtag jtag_info; /**< JTAG information for target */
        struct reg_cache *eice_cache; /**< Embedded ICE register cache */
index 49ec3c00014f7bd976afff5066d52d885f924ef8..eba768ffff4cb922073520ce2c162cecd116e03b 100644 (file)
 #include "arm9tdmi.h"
 #include "armv4_5_mmu.h"
 
-#define        ARM920T_COMMON_MAGIC 0xa920a920
+#define        ARM920T_COMMON_MAGIC 0xa920a920U
 
 struct arm920t_common {
+       unsigned int common_magic;
+
        struct arm7_9_common arm7_9_common;
-       uint32_t common_magic;
        struct armv4_5_mmu_common armv4_5_mmu;
        uint32_t cp15_control_reg;
        uint32_t d_fsr;
index c652a3b092b3dd520ea9b9b42a4df3d1d1e617a1..479128e61517bd1aa8f2517d43a2dec8018611b2 100644 (file)
 #include "arm9tdmi.h"
 #include "armv4_5_mmu.h"
 
-#define        ARM926EJS_COMMON_MAGIC 0xa926a926
+#define        ARM926EJS_COMMON_MAGIC 0xa926a926U
 
 struct arm926ejs_common {
+       unsigned int common_magic;
+
        struct arm7_9_common arm7_9_common;
-       uint32_t common_magic;
        struct armv4_5_mmu_common armv4_5_mmu;
        int (*read_cp15)(struct target *target, uint32_t op1, uint32_t op2,
                        uint32_t crn, uint32_t crm, uint32_t *value);
index b205534fd924955da2b4630f1cf1122860b2de7a..7416878690f96339552541bf2f113e5abe5be6cc 100644 (file)
 
 #include "arm9tdmi.h"
 
-#define ARM946E_COMMON_MAGIC 0x20f920f9
+#define ARM946E_COMMON_MAGIC 0x20f920f9U
 
 struct arm946e_common {
+       unsigned int common_magic;
+
        struct arm7_9_common arm7_9_common;
-       int common_magic;
        uint32_t cp15_control_reg;
        uint32_t cp15_cache_info;
 };
index e41b850376d2627e72ced30f309296fd0b23fc33..be2b3391e877500f043bbb91ea9abf2629420f67 100644 (file)
 
 #include "arm9tdmi.h"
 
-#define        ARM966E_COMMON_MAGIC 0x20f920f9
+#define        ARM966E_COMMON_MAGIC 0x20f920f9U
 
 struct arm966e_common {
+       unsigned int common_magic;
+
        struct arm7_9_common arm7_9_common;
-       int common_magic;
        uint32_t cp15_control_reg;
 };
 
index ebd38f0f680b20eb06e7daec2a108a6f8c31da7f..6b9c2a68f42f431198d4a7426d33d96eaf32505b 100644 (file)
@@ -19,7 +19,7 @@ enum {
        ARM_CPSR = 16
 };
 
-#define ARMV7_COMMON_MAGIC 0x0A450999
+#define ARMV7_COMMON_MAGIC 0x0A450999U
 
 /* VA to PA translation operations opc2 values*/
 #define V2PCWPR  0
@@ -87,8 +87,9 @@ struct armv7a_mmu_common {
 };
 
 struct armv7a_common {
+       unsigned int common_magic;
+
        struct arm arm;
-       int common_magic;
        struct reg_cache *core_cache;
 
        /* Core Debug Unit */
index 6d97e4ac512a5828ebff755bde5a757f84cdfca4..9ac6b9ec9dc2fe6aa1d294e937a4764ac679d16f 100644 (file)
@@ -215,12 +215,13 @@ enum {
 
 #define ARMV7M_NUM_CORE_REGS (ARMV7M_CORE_LAST_REG - ARMV7M_CORE_FIRST_REG + 1)
 
-#define ARMV7M_COMMON_MAGIC 0x2A452A45
+#define ARMV7M_COMMON_MAGIC 0x2A452A45U
 
 struct armv7m_common {
+       unsigned int common_magic;
+
        struct arm arm;
 
-       int common_magic;
        int exception_number;
 
        /* AP this processor is connected to in the DAP */
@@ -289,7 +290,7 @@ target_to_armv7m_safe(struct target *target)
 }
 
 struct armv7m_algorithm {
-       int common_magic;
+       unsigned int common_magic;
 
        enum arm_mode core_mode;
 
index 912da675cdd3770eb4f0990b8e97bc0e2c2a988b..e06067175bb044758873f54ee8c55c4444417dc4 100644 (file)
@@ -108,7 +108,7 @@ enum run_control_op {
        ARMV8_RUNCONTROL_STEP = 3,
 };
 
-#define ARMV8_COMMON_MAGIC 0x0A450AAA
+#define ARMV8_COMMON_MAGIC 0x0A450AAAU
 
 /* VA to PA translation operations opc2 values*/
 #define V2PCWPR  0
@@ -178,8 +178,9 @@ struct armv8_mmu_common {
 };
 
 struct armv8_common {
+       unsigned int common_magic;
+
        struct arm arm;
-       int common_magic;
        struct reg_cache *core_cache;
 
        /* Core Debug Unit */
index 6984b610137814071b5b1f1c6077e55f90a8d9c9..ac35754f47df724a31e7cac825eee84749a23cb3 100644 (file)
@@ -9,9 +9,11 @@
 
 struct target;
 
-#define AP7K_COMMON_MAGIC      0x4150374b
+#define AP7K_COMMON_MAGIC      0x4150374bU
+
 struct avr32_ap7k_common {
-       int common_magic;
+       unsigned int common_magic;
+
        struct avr32_jtag jtag;
        struct reg_cache *core_cache;
        uint32_t core_regs[AVR32NUMCOREREGS];
index 05c3730c253cb789b553b59ee9e8b3b7c707298b..656ccea8a5798a3f35132edbd94c919445641f4b 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "armv7a.h"
 
-#define CORTEX_A_COMMON_MAGIC 0x411fc082
+#define CORTEX_A_COMMON_MAGIC 0x411fc082U
 
 #define CORTEX_A5_PARTNUM 0xc05
 #define CORTEX_A7_PARTNUM 0xc07
@@ -67,7 +67,7 @@ struct cortex_a_wrp {
 };
 
 struct cortex_a_common {
-       int common_magic;
+       unsigned int common_magic;
 
        /* Context information */
        uint32_t cpudbg_dscr;
index 3f0d55c1c24f5160ef3e6505c9413c0f5d4262a5..54767c5dfd62a6e0ef535a671af8bef9bcb10884 100644 (file)
@@ -17,7 +17,7 @@
 #include "armv7m.h"
 #include "helper/bits.h"
 
-#define CORTEX_M_COMMON_MAGIC 0x1A451A45
+#define CORTEX_M_COMMON_MAGIC 0x1A451A45U
 
 #define SYSTEM_CONTROL_BASE 0x400FE000
 
@@ -199,7 +199,7 @@ enum cortex_m_isrmasking_mode {
 };
 
 struct cortex_m_common {
-       int common_magic;
+       unsigned int common_magic;
 
        /* Context information */
        uint32_t dcb_dhcsr;
index ca02dda451377719e32074bc936da25036e6aec2..8837da1d08a27b74bb7a5c787d389c5f0b782a27 100644 (file)
@@ -16,7 +16,7 @@
 #include "target.h"
 #include "mips32_pracc.h"
 
-#define MIPS32_COMMON_MAGIC            0xB320B320
+#define MIPS32_COMMON_MAGIC            0xB320B320U
 
 /**
  * Memory segments (32bit kernel mode addresses)
@@ -82,7 +82,8 @@ struct mips32_comparator {
 };
 
 struct mips32_common {
-       uint32_t common_magic;
+       unsigned int common_magic;
+
        void *arch_info;
        struct reg_cache *core_cache;
        struct mips_ejtag ejtag_info;
@@ -119,7 +120,7 @@ struct mips32_core_reg {
 };
 
 struct mips32_algorithm {
-       int common_magic;
+       unsigned int common_magic;
        enum mips32_isa_mode isa_mode;
 };
 
index 3453e4ed1ab6f62e20fbc0a145680103a4f3383b..9079c8013de21c1177a0c7ccb50fba978fffc07e 100644 (file)
@@ -19,7 +19,7 @@
 #include "register.h"
 #include "mips64_pracc.h"
 
-#define MIPS64_COMMON_MAGIC            0xB640B640
+#define MIPS64_COMMON_MAGIC            0xB640B640U
 
 /* MIPS64 CP0 registers */
 #define MIPS64_C0_INDEX                0
@@ -81,7 +81,8 @@ struct mips64_comparator {
 };
 
 struct mips64_common {
-       uint32_t common_magic;
+       unsigned int common_magic;
+
        void *arch_info;
        struct reg_cache *core_cache;
        struct mips_ejtag ejtag_info;
index ae4a0ff722401e1ed2d51094cbfc62cf81681240..b563ea513aa76ebf35bc248c2fd4495213e9b224 100644 (file)
 
 struct target;
 
-#define MIPSM4K_COMMON_MAGIC   0xB321B321
+#define MIPSM4K_COMMON_MAGIC   0xB321B321U
 
 struct mips_m4k_common {
-       uint32_t common_magic;
+       unsigned int common_magic;
+
        bool is_pic32mx;
        struct mips32_common mips32;
 };
index 69fb2a6f98d2630350986433f5d0fdffff70d9e7..9841deb2fd437c8c7bd48b93f029fbca25a48cb4 100644 (file)
@@ -17,7 +17,8 @@
 #include "helper/types.h"
 
 struct mips_mips64_common {
-       int common_magic;
+       unsigned int common_magic;
+
        struct mips64_common mips64_common;
 };
 
index 1c8675e731227353c153569d96b9e406146f0065..d0b680a97c6546cab70b4df6f1e265795d8f209b 100644 (file)
@@ -224,7 +224,8 @@ struct nds32_misc_config {
  * Represents a generic Andes core.
  */
 struct nds32 {
-       uint32_t common_magic;
+       unsigned int common_magic;
+
        struct reg_cache *core_cache;
 
        /** Handle for the debug module. */
index bbda4feb681860b4a051a37dee7ff11c7a455df2..55e1071aba4c681d5cbbe59ef5067ccb3a73e121 100644 (file)
 
 struct target;
 
-#define STM8_COMMON_MAGIC      0x53544D38
+#define STM8_COMMON_MAGIC      0x53544D38U
 #define STM8_NUM_CORE_REGS 6
 
 struct stm8_common {
-       uint32_t common_magic;
+       unsigned int common_magic;
+
        void *arch_info;
        struct reg_cache *core_cache;
        uint32_t core_regs[STM8_NUM_CORE_REGS];
index 4f90ab4e677c1b2c9776354c309d2ed0d3b5d141..7392447a68715d65ebe5d67d87e00e59fbd89fc9 100644 (file)
@@ -148,7 +148,7 @@ enum {
        PMCR,
 };
 
-#define X86_32_COMMON_MAGIC 0x86328632
+#define X86_32_COMMON_MAGIC 0x86328632U
 
 enum {
        /* memory read/write */
@@ -200,7 +200,8 @@ struct swbp_mem_patch {
 #define NUM_PM_REGS            18 /* regs used in save/restore */
 
 struct x86_32_common {
-       uint32_t common_magic;
+       unsigned int common_magic;
+
        void *arch_info;
        enum x86_core_type core_type;
        struct reg_cache *cache;
index 0087b8a43b774c4335fe3e6ea17f085ce68238e0..36a69bca3998b3bc10b6c1751058d1f4362756bf 100644 (file)
@@ -15,7 +15,7 @@
 #include "armv4_5_mmu.h"
 #include "trace.h"
 
-#define        XSCALE_COMMON_MAGIC 0x58534341
+#define        XSCALE_COMMON_MAGIC 0x58534341U
 
 /* These four JTAG instructions are architecturally defined.
  * Lengths are core-specific; originally 5 bits, later 7.
@@ -71,11 +71,11 @@ struct xscale_trace {
 };
 
 struct xscale_common {
+       unsigned int common_magic;
+
        /* armv4/5 common stuff */
        struct arm arm;
 
-       int common_magic;
-
        /* XScale registers (CP15, DBG) */
        struct reg_cache *reg_cache;