openocd: src/jtag: replace the GPL-2.0-or-later license tag
[openocd.git] / src / jtag / aice / aice_pipe.c
blob3651952381ba95f435cedd64f9f37627fd3b5c18
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 /***************************************************************************
4 * Copyright (C) 2013 by Andes Technology *
5 * Hsiangkai Wang <hkwang@andestech.com> *
6 ***************************************************************************/
7 #ifdef HAVE_CONFIG_H
8 #include "config.h"
9 #endif
11 #include <helper/system.h>
13 #ifdef _WIN32
14 #include <windows.h>
15 #else
16 #include <signal.h>
17 #endif
19 #include <helper/log.h>
20 #include <helper/time_support.h>
21 #include "aice_port.h"
22 #include "aice_pipe.h"
24 #define AICE_PIPE_MAXLINE 8192
26 #ifdef _WIN32
27 PROCESS_INFORMATION proc_info;
29 static HANDLE aice_pipe_output[2];
30 static HANDLE aice_pipe_input[2];
32 static int aice_pipe_write(const void *buffer, int count)
34 BOOL success;
35 DWORD written;
37 success = WriteFile(aice_pipe_output[1], buffer, count, &written, NULL);
38 if (!success) {
39 LOG_ERROR("(WIN32) write to pipe failed, error code: 0x%08l" PRIx32, GetLastError());
40 return -1;
43 return written;
46 static int aice_pipe_read(void *buffer, int count)
48 BOOL success;
49 DWORD has_read;
51 success = ReadFile(aice_pipe_input[0], buffer, count, &has_read, NULL);
52 if (!success || (has_read == 0)) {
53 LOG_ERROR("(WIN32) read from pipe failed, error code: 0x%08l" PRIx32, GetLastError());
54 return -1;
57 return has_read;
60 static int aice_pipe_child_init(struct aice_port_param_s *param)
62 STARTUPINFO start_info;
63 BOOL success;
65 ZeroMemory(&proc_info, sizeof(PROCESS_INFORMATION));
66 ZeroMemory(&start_info, sizeof(STARTUPINFO));
67 start_info.cb = sizeof(STARTUPINFO);
68 start_info.hStdError = aice_pipe_input[1];
69 start_info.hStdOutput = aice_pipe_input[1];
70 start_info.hStdInput = aice_pipe_output[0];
71 start_info.dwFlags |= STARTF_USESTDHANDLES;
73 success = CreateProcess(NULL,
74 param->adapter_name,
75 NULL,
76 NULL,
77 TRUE,
79 NULL,
80 NULL,
81 &start_info,
82 &proc_info);
84 if (!success) {
85 LOG_ERROR("Create new process failed");
86 return ERROR_FAIL;
89 return ERROR_OK;
92 static int aice_pipe_parent_init(struct aice_port_param_s *param)
94 /* send open to adapter */
95 char line[AICE_PIPE_MAXLINE];
96 char command[AICE_PIPE_MAXLINE];
98 command[0] = AICE_OPEN;
99 set_u16(command + 1, param->vid);
100 set_u16(command + 3, param->pid);
102 if (aice_pipe_write(command, 5) != 5) {
103 LOG_ERROR("write failed\n");
104 return ERROR_FAIL;
107 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0) {
108 LOG_ERROR("read failed\n");
109 return ERROR_FAIL;
112 if (line[0] == AICE_OK)
113 return ERROR_OK;
114 else
115 return ERROR_FAIL;
118 static int aice_pipe_open(struct aice_port_param_s *param)
120 SECURITY_ATTRIBUTES attribute;
122 attribute.nLength = sizeof(SECURITY_ATTRIBUTES);
123 attribute.bInheritHandle = TRUE;
124 attribute.lpSecurityDescriptor = NULL;
126 if (!CreatePipe(&aice_pipe_output[0], &aice_pipe_output[1],
127 &attribute, AICE_PIPE_MAXLINE)) {
128 LOG_ERROR("Create pipes failed");
129 return ERROR_FAIL;
131 if (!CreatePipe(&aice_pipe_input[0], &aice_pipe_input[1],
132 &attribute, AICE_PIPE_MAXLINE)) {
133 LOG_ERROR("Create pipes failed");
134 return ERROR_FAIL;
137 /* do not inherit aice_pipe_output[1] & aice_pipe_input[0] to child process */
138 if (!SetHandleInformation(aice_pipe_output[1], HANDLE_FLAG_INHERIT, 0))
139 return ERROR_FAIL;
140 if (!SetHandleInformation(aice_pipe_input[0], HANDLE_FLAG_INHERIT, 0))
141 return ERROR_FAIL;
143 aice_pipe_child_init(param);
145 aice_pipe_parent_init(param);
147 return ERROR_OK;
150 #else
152 static int aice_pipe_output[2];
153 static int aice_pipe_input[2];
155 static int aice_pipe_write(const void *buffer, int count)
157 if (write(aice_pipe_output[1], buffer, count) != count) {
158 LOG_ERROR("write to pipe failed");
159 return -1;
162 return count;
165 static int aice_pipe_read(void *buffer, int count)
167 int n;
168 int64_t then, cur;
170 then = timeval_ms();
172 while (1) {
173 n = read(aice_pipe_input[0], buffer, count);
175 if ((n == -1) && (errno == EAGAIN)) {
176 cur = timeval_ms();
177 if (cur - then > 500)
178 keep_alive();
179 continue;
180 } else if (n > 0)
181 break;
182 else {
183 LOG_ERROR("read from pipe failed");
184 break;
188 return n;
191 static int aice_pipe_child_init(struct aice_port_param_s *param)
193 close(aice_pipe_output[1]);
194 close(aice_pipe_input[0]);
196 if (aice_pipe_output[0] != STDIN_FILENO) {
197 if (dup2(aice_pipe_output[0], STDIN_FILENO) != STDIN_FILENO) {
198 LOG_ERROR("Map aice_pipe to STDIN failed");
199 return ERROR_FAIL;
201 close(aice_pipe_output[0]);
204 if (aice_pipe_input[1] != STDOUT_FILENO) {
205 if (dup2(aice_pipe_input[1], STDOUT_FILENO) != STDOUT_FILENO) {
206 LOG_ERROR("Map aice_pipe to STDOUT failed");
207 return ERROR_FAIL;
209 close(aice_pipe_input[1]);
212 if (execl(param->adapter_name, param->adapter_name, (char *)0) < 0) {
213 LOG_ERROR("Execute aice_pipe failed");
214 return ERROR_FAIL;
217 return ERROR_OK;
220 static int aice_pipe_parent_init(struct aice_port_param_s *param)
222 close(aice_pipe_output[0]);
223 close(aice_pipe_input[1]);
225 /* set read end of pipe as non-blocking */
226 if (fcntl(aice_pipe_input[0], F_SETFL, O_NONBLOCK))
227 return ERROR_FAIL;
229 /* send open to adapter */
230 char line[AICE_PIPE_MAXLINE];
231 char command[AICE_PIPE_MAXLINE];
233 command[0] = AICE_OPEN;
234 set_u16(command + 1, param->vid);
235 set_u16(command + 3, param->pid);
237 if (aice_pipe_write(command, 5) != 5) {
238 LOG_ERROR("write failed\n");
239 return ERROR_FAIL;
242 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0) {
243 LOG_ERROR("read failed\n");
244 return ERROR_FAIL;
247 if (line[0] == AICE_OK)
248 return ERROR_OK;
249 else
250 return ERROR_FAIL;
253 static void sig_pipe(int signo)
255 exit(1);
258 static int aice_pipe_open(struct aice_port_param_s *param)
260 pid_t pid;
262 if (signal(SIGPIPE, sig_pipe) == SIG_ERR) {
263 LOG_ERROR("Register SIGPIPE handler failed");
264 return ERROR_FAIL;
267 if (pipe(aice_pipe_output) < 0 || pipe(aice_pipe_input) < 0) {
268 LOG_ERROR("Create pipes failed");
269 return ERROR_FAIL;
272 pid = fork();
273 if (pid < 0) {
274 LOG_ERROR("Fork new process failed");
275 return ERROR_FAIL;
276 } else if (pid == 0) {
277 if (aice_pipe_child_init(param) != ERROR_OK) {
278 LOG_ERROR("AICE_PIPE child process initial error");
279 return ERROR_FAIL;
280 } else {
281 if (aice_pipe_parent_init(param) != ERROR_OK) {
282 LOG_ERROR("AICE_PIPE parent process initial error");
283 return ERROR_FAIL;
288 return ERROR_OK;
290 #endif
292 static int aice_pipe_close(void)
294 char line[AICE_PIPE_MAXLINE];
295 char command[AICE_PIPE_MAXLINE];
297 command[0] = AICE_CLOSE;
299 if (aice_pipe_write(command, 1) != 1)
300 return ERROR_FAIL;
302 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
303 return ERROR_FAIL;
305 if (line[0] == AICE_OK) {
306 #ifdef _WIN32
307 WaitForSingleObject(proc_info.hProcess, INFINITE);
308 CloseHandle(proc_info.hProcess);
309 CloseHandle(proc_info.hThread);
310 #endif
311 return ERROR_OK;
312 } else
313 return ERROR_FAIL;
316 static int aice_pipe_idcode(uint32_t *idcode, uint8_t *num_of_idcode)
318 char line[AICE_PIPE_MAXLINE];
319 char command[AICE_PIPE_MAXLINE];
321 command[0] = AICE_IDCODE;
323 if (aice_pipe_write(command, 1) != 1)
324 return ERROR_FAIL;
326 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
327 return ERROR_FAIL;
329 *num_of_idcode = line[0];
331 if ((*num_of_idcode == 0) || (*num_of_idcode >= 16))
332 return ERROR_FAIL;
334 for (int i = 0 ; i < *num_of_idcode ; i++)
335 idcode[i] = get_u32(line + i * 4 + 1);
337 return ERROR_OK;
340 static int aice_pipe_state(uint32_t coreid, enum aice_target_state_s *state)
342 char line[AICE_PIPE_MAXLINE];
343 char command[AICE_PIPE_MAXLINE];
345 command[0] = AICE_STATE;
347 if (aice_pipe_write(command, 1) != 1)
348 return ERROR_FAIL;
350 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
351 return ERROR_FAIL;
353 *state = (enum aice_target_state_s)line[0];
355 return ERROR_OK;
358 static int aice_pipe_reset(void)
360 char line[AICE_PIPE_MAXLINE];
361 char command[AICE_PIPE_MAXLINE];
363 command[0] = AICE_RESET;
365 if (aice_pipe_write(command, 1) != 1)
366 return ERROR_FAIL;
368 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
369 return ERROR_FAIL;
371 if (line[0] == AICE_OK)
372 return ERROR_OK;
373 else
374 return ERROR_FAIL;
377 static int aice_pipe_assert_srst(uint32_t coreid, enum aice_srst_type_s srst)
379 char line[AICE_PIPE_MAXLINE];
380 char command[AICE_PIPE_MAXLINE];
382 command[0] = AICE_ASSERT_SRST;
383 command[1] = srst;
385 if (aice_pipe_write(command, 2) != 2)
386 return ERROR_FAIL;
388 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
389 return ERROR_FAIL;
391 if (line[0] == AICE_OK)
392 return ERROR_OK;
393 else
394 return ERROR_FAIL;
397 static int aice_pipe_run(uint32_t coreid)
399 char line[AICE_PIPE_MAXLINE];
400 char command[AICE_PIPE_MAXLINE];
402 command[0] = AICE_RUN;
404 if (aice_pipe_write(command, 1) != 1)
405 return ERROR_FAIL;
407 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
408 return ERROR_FAIL;
410 if (line[0] == AICE_OK)
411 return ERROR_OK;
412 else
413 return ERROR_FAIL;
416 static int aice_pipe_halt(uint32_t coreid)
418 char line[AICE_PIPE_MAXLINE];
419 char command[AICE_PIPE_MAXLINE];
421 command[0] = AICE_HALT;
423 if (aice_pipe_write(command, 1) != 1)
424 return ERROR_FAIL;
426 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
427 return ERROR_FAIL;
429 if (line[0] == AICE_OK)
430 return ERROR_OK;
431 else
432 return ERROR_FAIL;
435 static int aice_pipe_read_reg(uint32_t coreid, uint32_t num, uint32_t *val)
437 char line[AICE_PIPE_MAXLINE];
438 char command[AICE_PIPE_MAXLINE];
440 command[0] = AICE_READ_REG;
441 set_u32(command + 1, num);
443 if (aice_pipe_write(command, 5) != 5)
444 return ERROR_FAIL;
446 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
447 return ERROR_FAIL;
449 *val = get_u32(line);
451 return ERROR_OK;
454 static int aice_pipe_write_reg(uint32_t coreid, uint32_t num, uint32_t val)
456 char line[AICE_PIPE_MAXLINE];
457 char command[AICE_PIPE_MAXLINE];
459 command[0] = AICE_WRITE_REG;
460 set_u32(command + 1, num);
461 set_u32(command + 5, val);
463 if (aice_pipe_write(command, 9) != 9)
464 return ERROR_FAIL;
466 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
467 return ERROR_FAIL;
469 if (line[0] == AICE_OK)
470 return ERROR_OK;
471 else
472 return ERROR_FAIL;
475 static int aice_pipe_read_reg_64(uint32_t coreid, uint32_t num, uint64_t *val)
477 char line[AICE_PIPE_MAXLINE];
478 char command[AICE_PIPE_MAXLINE];
480 command[0] = AICE_READ_REG_64;
481 set_u32(command + 1, num);
483 if (aice_pipe_write(command, 5) != 5)
484 return ERROR_FAIL;
486 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
487 return ERROR_FAIL;
489 *val = (((uint64_t)get_u32(line + 4)) << 32) | get_u32(line);
491 return ERROR_OK;
494 static int aice_pipe_write_reg_64(uint32_t coreid, uint32_t num, uint64_t val)
496 char line[AICE_PIPE_MAXLINE];
497 char command[AICE_PIPE_MAXLINE];
499 command[0] = AICE_WRITE_REG_64;
500 set_u32(command + 1, num);
501 set_u32(command + 5, val & 0xFFFFFFFF);
502 set_u32(command + 9, (val >> 32) & 0xFFFFFFFF);
504 if (aice_pipe_write(command, 13) != 9)
505 return ERROR_FAIL;
507 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
508 return ERROR_FAIL;
510 if (line[0] == AICE_OK)
511 return ERROR_OK;
512 else
513 return ERROR_FAIL;
516 static int aice_pipe_step(uint32_t coreid)
518 char line[AICE_PIPE_MAXLINE];
519 char command[AICE_PIPE_MAXLINE];
521 command[0] = AICE_STEP;
523 if (aice_pipe_write(command, 1) != 1)
524 return ERROR_FAIL;
526 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
527 return ERROR_FAIL;
529 if (line[0] == AICE_OK)
530 return ERROR_OK;
531 else
532 return ERROR_FAIL;
535 static int aice_pipe_read_mem_unit(uint32_t coreid, uint32_t addr, uint32_t size,
536 uint32_t count, uint8_t *buffer)
538 char command[AICE_PIPE_MAXLINE];
540 command[0] = AICE_READ_MEM_UNIT;
541 set_u32(command + 1, addr);
542 set_u32(command + 5, size);
543 set_u32(command + 9, count);
545 if (aice_pipe_write(command, 13) != 13)
546 return ERROR_FAIL;
548 if (aice_pipe_read(buffer, size * count) < 0)
549 return ERROR_FAIL;
551 return ERROR_OK;
554 static int aice_pipe_write_mem_unit(uint32_t coreid, uint32_t addr, uint32_t size,
555 uint32_t count, const uint8_t *buffer)
557 char line[AICE_PIPE_MAXLINE];
558 char command[AICE_PIPE_MAXLINE];
560 command[0] = AICE_WRITE_MEM_UNIT;
561 set_u32(command + 1, addr);
562 set_u32(command + 5, size);
563 set_u32(command + 9, count);
565 /* WRITE_MEM_UNIT|addr|size|count|data */
566 memcpy(command + 13, buffer, size * count);
568 if (aice_pipe_write(command, 13 + size * count) < 0)
569 return ERROR_FAIL;
571 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
572 return ERROR_FAIL;
574 if (line[0] == AICE_OK)
575 return ERROR_OK;
576 else
577 return ERROR_FAIL;
579 return ERROR_OK;
582 static int aice_pipe_read_mem_bulk(uint32_t coreid, uint32_t addr,
583 uint32_t length, uint8_t *buffer)
585 char line[AICE_PIPE_MAXLINE + 1];
586 char command[AICE_PIPE_MAXLINE];
587 uint32_t remain_len = length;
588 uint32_t prepare_len;
589 char *received_line;
590 uint32_t received_len;
591 int read_len;
593 command[0] = AICE_READ_MEM_BULK;
594 set_u32(command + 1, addr);
595 set_u32(command + 5, length);
597 if (aice_pipe_write(command, 9) < 0)
598 return ERROR_FAIL;
600 while (remain_len > 0) {
601 if (remain_len > AICE_PIPE_MAXLINE)
602 prepare_len = AICE_PIPE_MAXLINE;
603 else
604 prepare_len = remain_len;
606 prepare_len++;
607 received_len = 0;
608 received_line = line;
609 do {
610 read_len = aice_pipe_read(received_line, prepare_len - received_len);
611 if (read_len < 0)
612 return ERROR_FAIL;
613 received_line += read_len;
614 received_len += read_len;
615 } while (received_len < prepare_len);
617 if (line[0] != AICE_OK)
618 return ERROR_FAIL;
620 prepare_len--;
621 memcpy(buffer, line + 1, prepare_len);
622 remain_len -= prepare_len;
623 buffer += prepare_len;
626 return ERROR_OK;
629 static int aice_pipe_write_mem_bulk(uint32_t coreid, uint32_t addr,
630 uint32_t length, const uint8_t *buffer)
632 char line[AICE_PIPE_MAXLINE];
633 char command[AICE_PIPE_MAXLINE + 4];
634 uint32_t remain_len = length;
635 uint32_t written_len = 0;
636 uint32_t write_len;
638 command[0] = AICE_WRITE_MEM_BULK;
639 set_u32(command + 1, addr);
640 set_u32(command + 5, length);
642 /* Send command first */
643 if (aice_pipe_write(command, 9) < 0)
644 return ERROR_FAIL;
646 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
647 return ERROR_FAIL;
649 if (line[0] == AICE_ERROR)
650 return ERROR_FAIL;
652 while (remain_len > 0) {
653 if (remain_len > AICE_PIPE_MAXLINE)
654 write_len = AICE_PIPE_MAXLINE;
655 else
656 write_len = remain_len;
658 set_u32(command, write_len);
659 memcpy(command + 4, buffer + written_len, write_len); /* data only */
661 if (aice_pipe_write(command, write_len + 4) < 0)
662 return ERROR_FAIL;
664 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
665 return ERROR_FAIL;
667 if (line[0] == AICE_ERROR)
668 return ERROR_FAIL;
670 remain_len -= write_len;
671 written_len += write_len;
674 if (line[0] == AICE_OK)
675 return ERROR_OK;
676 else
677 return ERROR_FAIL;
680 static int aice_pipe_read_debug_reg(uint32_t coreid, uint32_t addr, uint32_t *val)
682 char line[AICE_PIPE_MAXLINE];
683 char command[AICE_PIPE_MAXLINE];
685 command[0] = AICE_READ_DEBUG_REG;
686 set_u32(command + 1, addr);
688 if (aice_pipe_write(command, 5) != 5)
689 return ERROR_FAIL;
691 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
692 return ERROR_FAIL;
694 *val = get_u32(line);
696 return ERROR_OK;
699 static int aice_pipe_write_debug_reg(uint32_t coreid, uint32_t addr, const uint32_t val)
701 char line[AICE_PIPE_MAXLINE];
702 char command[AICE_PIPE_MAXLINE];
704 command[0] = AICE_WRITE_DEBUG_REG;
705 set_u32(command + 1, addr);
706 set_u32(command + 5, val);
708 if (aice_pipe_write(command, 9) != 9)
709 return ERROR_FAIL;
711 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
712 return ERROR_FAIL;
714 if (line[0] == AICE_OK)
715 return ERROR_OK;
716 else
717 return ERROR_FAIL;
720 static int aice_pipe_set_jtag_clock(uint32_t a_clock)
722 char line[AICE_PIPE_MAXLINE];
723 char command[AICE_PIPE_MAXLINE];
725 command[0] = AICE_SET_JTAG_CLOCK;
726 set_u32(command + 1, a_clock);
728 if (aice_pipe_write(command, 5) != 5)
729 return ERROR_FAIL;
731 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
732 return ERROR_FAIL;
734 if (line[0] == AICE_OK)
735 return ERROR_OK;
736 else
737 return ERROR_FAIL;
740 static int aice_pipe_memory_access(uint32_t coreid, enum nds_memory_access access_channel)
742 char line[AICE_PIPE_MAXLINE];
743 char command[AICE_PIPE_MAXLINE];
745 command[0] = AICE_MEMORY_ACCESS;
746 set_u32(command + 1, access_channel);
748 if (aice_pipe_write(command, 5) != 5)
749 return ERROR_FAIL;
751 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
752 return ERROR_FAIL;
754 if (line[0] == AICE_OK)
755 return ERROR_OK;
756 else
757 return ERROR_FAIL;
760 static int aice_pipe_memory_mode(uint32_t coreid, enum nds_memory_select mem_select)
762 char line[AICE_PIPE_MAXLINE];
763 char command[AICE_PIPE_MAXLINE];
765 command[0] = AICE_MEMORY_MODE;
766 set_u32(command + 1, mem_select);
768 if (aice_pipe_write(command, 5) != 5)
769 return ERROR_FAIL;
771 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
772 return ERROR_FAIL;
774 if (line[0] == AICE_OK)
775 return ERROR_OK;
776 else
777 return ERROR_FAIL;
780 static int aice_pipe_read_tlb(uint32_t coreid, target_addr_t virtual_address,
781 target_addr_t *physical_address)
783 char line[AICE_PIPE_MAXLINE];
784 char command[AICE_PIPE_MAXLINE];
786 command[0] = AICE_READ_TLB;
787 set_u32(command + 1, virtual_address);
789 if (aice_pipe_write(command, 5) != 5)
790 return ERROR_FAIL;
792 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
793 return ERROR_FAIL;
795 if (line[0] == AICE_OK) {
796 *physical_address = get_u32(line + 1);
797 return ERROR_OK;
798 } else
799 return ERROR_FAIL;
802 static int aice_pipe_cache_ctl(uint32_t coreid, uint32_t subtype, uint32_t address)
804 char line[AICE_PIPE_MAXLINE];
805 char command[AICE_PIPE_MAXLINE];
807 command[0] = AICE_CACHE_CTL;
808 set_u32(command + 1, subtype);
809 set_u32(command + 5, address);
811 if (aice_pipe_write(command, 9) != 9)
812 return ERROR_FAIL;
814 if (aice_pipe_read(line, AICE_PIPE_MAXLINE) < 0)
815 return ERROR_FAIL;
817 if (line[0] == AICE_OK)
818 return ERROR_OK;
819 else
820 return ERROR_FAIL;
823 static int aice_pipe_set_retry_times(uint32_t a_retry_times)
825 return ERROR_OK;
828 /** */
829 struct aice_port_api_s aice_pipe = {
830 /** */
831 .open = aice_pipe_open,
832 /** */
833 .close = aice_pipe_close,
834 /** */
835 .idcode = aice_pipe_idcode,
836 /** */
837 .set_jtag_clock = aice_pipe_set_jtag_clock,
838 /** */
839 .state = aice_pipe_state,
840 /** */
841 .reset = aice_pipe_reset,
842 /** */
843 .assert_srst = aice_pipe_assert_srst,
844 /** */
845 .run = aice_pipe_run,
846 /** */
847 .halt = aice_pipe_halt,
848 /** */
849 .step = aice_pipe_step,
850 /** */
851 .read_reg = aice_pipe_read_reg,
852 /** */
853 .write_reg = aice_pipe_write_reg,
854 /** */
855 .read_reg_64 = aice_pipe_read_reg_64,
856 /** */
857 .write_reg_64 = aice_pipe_write_reg_64,
858 /** */
859 .read_mem_unit = aice_pipe_read_mem_unit,
860 /** */
861 .write_mem_unit = aice_pipe_write_mem_unit,
862 /** */
863 .read_mem_bulk = aice_pipe_read_mem_bulk,
864 /** */
865 .write_mem_bulk = aice_pipe_write_mem_bulk,
866 /** */
867 .read_debug_reg = aice_pipe_read_debug_reg,
868 /** */
869 .write_debug_reg = aice_pipe_write_debug_reg,
871 /** */
872 .memory_access = aice_pipe_memory_access,
873 /** */
874 .memory_mode = aice_pipe_memory_mode,
876 /** */
877 .read_tlb = aice_pipe_read_tlb,
879 /** */
880 .cache_ctl = aice_pipe_cache_ctl,
882 /** */
883 .set_retry_times = aice_pipe_set_retry_times,