]> git.sur5r.net Git - openocd/blob - src/target/nds32_aice.c
Change variable scope.
[openocd] / src / target / nds32_aice.c
1 /***************************************************************************
2  *   Copyright (C) 2013 Andes technology.                                  *
3  *   Hsiangkai Wang <hkwang@andestech.com>                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
19  ***************************************************************************/
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #include <helper/log.h>
25 #include "nds32_aice.h"
26
27 int aice_read_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t *val)
28 {
29         if (aice->port->api->read_reg_64 == NULL) {
30                 LOG_WARNING("Not implemented: %s", __func__);
31                 return ERROR_FAIL;
32         }
33
34         return aice->port->api->read_reg_64(num, val);
35 }
36
37 int aice_write_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t val)
38 {
39         if (aice->port->api->write_reg_64 == NULL) {
40                 LOG_WARNING("Not implemented: %s", __func__);
41                 return ERROR_FAIL;
42         }
43
44         return aice->port->api->write_reg_64(num, val);
45 }
46
47 int aice_select_target(struct aice_port_s *aice, uint32_t target_id)
48 {
49         if (aice->port->api->select_target == NULL) {
50                 LOG_WARNING("Not implemented: %s", __func__);
51                 return ERROR_FAIL;
52         }
53
54         return aice->port->api->select_target(target_id);
55 }
56
57 int aice_read_tlb(struct aice_port_s *aice, uint32_t virtual_address,
58                 uint32_t *physical_address)
59 {
60         if (aice->port->api->read_tlb == NULL) {
61                 LOG_WARNING("Not implemented: %s", __func__);
62                 return ERROR_FAIL;
63         }
64
65         return aice->port->api->read_tlb(virtual_address, physical_address);
66 }
67
68 int aice_cache_ctl(struct aice_port_s *aice, uint32_t subtype, uint32_t address)
69 {
70         if (aice->port->api->cache_ctl == NULL) {
71                 LOG_WARNING("Not implemented: %s", __func__);
72                 return ERROR_FAIL;
73         }
74
75         return aice->port->api->cache_ctl(subtype, address);
76 }
77
78 int aice_set_retry_times(struct aice_port_s *aice, uint32_t a_retry_times)
79 {
80         if (aice->port->api->set_retry_times == NULL) {
81                 LOG_WARNING("Not implemented: %s", __func__);
82                 return ERROR_FAIL;
83         }
84
85         return aice->port->api->set_retry_times(a_retry_times);
86 }
87
88 int aice_program_edm(struct aice_port_s *aice, char *command_sequence)
89 {
90         if (aice->port->api->program_edm == NULL) {
91                 LOG_WARNING("Not implemented: %s", __func__);
92                 return ERROR_FAIL;
93         }
94
95         return aice->port->api->program_edm(command_sequence);
96 }
97
98 int aice_pack_command(struct aice_port_s *aice, bool enable_pack_command)
99 {
100         if (aice->port->api->pack_command == NULL) {
101                 LOG_WARNING("Not implemented: %s", __func__);
102                 return ERROR_FAIL;
103         }
104
105         return aice->port->api->pack_command(enable_pack_command);
106 }
107
108 int aice_execute(struct aice_port_s *aice, uint32_t *instructions,
109                 uint32_t instruction_num)
110 {
111         if (aice->port->api->execute == NULL) {
112                 LOG_WARNING("Not implemented: %s", __func__);
113                 return ERROR_FAIL;
114         }
115
116         return aice->port->api->execute(instructions, instruction_num);
117 }
118
119 int aice_set_custom_srst_script(struct aice_port_s *aice, const char *script)
120 {
121         if (aice->port->api->set_custom_srst_script == NULL) {
122                 LOG_WARNING("Not implemented: %s", __func__);
123                 return ERROR_FAIL;
124         }
125
126         return aice->port->api->set_custom_srst_script(script);
127 }
128
129 int aice_set_custom_trst_script(struct aice_port_s *aice, const char *script)
130 {
131         if (aice->port->api->set_custom_trst_script == NULL) {
132                 LOG_WARNING("Not implemented: %s", __func__);
133                 return ERROR_FAIL;
134         }
135
136         return aice->port->api->set_custom_trst_script(script);
137 }
138
139 int aice_set_custom_restart_script(struct aice_port_s *aice, const char *script)
140 {
141         if (aice->port->api->set_custom_restart_script == NULL) {
142                 LOG_WARNING("Not implemented: %s", __func__);
143                 return ERROR_FAIL;
144         }
145
146         return aice->port->api->set_custom_restart_script(script);
147 }
148
149 int aice_set_count_to_check_dbger(struct aice_port_s *aice, uint32_t count_to_check)
150 {
151         if (aice->port->api->set_count_to_check_dbger == NULL) {
152                 LOG_WARNING("Not implemented: %s", __func__);
153                 return ERROR_FAIL;
154         }
155
156         return aice->port->api->set_count_to_check_dbger(count_to_check);
157 }