OpenOCD
arm_jtag.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 /***************************************************************************
4  * Copyright (C) 2005 by Dominic Rath *
5  * Dominic.Rath@gmx.de *
6  * *
7  * Copyright (C) 2007-2010 Øyvind Harboe *
8  * oyvind.harboe@zylin.com *
9  ***************************************************************************/
10 
11 #ifndef OPENOCD_TARGET_ARM_JTAG_H
12 #define OPENOCD_TARGET_ARM_JTAG_H
13 
14 #include <jtag/jtag.h>
15 #include <helper/bits.h>
16 
17 struct arm_jtag {
18  struct jtag_tap *tap;
19 
20  uint32_t scann_size;
21  uint32_t scann_instr;
22  uint32_t cur_scan_chain;
23 
24  uint32_t intest_instr;
25 };
26 
27 int arm_jtag_set_instr_inner(struct jtag_tap *tap, uint32_t new_instr,
28  void *no_verify_capture,
29  tap_state_t end_state);
30 
31 static inline int arm_jtag_set_instr(struct jtag_tap *tap,
32  uint32_t new_instr, void *no_verify_capture, tap_state_t end_state)
33 {
34  /* inline most common code path */
35  if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != (new_instr & (BIT(tap->ir_length) - 1)))
36  return arm_jtag_set_instr_inner(tap, new_instr, no_verify_capture, end_state);
37 
38  return ERROR_OK;
39 
40 }
41 
42 int arm_jtag_scann_inner(struct arm_jtag *jtag_info, uint32_t new_scan_chain, tap_state_t end_state);
43 static inline int arm_jtag_scann(struct arm_jtag *jtag_info, uint32_t new_scan_chain, tap_state_t end_state)
44 {
45  /* inline most common code path */
46  int retval = ERROR_OK;
47  if (jtag_info->cur_scan_chain != new_scan_chain)
48  return arm_jtag_scann_inner(jtag_info, new_scan_chain, end_state);
49 
50  return retval;
51 }
52 
53 int arm_jtag_setup_connection(struct arm_jtag *jtag_info);
54 int arm_jtag_close_connection(struct arm_jtag *jtag_info);
55 
56 /* use this as a static so we can inline it in -O3 and refer to it via a pointer */
57 static inline void arm7flip32(jtag_callback_data_t arg)
58 {
59  uint8_t *in = (uint8_t *)arg;
60  *((uint32_t *)arg) = flip_u32(le_to_h_u32(in), 32);
61 }
62 
63 static inline void arm_le_to_h_u32(jtag_callback_data_t arg)
64 {
65  uint8_t *in = (uint8_t *)arg;
66  *((uint32_t *)arg) = le_to_h_u32(in);
67 }
68 
69 #endif /* OPENOCD_TARGET_ARM_JTAG_H */
int arm_jtag_setup_connection(struct arm_jtag *jtag_info)
Definition: arm_jtag.c:76
static int arm_jtag_scann(struct arm_jtag *jtag_info, uint32_t new_scan_chain, tap_state_t end_state)
Definition: arm_jtag.h:43
int arm_jtag_close_connection(struct arm_jtag *jtag_info)
Definition: arm_jtag.c:85
static int arm_jtag_set_instr(struct jtag_tap *tap, uint32_t new_instr, void *no_verify_capture, tap_state_t end_state)
Definition: arm_jtag.h:31
int arm_jtag_scann_inner(struct arm_jtag *jtag_info, uint32_t new_scan_chain, tap_state_t end_state)
Definition: arm_jtag.c:44
int arm_jtag_set_instr_inner(struct jtag_tap *tap, uint32_t new_instr, void *no_verify_capture, tap_state_t end_state)
Definition: arm_jtag.c:21
static void arm_le_to_h_u32(jtag_callback_data_t arg)
Definition: arm_jtag.h:63
static void arm7flip32(jtag_callback_data_t arg)
Definition: arm_jtag.h:57
uint32_t flip_u32(uint32_t value, unsigned int num)
Inverts the ordering of bits inside a 32-bit word (e.g.
Definition: binarybuffer.c:165
static uint32_t buf_get_u32(const uint8_t *_buffer, unsigned int first, unsigned int num)
Retrieves num bits from _buffer, starting at the first bit, returning the bits in a 32-bit word.
Definition: binarybuffer.h:104
The JTAG interface can be implemented with a software or hardware fifo.
enum tap_state tap_state_t
Defines JTAG Test Access Port states.
intptr_t jtag_callback_data_t
Defines the type of data passed to the jtag_callback_t interface.
Definition: jtag.h:336
#define ERROR_OK
Definition: log.h:164
#define BIT(nr)
Definition: stm32l4x.h:18
uint32_t scann_size
Definition: arm_jtag.h:20
uint32_t scann_instr
Definition: arm_jtag.h:21
uint32_t intest_instr
Definition: arm_jtag.h:24
struct jtag_tap * tap
Definition: arm_jtag.h:18
uint32_t cur_scan_chain
Definition: arm_jtag.h:22
Definition: jtag.h:101
uint8_t * cur_instr
current instruction
Definition: jtag.h:132
unsigned int ir_length
size of instruction register
Definition: jtag.h:110
static uint32_t le_to_h_u32(const uint8_t *buf)
Definition: types.h:112