OpenOCD
nds32_aice.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /***************************************************************************
4  * Copyright (C) 2013 Andes technology. *
5  * Hsiangkai Wang <hkwang@andestech.com> *
6  ***************************************************************************/
7 #ifdef HAVE_CONFIG_H
8 #include "config.h"
9 #endif
10 
11 #include <helper/log.h>
12 #include "nds32_aice.h"
13 
14 int aice_read_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t *val)
15 {
16  if (!aice->port->api->read_reg_64) {
17  LOG_WARNING("Not implemented: %s", __func__);
18  return ERROR_FAIL;
19  }
20 
21  return aice->port->api->read_reg_64(aice->coreid, num, val);
22 }
23 
24 int aice_write_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t val)
25 {
26  if (!aice->port->api->write_reg_64) {
27  LOG_WARNING("Not implemented: %s", __func__);
28  return ERROR_FAIL;
29  }
30 
31  return aice->port->api->write_reg_64(aice->coreid, num, val);
32 }
33 
34 int aice_read_tlb(struct aice_port_s *aice, target_addr_t virtual_address,
35  target_addr_t *physical_address)
36 {
37  if (!aice->port->api->read_tlb) {
38  LOG_WARNING("Not implemented: %s", __func__);
39  return ERROR_FAIL;
40  }
41 
42  return aice->port->api->read_tlb(aice->coreid, virtual_address, physical_address);
43 }
44 
45 int aice_cache_ctl(struct aice_port_s *aice, uint32_t subtype, uint32_t address)
46 {
47  if (!aice->port->api->cache_ctl) {
48  LOG_WARNING("Not implemented: %s", __func__);
49  return ERROR_FAIL;
50  }
51 
52  return aice->port->api->cache_ctl(aice->coreid, subtype, address);
53 }
54 
55 int aice_set_retry_times(struct aice_port_s *aice, uint32_t a_retry_times)
56 {
57  if (!aice->port->api->set_retry_times) {
58  LOG_WARNING("Not implemented: %s", __func__);
59  return ERROR_FAIL;
60  }
61 
62  return aice->port->api->set_retry_times(a_retry_times);
63 }
64 
65 int aice_program_edm(struct aice_port_s *aice, char *command_sequence)
66 {
67  if (!aice->port->api->program_edm) {
68  LOG_WARNING("Not implemented: %s", __func__);
69  return ERROR_FAIL;
70  }
71 
72  return aice->port->api->program_edm(aice->coreid, command_sequence);
73 }
74 
77 {
78  if (!aice->port->api->set_command_mode) {
79  LOG_WARNING("Not implemented: %s", __func__);
80  return ERROR_FAIL;
81  }
82 
83  return aice->port->api->set_command_mode(command_mode);
84 }
85 
86 int aice_execute(struct aice_port_s *aice, uint32_t *instructions,
87  uint32_t instruction_num)
88 {
89  if (!aice->port->api->execute) {
90  LOG_WARNING("Not implemented: %s", __func__);
91  return ERROR_FAIL;
92  }
93 
94  return aice->port->api->execute(aice->coreid, instructions, instruction_num);
95 }
96 
97 int aice_set_custom_srst_script(struct aice_port_s *aice, const char *script)
98 {
99  if (!aice->port->api->set_custom_srst_script) {
100  LOG_WARNING("Not implemented: %s", __func__);
101  return ERROR_FAIL;
102  }
103 
104  return aice->port->api->set_custom_srst_script(script);
105 }
106 
107 int aice_set_custom_trst_script(struct aice_port_s *aice, const char *script)
108 {
109  if (!aice->port->api->set_custom_trst_script) {
110  LOG_WARNING("Not implemented: %s", __func__);
111  return ERROR_FAIL;
112  }
113 
114  return aice->port->api->set_custom_trst_script(script);
115 }
116 
117 int aice_set_custom_restart_script(struct aice_port_s *aice, const char *script)
118 {
119  if (!aice->port->api->set_custom_restart_script) {
120  LOG_WARNING("Not implemented: %s", __func__);
121  return ERROR_FAIL;
122  }
123 
124  return aice->port->api->set_custom_restart_script(script);
125 }
126 
127 int aice_set_count_to_check_dbger(struct aice_port_s *aice, uint32_t count_to_check)
128 {
129  if (!aice->port->api->set_count_to_check_dbger) {
130  LOG_WARNING("Not implemented: %s", __func__);
131  return ERROR_FAIL;
132  }
133 
134  return aice->port->api->set_count_to_check_dbger(count_to_check);
135 }
136 
137 int aice_profiling(struct aice_port_s *aice, uint32_t interval, uint32_t iteration,
138  uint32_t reg_no, uint32_t *samples, uint32_t *num_samples)
139 {
140  if (!aice->port->api->profiling) {
141  LOG_WARNING("Not implemented: %s", __func__);
142  return ERROR_FAIL;
143  }
144 
145  return aice->port->api->profiling(aice->coreid, interval, iteration,
146  reg_no, samples, num_samples);
147 }
aice_command_mode
Definition: aice_port.h:89
command_mode
OpenOCD command mode is COMMAND_CONFIG at start, then switches to COMMAND_EXEC during the execution o...
Definition: command.h:39
static const struct @102 instructions[]
#define LOG_WARNING(expr ...)
Definition: log.h:120
#define ERROR_FAIL
Definition: log.h:161
int aice_set_custom_srst_script(struct aice_port_s *aice, const char *script)
Definition: nds32_aice.c:97
int aice_set_custom_trst_script(struct aice_port_s *aice, const char *script)
Definition: nds32_aice.c:107
int aice_write_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t val)
Definition: nds32_aice.c:24
int aice_program_edm(struct aice_port_s *aice, char *command_sequence)
Definition: nds32_aice.c:65
int aice_set_count_to_check_dbger(struct aice_port_s *aice, uint32_t count_to_check)
Definition: nds32_aice.c:127
int aice_profiling(struct aice_port_s *aice, uint32_t interval, uint32_t iteration, uint32_t reg_no, uint32_t *samples, uint32_t *num_samples)
Definition: nds32_aice.c:137
int aice_read_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t *val)
Definition: nds32_aice.c:14
int aice_cache_ctl(struct aice_port_s *aice, uint32_t subtype, uint32_t address)
Definition: nds32_aice.c:45
int aice_set_command_mode(struct aice_port_s *aice, enum aice_command_mode command_mode)
Definition: nds32_aice.c:75
int aice_set_retry_times(struct aice_port_s *aice, uint32_t a_retry_times)
Definition: nds32_aice.c:55
int aice_read_tlb(struct aice_port_s *aice, target_addr_t virtual_address, target_addr_t *physical_address)
Definition: nds32_aice.c:34
int aice_execute(struct aice_port_s *aice, uint32_t *instructions, uint32_t instruction_num)
Definition: nds32_aice.c:86
int aice_set_custom_restart_script(struct aice_port_s *aice, const char *script)
Definition: nds32_aice.c:117
int(* read_reg_64)(uint32_t coreid, uint32_t num, uint64_t *val)
Definition: aice_port.h:141
int(* set_command_mode)(enum aice_command_mode command_mode)
Definition: aice_port.h:182
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(* 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(* write_reg_64)(uint32_t coreid, uint32_t num, uint64_t val)
Definition: aice_port.h:143
int(* set_count_to_check_dbger)(uint32_t count_to_check)
Definition: aice_port.h:197
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_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
const struct aice_port * port
Definition: aice_port.h:110
uint32_t coreid
Definition: aice_port.h:108
struct aice_port_api_s *const api
Definition: aice_port.h:218
uint64_t target_addr_t
Definition: types.h:335