1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 /***************************************************************************
4 * Copyright (C) 2005 by Dominic Rath *
5 * Dominic.Rath@gmx.de *
7 * Copyright (C) 2006 by Magnus Lundin *
10 * Copyright (C) 2008 by Spencer Oliver *
11 * spen@spen-soft.co.uk *
12 ***************************************************************************/
14 #ifndef OPENOCD_TARGET_ARMV7M_H
15 #define OPENOCD_TARGET_ARMV7M_H
18 #include "armv7m_trace.h"
22 extern const int armv7m_psp_reg_map
[];
23 extern const int armv7m_msp_reg_map
[];
25 const char *armv7m_exception_string(int number
);
27 /* Cortex-M DCRSR.REGSEL selectors */
47 ARMV7M_REGSEL_PC
= 15,
49 ARMV7M_REGSEL_xPSR
= 16,
53 ARMV8M_REGSEL_MSP_NS
= 0x18,
57 ARMV8M_REGSEL_MSPLIM_S
,
58 ARMV8M_REGSEL_PSPLIM_S
,
59 ARMV8M_REGSEL_MSPLIM_NS
,
60 ARMV8M_REGSEL_PSPLIM_NS
,
62 ARMV7M_REGSEL_PMSK_BPRI_FLTMSK_CTRL
= 0x14,
63 ARMV8M_REGSEL_PMSK_BPRI_FLTMSK_CTRL_S
= 0x22,
64 ARMV8M_REGSEL_PMSK_BPRI_FLTMSK_CTRL_NS
= 0x23,
65 ARMV7M_REGSEL_FPSCR
= 0x21,
67 /* 32bit Floating-point registers */
68 ARMV7M_REGSEL_S0
= 0x40,
102 /* offsets into armv7m core register cache */
104 /* for convenience, the first set of indices match
105 * the Cortex-M DCRSR.REGSEL selectors
107 ARMV7M_R0
= ARMV7M_REGSEL_R0
,
108 ARMV7M_R1
= ARMV7M_REGSEL_R1
,
109 ARMV7M_R2
= ARMV7M_REGSEL_R2
,
110 ARMV7M_R3
= ARMV7M_REGSEL_R3
,
112 ARMV7M_R4
= ARMV7M_REGSEL_R4
,
113 ARMV7M_R5
= ARMV7M_REGSEL_R5
,
114 ARMV7M_R6
= ARMV7M_REGSEL_R6
,
115 ARMV7M_R7
= ARMV7M_REGSEL_R7
,
117 ARMV7M_R8
= ARMV7M_REGSEL_R8
,
118 ARMV7M_R9
= ARMV7M_REGSEL_R9
,
119 ARMV7M_R10
= ARMV7M_REGSEL_R10
,
120 ARMV7M_R11
= ARMV7M_REGSEL_R11
,
122 ARMV7M_R12
= ARMV7M_REGSEL_R12
,
123 ARMV7M_R13
= ARMV7M_REGSEL_R13
,
124 ARMV7M_R14
= ARMV7M_REGSEL_R14
,
125 ARMV7M_PC
= ARMV7M_REGSEL_PC
,
127 ARMV7M_xPSR
= ARMV7M_REGSEL_xPSR
,
128 ARMV7M_MSP
= ARMV7M_REGSEL_MSP
,
129 ARMV7M_PSP
= ARMV7M_REGSEL_PSP
,
131 /* following indices are arbitrary, do not match DCRSR.REGSEL selectors */
133 /* A block of container and contained registers follows:
134 * THE ORDER IS IMPORTANT to the end of the block ! */
135 /* working register for packing/unpacking special regs, hidden from gdb */
136 ARMV7M_PMSK_BPRI_FLTMSK_CTRL
,
138 /* WARNING: If you use armv7m_write_core_reg() on one of 4 following
139 * special registers, the new data go to ARMV7M_PMSK_BPRI_FLTMSK_CTRL
140 * cache only and are not flushed to CPU HW register.
141 * To trigger write to CPU HW register, add
142 * armv7m_write_core_reg(,,ARMV7M_PMSK_BPRI_FLTMSK_CTRL,);
148 /* The end of block of container and contained registers */
150 /* ARMv8-M specific registers */
160 /* A block of container and contained registers follows:
161 * THE ORDER IS IMPORTANT to the end of the block ! */
162 ARMV8M_PMSK_BPRI_FLTMSK_CTRL_S
,
167 /* The end of block of container and contained registers */
169 /* A block of container and contained registers follows:
170 * THE ORDER IS IMPORTANT to the end of the block ! */
171 ARMV8M_PMSK_BPRI_FLTMSK_CTRL_NS
,
176 /* The end of block of container and contained registers */
178 /* 64bit Floating-point registers */
196 /* Floating-point status register */
199 /* for convenience add registers' block delimiters */
201 ARMV7M_CORE_FIRST_REG
= ARMV7M_R0
,
202 ARMV7M_CORE_LAST_REG
= ARMV7M_xPSR
,
203 ARMV7M_FPU_FIRST_REG
= ARMV7M_D0
,
204 ARMV7M_FPU_LAST_REG
= ARMV7M_FPSCR
,
205 ARMV8M_FIRST_REG
= ARMV8M_MSP_NS
,
206 ARMV8M_LAST_REG
= ARMV8M_CONTROL_NS
,
216 #define ARMV7M_NUM_CORE_REGS (ARMV7M_CORE_LAST_REG - ARMV7M_CORE_FIRST_REG + 1)
218 #define ARMV7M_COMMON_MAGIC 0x2A452A45
220 struct armv7m_common
{
224 int exception_number
;
226 /* AP this processor is connected to in the DAP */
227 struct adiv5_ap
*debug_ap
;
232 /* hla_target uses a high level adapter that does not support all functions */
235 struct armv7m_trace_config trace_config
;
237 /* Direct processor core register read and writes */
238 int (*load_core_reg_u32
)(struct target
*target
, uint32_t regsel
, uint32_t *value
);
239 int (*store_core_reg_u32
)(struct target
*target
, uint32_t regsel
, uint32_t value
);
241 int (*examine_debug_reason
)(struct target
*target
);
242 int (*post_debug_entry
)(struct target
*target
);
244 void (*pre_restore_context
)(struct target
*target
);
247 static inline bool is_armv7m(const struct armv7m_common
*armv7m
)
249 return armv7m
->common_magic
== ARMV7M_COMMON_MAGIC
;
253 * @returns the pointer to the target specific struct
254 * without matching a magic number.
255 * Use in target specific service routines, where the correct
256 * type of arch_info is certain.
258 static inline struct armv7m_common
*
259 target_to_armv7m(struct target
*target
)
261 return container_of(target
->arch_info
, struct armv7m_common
, arm
);
265 * @returns the pointer to the target specific struct
266 * or NULL if the magic number does not match.
267 * Use in a flash driver or any place where mismatch of the arch_info
270 static inline struct armv7m_common
*
271 target_to_armv7m_safe(struct target
*target
)
276 if (!target
->arch_info
)
279 /* Check the parent type first to prevent peeking memory too far
280 * from arch_info pointer */
281 if (!is_arm(target_to_arm(target
)))
284 struct armv7m_common
*armv7m
= target_to_armv7m(target
);
285 if (!is_armv7m(armv7m
))
291 struct armv7m_algorithm
{
294 enum arm_mode core_mode
;
296 uint32_t context
[ARMV7M_LAST_REG
]; /* ARMV7M_NUM_REGS */
299 struct reg_cache
*armv7m_build_reg_cache(struct target
*target
);
300 void armv7m_free_reg_cache(struct target
*target
);
302 enum armv7m_mode
armv7m_number_to_mode(int number
);
303 int armv7m_mode_to_number(enum armv7m_mode mode
);
305 int armv7m_arch_state(struct target
*target
);
306 int armv7m_get_gdb_reg_list(struct target
*target
,
307 struct reg
**reg_list
[], int *reg_list_size
,
308 enum target_register_class reg_class
);
310 int armv7m_init_arch_info(struct target
*target
, struct armv7m_common
*armv7m
);
312 int armv7m_run_algorithm(struct target
*target
,
313 int num_mem_params
, struct mem_param
*mem_params
,
314 int num_reg_params
, struct reg_param
*reg_params
,
315 target_addr_t entry_point
, target_addr_t exit_point
,
316 int timeout_ms
, void *arch_info
);
318 int armv7m_start_algorithm(struct target
*target
,
319 int num_mem_params
, struct mem_param
*mem_params
,
320 int num_reg_params
, struct reg_param
*reg_params
,
321 target_addr_t entry_point
, target_addr_t exit_point
,
324 int armv7m_wait_algorithm(struct target
*target
,
325 int num_mem_params
, struct mem_param
*mem_params
,
326 int num_reg_params
, struct reg_param
*reg_params
,
327 target_addr_t exit_point
, int timeout_ms
,
330 int armv7m_invalidate_core_regs(struct target
*target
);
332 int armv7m_restore_context(struct target
*target
);
334 uint32_t armv7m_map_id_to_regsel(unsigned int arm_reg_id
);
336 bool armv7m_map_reg_packing(unsigned int arm_reg_id
,
337 unsigned int *reg32_id
, uint32_t *offset
);
339 int armv7m_checksum_memory(struct target
*target
,
340 target_addr_t address
, uint32_t count
, uint32_t *checksum
);
341 int armv7m_blank_check_memory(struct target
*target
,
342 struct target_memory_check_block
*blocks
, int num_blocks
, uint8_t erased_value
);
344 int armv7m_maybe_skip_bkpt_inst(struct target
*target
, bool *inst_found
);
346 extern const struct command_registration armv7m_command_handlers
[];
348 #endif /* OPENOCD_TARGET_ARMV7M_H */
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)