OpenOCD
esirisc_jtag.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 /***************************************************************************
4  * Copyright (C) 2018 by Square, Inc. *
5  * Steven Stallion <stallion@squareup.com> *
6  * James Zhao <hjz@squareup.com> *
7  ***************************************************************************/
8 
9 #ifndef OPENOCD_TARGET_ESIRISC_JTAG_H
10 #define OPENOCD_TARGET_ESIRISC_JTAG_H
11 
12 #include <helper/types.h>
13 #include <jtag/jtag.h>
14 
15 /* TAP Instructions */
16 #define INSTR_IDCODE 0x8
17 #define INSTR_DEBUG 0x9
18 #define INSTR_BYPASS 0xf
19 #define INSTR_LENGTH 4
20 
21 /* eSi-Debug Commands */
22 #define DEBUG_NOP 0x00
23 #define DEBUG_READ_BYTE 0x10
24 #define DEBUG_READ_HWORD 0x20
25 #define DEBUG_READ_WORD 0x30
26 #define DEBUG_WRITE_BYTE 0x60
27 #define DEBUG_WRITE_HWORD 0x70
28 #define DEBUG_WRITE_WORD 0x80
29 #define DEBUG_READ_REG 0xb0
30 #define DEBUG_WRITE_REG 0xc0
31 #define DEBUG_READ_CSR 0xd0
32 #define DEBUG_WRITE_CSR 0xe0
33 #define DEBUG_ENABLE_DEBUG 0xf0
34 #define DEBUG_DISABLE_DEBUG 0xf2
35 #define DEBUG_ASSERT_RESET 0xf4
36 #define DEBUG_DEASSERT_RESET 0xf6
37 #define DEBUG_BREAK 0xf8
38 #define DEBUG_CONTINUE 0xfa
39 #define DEBUG_FLUSH_CACHES 0xfc
40 
41 /* Exception IDs */
42 #define EID_OVERFLOW 0x3d
43 #define EID_CANT_DEBUG 0x3e
44 #define EID_NONE 0x3f
45 
46 /* Byte Stuffing */
47 #define STUFF_MARKER 0x55
48 #define PAD_BYTE 0xaa
49 
50 struct esirisc_jtag {
51  struct jtag_tap *tap;
52  uint8_t status;
53 };
54 
55 bool esirisc_jtag_is_debug_active(struct esirisc_jtag *jtag_info);
56 bool esirisc_jtag_is_stopped(struct esirisc_jtag *jtag_info);
57 
58 int esirisc_jtag_read_byte(struct esirisc_jtag *jtag_info,
59  uint32_t address, uint8_t *data);
60 int esirisc_jtag_read_hword(struct esirisc_jtag *jtag_info,
61  uint32_t address, uint16_t *data);
62 int esirisc_jtag_read_word(struct esirisc_jtag *jtag_info,
63  uint32_t address, uint32_t *data);
64 
65 int esirisc_jtag_write_byte(struct esirisc_jtag *jtag_info,
66  uint32_t address, uint8_t data);
67 int esirisc_jtag_write_hword(struct esirisc_jtag *jtag_info,
68  uint32_t address, uint16_t data);
69 int esirisc_jtag_write_word(struct esirisc_jtag *jtag_info,
70  uint32_t address, uint32_t data);
71 
72 int esirisc_jtag_read_reg(struct esirisc_jtag *jtag_info,
73  uint8_t reg, uint32_t *data);
74 int esirisc_jtag_write_reg(struct esirisc_jtag *jtag_info,
75  uint8_t reg, uint32_t data);
76 
77 int esirisc_jtag_read_csr(struct esirisc_jtag *jtag_info,
78  uint8_t bank, uint8_t csr, uint32_t *data);
79 int esirisc_jtag_write_csr(struct esirisc_jtag *jtag_info,
80  uint8_t bank, uint8_t csr, uint32_t data);
81 
82 int esirisc_jtag_enable_debug(struct esirisc_jtag *jtag_info);
83 
84 int esirisc_jtag_assert_reset(struct esirisc_jtag *jtag_info);
85 int esirisc_jtag_deassert_reset(struct esirisc_jtag *jtag_info);
86 
87 int esirisc_jtag_break(struct esirisc_jtag *jtag_info);
88 int esirisc_jtag_continue(struct esirisc_jtag *jtag_info);
89 
90 int esirisc_jtag_flush_caches(struct esirisc_jtag *jtag_info);
91 
92 #endif /* OPENOCD_TARGET_ESIRISC_JTAG_H */
uint8_t csr
Definition: esirisc.c:136
uint8_t bank
Definition: esirisc.c:135
int esirisc_jtag_read_hword(struct esirisc_jtag *jtag_info, uint32_t address, uint16_t *data)
Definition: esirisc_jtag.c:267
int esirisc_jtag_read_csr(struct esirisc_jtag *jtag_info, uint8_t bank, uint8_t csr, uint32_t *data)
Definition: esirisc_jtag.c:431
int esirisc_jtag_deassert_reset(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:505
int esirisc_jtag_read_reg(struct esirisc_jtag *jtag_info, uint8_t reg, uint32_t *data)
Definition: esirisc_jtag.c:385
int esirisc_jtag_read_byte(struct esirisc_jtag *jtag_info, uint32_t address, uint8_t *data)
Definition: esirisc_jtag.c:239
int esirisc_jtag_write_byte(struct esirisc_jtag *jtag_info, uint32_t address, uint8_t data)
Definition: esirisc_jtag.c:323
int esirisc_jtag_continue(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:515
int esirisc_jtag_flush_caches(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:520
bool esirisc_jtag_is_debug_active(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:216
int esirisc_jtag_write_csr(struct esirisc_jtag *jtag_info, uint8_t bank, uint8_t csr, uint32_t data)
Definition: esirisc_jtag.c:459
int esirisc_jtag_write_reg(struct esirisc_jtag *jtag_info, uint8_t reg, uint32_t data)
Definition: esirisc_jtag.c:411
int esirisc_jtag_read_word(struct esirisc_jtag *jtag_info, uint32_t address, uint32_t *data)
Definition: esirisc_jtag.c:295
bool esirisc_jtag_is_stopped(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:221
int esirisc_jtag_assert_reset(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:500
int esirisc_jtag_write_word(struct esirisc_jtag *jtag_info, uint32_t address, uint32_t data)
Definition: esirisc_jtag.c:364
int esirisc_jtag_write_hword(struct esirisc_jtag *jtag_info, uint32_t address, uint16_t data)
Definition: esirisc_jtag.c:343
int esirisc_jtag_enable_debug(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:490
int esirisc_jtag_break(struct esirisc_jtag *jtag_info)
Definition: esirisc_jtag.c:510
The JTAG interface can be implemented with a software or hardware fifo.
struct jtag_tap * tap
Definition: esirisc_jtag.h:51
uint8_t status
Definition: esirisc_jtag.h:52
Definition: jtag.h:101
Definition: register.h:111