OpenOCD
aice_port.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 /***************************************************************************
4  * Copyright (C) 2013 by Andes Technology *
5  * Hsiangkai Wang <hkwang@andestech.com> *
6  ***************************************************************************/
7 
8 #ifndef OPENOCD_JTAG_AICE_AICE_PORT_H
9 #define OPENOCD_JTAG_AICE_AICE_PORT_H
10 
11 #include <target/nds32_edm.h>
12 
13 #define AICE_MAX_NUM_CORE (0x10)
14 
15 #define ERROR_AICE_DISCONNECT (-200)
16 #define ERROR_AICE_TIMEOUT (-201)
17 
26 };
27 
29  AICE_SRST = 0x1,
31 };
32 
36 };
37 
38 enum aice_api_s {
39  AICE_OPEN = 0x0,
72 };
73 
78 };
79 
87 };
88 
93 };
94 
97  const char *device_desc;
99  uint16_t vid;
101  uint16_t pid;
104 };
105 
106 struct aice_port_s {
108  uint32_t coreid;
110  const struct aice_port *port;
111 };
112 
115 
119  int (*open)(struct aice_port_param_s *param);
121  int (*close)(void);
123  int (*reset)(void);
125  int (*idcode)(uint32_t *idcode, uint8_t *num_of_idcode);
127  int (*set_jtag_clock)(uint32_t a_clock);
129  int (*assert_srst)(uint32_t coreid, enum aice_srst_type_s srst);
131  int (*run)(uint32_t coreid);
133  int (*halt)(uint32_t coreid);
135  int (*step)(uint32_t coreid);
137  int (*read_reg)(uint32_t coreid, uint32_t num, uint32_t *val);
139  int (*write_reg)(uint32_t coreid, uint32_t num, uint32_t val);
141  int (*read_reg_64)(uint32_t coreid, uint32_t num, uint64_t *val);
143  int (*write_reg_64)(uint32_t coreid, uint32_t num, uint64_t val);
145  int (*read_mem_unit)(uint32_t coreid, uint32_t addr, uint32_t size,
146  uint32_t count, uint8_t *buffer);
148  int (*write_mem_unit)(uint32_t coreid, uint32_t addr, uint32_t size,
149  uint32_t count, const uint8_t *buffer);
151  int (*read_mem_bulk)(uint32_t coreid, uint32_t addr, uint32_t length,
152  uint8_t *buffer);
154  int (*write_mem_bulk)(uint32_t coreid, uint32_t addr, uint32_t length,
155  const uint8_t *buffer);
157  int (*read_debug_reg)(uint32_t coreid, uint32_t addr, uint32_t *val);
159  int (*write_debug_reg)(uint32_t coreid, uint32_t addr, const uint32_t val);
160 
162  int (*state)(uint32_t coreid, enum aice_target_state_s *state);
163 
165  int (*memory_access)(uint32_t coreid, enum nds_memory_access a_access);
167  int (*memory_mode)(uint32_t coreid, enum nds_memory_select mem_select);
168 
170  int (*read_tlb)(uint32_t coreid, target_addr_t virtual_address, target_addr_t *physical_address);
171 
173  int (*cache_ctl)(uint32_t coreid, uint32_t subtype, uint32_t address);
174 
176  int (*set_retry_times)(uint32_t a_retry_times);
177 
179  int (*program_edm)(uint32_t coreid, char *command_sequence);
180 
183 
185  int (*execute)(uint32_t coreid, uint32_t *instructions, uint32_t instruction_num);
186 
188  int (*set_custom_srst_script)(const char *script);
189 
191  int (*set_custom_trst_script)(const char *script);
192 
194  int (*set_custom_restart_script)(const char *script);
195 
197  int (*set_count_to_check_dbger)(uint32_t count_to_check);
198 
200  int (*set_data_endian)(uint32_t coreid, enum aice_target_endian target_data_endian);
201 
203  int (*profiling)(uint32_t coreid, uint32_t interval, uint32_t iteration,
204  uint32_t reg_no, uint32_t *samples, uint32_t *num_samples);
205 };
206 
207 #define AICE_PORT_UNKNOWN 0
208 #define AICE_PORT_AICE_USB 1
209 #define AICE_PORT_AICE_PIPE 2
210 
212 struct aice_port {
214  const char *name;
216  int type;
218  struct aice_port_api_s *const api;
219 };
220 
222 const struct aice_port *aice_port_get_list(void);
223 
224 #endif /* OPENOCD_JTAG_AICE_AICE_PORT_H */
static struct aice_port_param_s param
aice_command_mode
Definition: aice_port.h:89
@ AICE_COMMAND_MODE_BATCH
Definition: aice_port.h:92
@ AICE_COMMAND_MODE_NORMAL
Definition: aice_port.h:90
@ AICE_COMMAND_MODE_PACK
Definition: aice_port.h:91
aice_error_s
Definition: aice_port.h:74
@ AICE_ERROR
Definition: aice_port.h:77
@ AICE_ACK
Definition: aice_port.h:76
@ AICE_OK
Definition: aice_port.h:75
struct aice_port_api_s aice_usb_layout_api
const struct aice_port * aice_port_get_list(void)
Definition: aice_port.c:31
aice_target_state_s
Definition: aice_port.h:18
@ AICE_TARGET_DETACH
Definition: aice_port.h:20
@ AICE_TARGET_RUNNING
Definition: aice_port.h:22
@ AICE_TARGET_DEBUG_RUNNING
Definition: aice_port.h:25
@ AICE_DISCONNECT
Definition: aice_port.h:19
@ AICE_TARGET_UNKNOWN
Definition: aice_port.h:21
@ AICE_TARGET_RESET
Definition: aice_port.h:24
@ AICE_TARGET_HALTED
Definition: aice_port.h:23
aice_cache_ctl_type
Definition: aice_port.h:80
@ AICE_CACHE_CTL_L1D_VA_INVAL
Definition: aice_port.h:82
@ AICE_CACHE_CTL_L1D_WBALL
Definition: aice_port.h:83
@ AICE_CACHE_CTL_L1D_VA_WB
Definition: aice_port.h:84
@ AICE_CACHE_CTL_L1I_VA_INVAL
Definition: aice_port.h:86
@ AICE_CACHE_CTL_L1D_INVALALL
Definition: aice_port.h:81
@ AICE_CACHE_CTL_L1I_INVALALL
Definition: aice_port.h:85
aice_srst_type_s
Definition: aice_port.h:28
@ AICE_RESET_HOLD
Definition: aice_port.h:30
@ AICE_SRST
Definition: aice_port.h:29
aice_target_endian
Definition: aice_port.h:33
@ AICE_LITTLE_ENDIAN
Definition: aice_port.h:34
@ AICE_BIG_ENDIAN
Definition: aice_port.h:35
aice_api_s
Definition: aice_port.h:38
@ AICE_EXECUTE
Definition: aice_port.h:66
@ AICE_ASSERT_SRST
Definition: aice_port.h:44
@ AICE_SET_CUSTOM_RESTART_SCRIPT
Definition: aice_port.h:69
@ AICE_MEMORY_MODE
Definition: aice_port.h:60
@ AICE_WRITE_DEBUG_REG
Definition: aice_port.h:57
@ AICE_HALT
Definition: aice_port.h:46
@ AICE_RUN
Definition: aice_port.h:45
@ AICE_IDCODE
Definition: aice_port.h:42
@ AICE_SET_CUSTOM_TRST_SCRIPT
Definition: aice_port.h:68
@ AICE_WRITE_MEM_BULK
Definition: aice_port.h:55
@ AICE_STATE
Definition: aice_port.h:58
@ AICE_READ_MEM_UNIT
Definition: aice_port.h:52
@ AICE_SET_RETRY_TIMES
Definition: aice_port.h:63
@ AICE_STEP
Definition: aice_port.h:47
@ AICE_READ_REG_64
Definition: aice_port.h:50
@ AICE_READ_DEBUG_REG
Definition: aice_port.h:56
@ AICE_READ_MEM_BULK
Definition: aice_port.h:54
@ AICE_SET_COUNT_TO_CHECK_DBGER
Definition: aice_port.h:70
@ AICE_OPEN
Definition: aice_port.h:39
@ AICE_READ_TLB
Definition: aice_port.h:61
@ AICE_CACHE_CTL
Definition: aice_port.h:62
@ AICE_MEMORY_ACCESS
Definition: aice_port.h:59
@ AICE_READ_REG
Definition: aice_port.h:48
@ AICE_SET_DATA_ENDIAN
Definition: aice_port.h:71
@ AICE_RESET
Definition: aice_port.h:41
@ AICE_WRITE_REG
Definition: aice_port.h:49
@ AICE_SET_CUSTOM_SRST_SCRIPT
Definition: aice_port.h:67
@ AICE_CLOSE
Definition: aice_port.h:40
@ AICE_SET_JTAG_CLOCK
Definition: aice_port.h:43
@ AICE_WRITE_MEM_UNIT
Definition: aice_port.h:53
@ AICE_WRITE_REG_64
Definition: aice_port.h:51
@ AICE_SET_COMMAND_MODE
Definition: aice_port.h:65
@ AICE_PROGRAM_EDM
Definition: aice_port.h:64
command_mode
OpenOCD command mode is COMMAND_CONFIG at start, then switches to COMMAND_EXEC during the execution o...
Definition: command.h:39
uint8_t length
Definition: esp_usb_jtag.c:1
static const struct @102 instructions[]
This is the interface to the Embedded Debug Module for Andes cores.
nds_memory_select
Definition: nds32_edm.h:87
nds_memory_access
Definition: nds32_edm.h:82
uint32_t addr
Definition: nuttx.c:65
size_t size
Size of the control block search area.
Definition: rtt/rtt.c:30
int(* read_reg_64)(uint32_t coreid, uint32_t num, uint64_t *val)
Definition: aice_port.h:141
int(* assert_srst)(uint32_t coreid, enum aice_srst_type_s srst)
Definition: aice_port.h:129
int(* read_mem_bulk)(uint32_t coreid, uint32_t addr, uint32_t length, uint8_t *buffer)
Definition: aice_port.h:151
int(* set_command_mode)(enum aice_command_mode command_mode)
Definition: aice_port.h:182
int(* read_mem_unit)(uint32_t coreid, uint32_t addr, uint32_t size, uint32_t count, uint8_t *buffer)
Definition: aice_port.h:145
int(* program_edm)(uint32_t coreid, char *command_sequence)
Definition: aice_port.h:179
int(* execute)(uint32_t coreid, uint32_t *instructions, uint32_t instruction_num)
Definition: aice_port.h:185
int(* reset)(void)
Definition: aice_port.h:123
int(* memory_mode)(uint32_t coreid, enum nds_memory_select mem_select)
Definition: aice_port.h:167
int(* set_data_endian)(uint32_t coreid, enum aice_target_endian target_data_endian)
Definition: aice_port.h:200
int(* set_retry_times)(uint32_t a_retry_times)
Definition: aice_port.h:176
int(* set_custom_restart_script)(const char *script)
Definition: aice_port.h:194
int(* set_custom_srst_script)(const char *script)
Definition: aice_port.h:188
int(* halt)(uint32_t coreid)
Definition: aice_port.h:133
int(* state)(uint32_t coreid, enum aice_target_state_s *state)
Definition: aice_port.h:162
int(* open)(struct aice_port_param_s *param)
Definition: aice_port.h:119
int(* write_reg_64)(uint32_t coreid, uint32_t num, uint64_t val)
Definition: aice_port.h:143
int(* write_debug_reg)(uint32_t coreid, uint32_t addr, const uint32_t val)
Definition: aice_port.h:159
int(* write_reg)(uint32_t coreid, uint32_t num, uint32_t val)
Definition: aice_port.h:139
int(* step)(uint32_t coreid)
Definition: aice_port.h:135
int(* close)(void)
Definition: aice_port.h:121
int(* set_count_to_check_dbger)(uint32_t count_to_check)
Definition: aice_port.h:197
int(* write_mem_bulk)(uint32_t coreid, uint32_t addr, uint32_t length, const uint8_t *buffer)
Definition: aice_port.h:154
int(* memory_access)(uint32_t coreid, enum nds_memory_access a_access)
Definition: aice_port.h:165
int(* read_reg)(uint32_t coreid, uint32_t num, uint32_t *val)
Definition: aice_port.h:137
int(* write_mem_unit)(uint32_t coreid, uint32_t addr, uint32_t size, uint32_t count, const uint8_t *buffer)
Definition: aice_port.h:148
int(* idcode)(uint32_t *idcode, uint8_t *num_of_idcode)
Definition: aice_port.h:125
int(* set_jtag_clock)(uint32_t a_clock)
Definition: aice_port.h:127
int(* run)(uint32_t coreid)
Definition: aice_port.h:131
int(* cache_ctl)(uint32_t coreid, uint32_t subtype, uint32_t address)
Definition: aice_port.h:173
int(* set_custom_trst_script)(const char *script)
Definition: aice_port.h:191
int(* read_debug_reg)(uint32_t coreid, uint32_t addr, uint32_t *val)
Definition: aice_port.h:157
int(* read_tlb)(uint32_t coreid, target_addr_t virtual_address, target_addr_t *physical_address)
Definition: aice_port.h:170
int(* profiling)(uint32_t coreid, uint32_t interval, uint32_t iteration, uint32_t reg_no, uint32_t *samples, uint32_t *num_samples)
Definition: aice_port.h:203
char * adapter_name
Definition: aice_port.h:103
const char * device_desc
Definition: aice_port.h:97
uint16_t vid
Definition: aice_port.h:99
const struct aice_port * port
Definition: aice_port.h:110
uint32_t coreid
Definition: aice_port.h:108
int type
Definition: aice_port.h:216
struct aice_port_api_s *const api
Definition: aice_port.h:218
const char * name
Definition: aice_port.h:214
uint64_t target_addr_t
Definition: types.h:335
uint8_t count[4]
Definition: vdebug.c:22