1 /***************************************************************************
2 * Copyright (C) 2009 by Marvell Technology Group Ltd. *
3 * Written by Nicolas Pitre <nico@marvell.com> *
5 * Copyright (C) 2010 by Spencer Oliver *
6 * spen@spen-soft.co.uk *
8 * Copyright (C) 2016 by Square, Inc. *
9 * Steven Stallion <stallion@squareup.com> *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License for more details. *
21 * You should have received a copy of the GNU General Public License *
22 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
23 ***************************************************************************/
27 * Hold ARM semihosting support.
29 * Semihosting enables code running on an ARM target to use the I/O
30 * facilities on the host computer. The target application must be linked
31 * against a library that forwards operation requests by using the SVC
32 * instruction trapped at the Supervisor Call vector by the debugger.
33 * Details can be found in chapter 8 of DUI0203I_rvct_developer_guide.pdf
43 #include "arm7_9_common.h"
48 #include "arm_opcodes.h"
49 #include "target_type.h"
50 #include "arm_semihosting.h"
51 #include <helper/binarybuffer.h>
52 #include <helper/log.h>
55 static const int open_modeflags
[12] = {
60 O_WRONLY
| O_CREAT
| O_TRUNC
,
61 O_WRONLY
| O_CREAT
| O_TRUNC
| O_BINARY
,
62 O_RDWR
| O_CREAT
| O_TRUNC
,
63 O_RDWR
| O_CREAT
| O_TRUNC
| O_BINARY
,
64 O_WRONLY
| O_CREAT
| O_APPEND
,
65 O_WRONLY
| O_CREAT
| O_APPEND
| O_BINARY
,
66 O_RDWR
| O_CREAT
| O_APPEND
,
67 O_RDWR
| O_CREAT
| O_APPEND
| O_BINARY
70 static int post_result(struct target
*target
)
72 struct arm
*arm
= target_to_arm(target
);
74 /* REVISIT this looks wrong ... ARM11 and Cortex-A8
75 * should work this way at least sometimes.
77 if (is_arm7_9(target_to_arm7_9(target
)) ||
78 is_armv7a(target_to_armv7a(target
))) {
81 /* return value in R0 */
82 buf_set_u32(arm
->core_cache
->reg_list
[0].value
, 0, 32, arm
->semihosting_result
);
83 arm
->core_cache
->reg_list
[0].dirty
= 1;
86 buf_set_u32(arm
->core_cache
->reg_list
[15].value
, 0, 32,
87 buf_get_u32(arm_reg_current(arm
, 14)->value
, 0, 32));
88 arm
->core_cache
->reg_list
[15].dirty
= 1;
90 /* saved PSR --> current PSR */
91 spsr
= buf_get_u32(arm
->spsr
->value
, 0, 32);
93 /* REVISIT should this be arm_set_cpsr(arm, spsr)
94 * instead of a partially unrolled version?
97 buf_set_u32(arm
->cpsr
->value
, 0, 32, spsr
);
99 arm
->core_mode
= spsr
& 0x1f;
101 arm
->core_state
= ARM_STATE_THUMB
;
104 /* resume execution, this will be pc+2 to skip over the
105 * bkpt instruction */
107 /* return result in R0 */
108 buf_set_u32(arm
->core_cache
->reg_list
[0].value
, 0, 32, arm
->semihosting_result
);
109 arm
->core_cache
->reg_list
[0].dirty
= 1;
115 static int do_semihosting(struct target
*target
)
117 struct arm
*arm
= target_to_arm(target
);
118 struct gdb_fileio_info
*fileio_info
= target
->fileio_info
;
119 uint32_t r0
= buf_get_u32(arm
->core_cache
->reg_list
[0].value
, 0, 32);
120 uint32_t r1
= buf_get_u32(arm
->core_cache
->reg_list
[1].value
, 0, 32);
125 * TODO: lots of security issues are not considered yet, such as:
126 * - no validation on target provided file descriptors
127 * - no safety checks on opened/deleted/renamed file paths
128 * Beware the target app you use this support with.
130 * TODO: unsupported semihosting fileio operations could be
131 * implemented if we had a small working area at our disposal.
133 switch ((arm
->semihosting_op
= r0
)) {
134 case 0x01: /* SYS_OPEN */
135 retval
= target_read_memory(target
, r1
, 4, 3, params
);
136 if (retval
!= ERROR_OK
)
139 uint32_t a
= target_buffer_get_u32(target
, params
+0);
140 uint32_t m
= target_buffer_get_u32(target
, params
+4);
141 uint32_t l
= target_buffer_get_u32(target
, params
+8);
143 retval
= target_read_memory(target
, a
, 1, l
, fn
);
144 if (retval
!= ERROR_OK
)
147 if (arm
->is_semihosting_fileio
) {
148 if (strcmp((char *)fn
, ":tt") == 0)
149 arm
->semihosting_result
= 0;
151 arm
->semihosting_hit_fileio
= true;
152 fileio_info
->identifier
= "open";
153 fileio_info
->param_1
= a
;
154 fileio_info
->param_2
= l
;
155 fileio_info
->param_3
= open_modeflags
[m
];
156 fileio_info
->param_4
= 0644;
159 if (l
<= 255 && m
<= 11) {
160 if (strcmp((char *)fn
, ":tt") == 0) {
162 arm
->semihosting_result
= dup(STDIN_FILENO
);
164 arm
->semihosting_result
= dup(STDOUT_FILENO
);
166 /* cygwin requires the permission setting
167 * otherwise it will fail to reopen a previously
169 arm
->semihosting_result
= open((char *)fn
, open_modeflags
[m
], 0644);
171 arm
->semihosting_errno
= errno
;
173 arm
->semihosting_result
= -1;
174 arm
->semihosting_errno
= EINVAL
;
180 case 0x02: /* SYS_CLOSE */
181 retval
= target_read_memory(target
, r1
, 4, 1, params
);
182 if (retval
!= ERROR_OK
)
185 int fd
= target_buffer_get_u32(target
, params
+0);
186 if (arm
->is_semihosting_fileio
) {
187 arm
->semihosting_hit_fileio
= true;
188 fileio_info
->identifier
= "close";
189 fileio_info
->param_1
= fd
;
191 arm
->semihosting_result
= close(fd
);
192 arm
->semihosting_errno
= errno
;
197 case 0x03: /* SYS_WRITEC */
198 if (arm
->is_semihosting_fileio
) {
199 arm
->semihosting_hit_fileio
= true;
200 fileio_info
->identifier
= "write";
201 fileio_info
->param_1
= 1;
202 fileio_info
->param_2
= r1
;
203 fileio_info
->param_3
= 1;
206 retval
= target_read_memory(target
, r1
, 1, 1, &c
);
207 if (retval
!= ERROR_OK
)
210 arm
->semihosting_result
= 0;
214 case 0x04: /* SYS_WRITE0 */
215 if (arm
->is_semihosting_fileio
) {
217 for (uint32_t a
= r1
;; a
++) {
219 retval
= target_read_memory(target
, a
, 1, 1, &c
);
220 if (retval
!= ERROR_OK
)
226 arm
->semihosting_hit_fileio
= true;
227 fileio_info
->identifier
= "write";
228 fileio_info
->param_1
= 1;
229 fileio_info
->param_2
= r1
;
230 fileio_info
->param_3
= count
;
234 retval
= target_read_memory(target
, r1
++, 1, 1, &c
);
235 if (retval
!= ERROR_OK
)
241 arm
->semihosting_result
= 0;
245 case 0x05: /* SYS_WRITE */
246 retval
= target_read_memory(target
, r1
, 4, 3, params
);
247 if (retval
!= ERROR_OK
)
250 int fd
= target_buffer_get_u32(target
, params
+0);
251 uint32_t a
= target_buffer_get_u32(target
, params
+4);
252 size_t l
= target_buffer_get_u32(target
, params
+8);
253 if (arm
->is_semihosting_fileio
) {
254 arm
->semihosting_hit_fileio
= true;
255 fileio_info
->identifier
= "write";
256 fileio_info
->param_1
= fd
;
257 fileio_info
->param_2
= a
;
258 fileio_info
->param_3
= l
;
260 uint8_t *buf
= malloc(l
);
262 arm
->semihosting_result
= -1;
263 arm
->semihosting_errno
= ENOMEM
;
265 retval
= target_read_buffer(target
, a
, l
, buf
);
266 if (retval
!= ERROR_OK
) {
270 arm
->semihosting_result
= write(fd
, buf
, l
);
271 arm
->semihosting_errno
= errno
;
272 if (arm
->semihosting_result
>= 0)
273 arm
->semihosting_result
= l
- arm
->semihosting_result
;
280 case 0x06: /* SYS_READ */
281 retval
= target_read_memory(target
, r1
, 4, 3, params
);
282 if (retval
!= ERROR_OK
)
285 int fd
= target_buffer_get_u32(target
, params
+0);
286 uint32_t a
= target_buffer_get_u32(target
, params
+4);
287 ssize_t l
= target_buffer_get_u32(target
, params
+8);
288 if (arm
->is_semihosting_fileio
) {
289 arm
->semihosting_hit_fileio
= true;
290 fileio_info
->identifier
= "read";
291 fileio_info
->param_1
= fd
;
292 fileio_info
->param_2
= a
;
293 fileio_info
->param_3
= l
;
295 uint8_t *buf
= malloc(l
);
297 arm
->semihosting_result
= -1;
298 arm
->semihosting_errno
= ENOMEM
;
300 arm
->semihosting_result
= read(fd
, buf
, l
);
301 arm
->semihosting_errno
= errno
;
302 if (arm
->semihosting_result
>= 0) {
303 retval
= target_write_buffer(target
, a
, arm
->semihosting_result
, buf
);
304 if (retval
!= ERROR_OK
) {
308 arm
->semihosting_result
= l
- arm
->semihosting_result
;
316 case 0x07: /* SYS_READC */
317 if (arm
->is_semihosting_fileio
) {
318 LOG_ERROR("SYS_READC not supported by semihosting fileio");
321 arm
->semihosting_result
= getchar();
324 case 0x08: /* SYS_ISERROR */
325 retval
= target_read_memory(target
, r1
, 4, 1, params
);
326 if (retval
!= ERROR_OK
)
328 arm
->semihosting_result
= (target_buffer_get_u32(target
, params
+0) != 0);
331 case 0x09: /* SYS_ISTTY */
332 if (arm
->is_semihosting_fileio
) {
333 arm
->semihosting_hit_fileio
= true;
334 fileio_info
->identifier
= "isatty";
335 fileio_info
->param_1
= r1
;
337 retval
= target_read_memory(target
, r1
, 4, 1, params
);
338 if (retval
!= ERROR_OK
)
340 arm
->semihosting_result
= isatty(target_buffer_get_u32(target
, params
+0));
344 case 0x0a: /* SYS_SEEK */
345 retval
= target_read_memory(target
, r1
, 4, 2, params
);
346 if (retval
!= ERROR_OK
)
349 int fd
= target_buffer_get_u32(target
, params
+0);
350 off_t pos
= target_buffer_get_u32(target
, params
+4);
351 if (arm
->is_semihosting_fileio
) {
352 arm
->semihosting_hit_fileio
= true;
353 fileio_info
->identifier
= "lseek";
354 fileio_info
->param_1
= fd
;
355 fileio_info
->param_2
= pos
;
356 fileio_info
->param_3
= SEEK_SET
;
358 arm
->semihosting_result
= lseek(fd
, pos
, SEEK_SET
);
359 arm
->semihosting_errno
= errno
;
360 if (arm
->semihosting_result
== pos
)
361 arm
->semihosting_result
= 0;
366 case 0x0c: /* SYS_FLEN */
367 if (arm
->is_semihosting_fileio
) {
368 LOG_ERROR("SYS_FLEN not supported by semihosting fileio");
371 retval
= target_read_memory(target
, r1
, 4, 1, params
);
372 if (retval
!= ERROR_OK
)
375 int fd
= target_buffer_get_u32(target
, params
+0);
377 arm
->semihosting_result
= fstat(fd
, &buf
);
378 if (arm
->semihosting_result
== -1) {
379 arm
->semihosting_errno
= errno
;
380 arm
->semihosting_result
= -1;
383 arm
->semihosting_result
= buf
.st_size
;
387 case 0x0e: /* SYS_REMOVE */
388 retval
= target_read_memory(target
, r1
, 4, 2, params
);
389 if (retval
!= ERROR_OK
)
392 uint32_t a
= target_buffer_get_u32(target
, params
+0);
393 uint32_t l
= target_buffer_get_u32(target
, params
+4);
394 if (arm
->is_semihosting_fileio
) {
395 arm
->semihosting_hit_fileio
= true;
396 fileio_info
->identifier
= "unlink";
397 fileio_info
->param_1
= a
;
398 fileio_info
->param_2
= l
;
402 retval
= target_read_memory(target
, a
, 1, l
, fn
);
403 if (retval
!= ERROR_OK
)
406 arm
->semihosting_result
= remove((char *)fn
);
407 arm
->semihosting_errno
= errno
;
409 arm
->semihosting_result
= -1;
410 arm
->semihosting_errno
= EINVAL
;
416 case 0x0f: /* SYS_RENAME */
417 retval
= target_read_memory(target
, r1
, 4, 4, params
);
418 if (retval
!= ERROR_OK
)
421 uint32_t a1
= target_buffer_get_u32(target
, params
+0);
422 uint32_t l1
= target_buffer_get_u32(target
, params
+4);
423 uint32_t a2
= target_buffer_get_u32(target
, params
+8);
424 uint32_t l2
= target_buffer_get_u32(target
, params
+12);
425 if (arm
->is_semihosting_fileio
) {
426 arm
->semihosting_hit_fileio
= true;
427 fileio_info
->identifier
= "rename";
428 fileio_info
->param_1
= a1
;
429 fileio_info
->param_2
= l1
;
430 fileio_info
->param_3
= a2
;
431 fileio_info
->param_4
= l2
;
433 if (l1
<= 255 && l2
<= 255) {
434 uint8_t fn1
[256], fn2
[256];
435 retval
= target_read_memory(target
, a1
, 1, l1
, fn1
);
436 if (retval
!= ERROR_OK
)
438 retval
= target_read_memory(target
, a2
, 1, l2
, fn2
);
439 if (retval
!= ERROR_OK
)
443 arm
->semihosting_result
= rename((char *)fn1
, (char *)fn2
);
444 arm
->semihosting_errno
= errno
;
446 arm
->semihosting_result
= -1;
447 arm
->semihosting_errno
= EINVAL
;
453 case 0x11: /* SYS_TIME */
454 arm
->semihosting_result
= time(NULL
);
457 case 0x13: /* SYS_ERRNO */
458 arm
->semihosting_result
= arm
->semihosting_errno
;
461 case 0x15: /* SYS_GET_CMDLINE */
462 retval
= target_read_memory(target
, r1
, 4, 2, params
);
463 if (retval
!= ERROR_OK
)
466 uint32_t a
= target_buffer_get_u32(target
, params
+0);
467 uint32_t l
= target_buffer_get_u32(target
, params
+4);
468 char *arg
= "foobar";
469 uint32_t s
= strlen(arg
) + 1;
471 arm
->semihosting_result
= -1;
473 retval
= target_write_buffer(target
, a
, s
, (uint8_t *)arg
);
474 if (retval
!= ERROR_OK
)
476 arm
->semihosting_result
= 0;
481 case 0x16: /* SYS_HEAPINFO */
482 retval
= target_read_memory(target
, r1
, 4, 1, params
);
483 if (retval
!= ERROR_OK
)
486 uint32_t a
= target_buffer_get_u32(target
, params
+0);
487 /* tell the remote we have no idea */
488 memset(params
, 0, 4*4);
489 retval
= target_write_memory(target
, a
, 4, 4, params
);
490 if (retval
!= ERROR_OK
)
492 arm
->semihosting_result
= 0;
496 case 0x18: /* angel_SWIreason_ReportException */
498 case 0x20026: /* ADP_Stopped_ApplicationExit */
499 fprintf(stderr
, "semihosting: *** application exited ***\n");
501 case 0x20000: /* ADP_Stopped_BranchThroughZero */
502 case 0x20001: /* ADP_Stopped_UndefinedInstr */
503 case 0x20002: /* ADP_Stopped_SoftwareInterrupt */
504 case 0x20003: /* ADP_Stopped_PrefetchAbort */
505 case 0x20004: /* ADP_Stopped_DataAbort */
506 case 0x20005: /* ADP_Stopped_AddressException */
507 case 0x20006: /* ADP_Stopped_IRQ */
508 case 0x20007: /* ADP_Stopped_FIQ */
509 case 0x20020: /* ADP_Stopped_BreakPoint */
510 case 0x20021: /* ADP_Stopped_WatchPoint */
511 case 0x20022: /* ADP_Stopped_StepComplete */
512 case 0x20023: /* ADP_Stopped_RunTimeErrorUnknown */
513 case 0x20024: /* ADP_Stopped_InternalError */
514 case 0x20025: /* ADP_Stopped_UserInterruption */
515 case 0x20027: /* ADP_Stopped_StackOverflow */
516 case 0x20028: /* ADP_Stopped_DivisionByZero */
517 case 0x20029: /* ADP_Stopped_OSSpecific */
519 fprintf(stderr
, "semihosting: exception %#x\n",
522 return target_call_event_callbacks(target
, TARGET_EVENT_HALTED
);
524 case 0x12: /* SYS_SYSTEM */
525 /* Provide SYS_SYSTEM functionality. Uses the
526 * libc system command, there may be a reason *NOT*
527 * to use this, but as I can't think of one, I
528 * implemented it this way.
530 retval
= target_read_memory(target
, r1
, 4, 2, params
);
531 if (retval
!= ERROR_OK
)
534 uint32_t len
= target_buffer_get_u32(target
, params
+4);
535 uint32_t c_ptr
= target_buffer_get_u32(target
, params
);
536 if (arm
->is_semihosting_fileio
) {
537 arm
->semihosting_hit_fileio
= true;
538 fileio_info
->identifier
= "system";
539 fileio_info
->param_1
= c_ptr
;
540 fileio_info
->param_2
= len
;
544 arm
->semihosting_result
= -1;
545 arm
->semihosting_errno
= EINVAL
;
547 memset(cmd
, 0x0, 256);
548 retval
= target_read_memory(target
, c_ptr
, 1, len
, cmd
);
549 if (retval
!= ERROR_OK
)
552 arm
->semihosting_result
= system((const char *)cmd
);
557 case 0x0d: /* SYS_TMPNAM */
558 case 0x10: /* SYS_CLOCK */
559 case 0x17: /* angel_SWIreason_EnterSVC */
560 case 0x30: /* SYS_ELAPSED */
561 case 0x31: /* SYS_TICKFREQ */
563 fprintf(stderr
, "semihosting: unsupported call %#x\n",
565 arm
->semihosting_result
= -1;
566 arm
->semihosting_errno
= ENOTSUP
;
572 static int get_gdb_fileio_info(struct target
*target
, struct gdb_fileio_info
*fileio_info
)
574 struct arm
*arm
= target_to_arm(target
);
576 /* To avoid uneccessary duplication, semihosting prepares the
577 * fileio_info structure out-of-band when the target halts. See
578 * do_semihosting for more detail.
580 if (!arm
->is_semihosting_fileio
|| !arm
->semihosting_hit_fileio
)
586 static int gdb_fileio_end(struct target
*target
, int result
, int fileio_errno
, bool ctrl_c
)
588 struct arm
*arm
= target_to_arm(target
);
589 struct gdb_fileio_info
*fileio_info
= target
->fileio_info
;
591 /* clear pending status */
592 arm
->semihosting_hit_fileio
= false;
594 arm
->semihosting_result
= result
;
595 arm
->semihosting_errno
= fileio_errno
;
597 /* Some fileio results do not match up with what the semihosting
598 * operation expects; for these operations, we munge the results
601 switch (arm
->semihosting_op
) {
602 case 0x05: /* SYS_WRITE */
604 arm
->semihosting_result
= fileio_info
->param_3
;
606 arm
->semihosting_result
= 0;
609 case 0x06: /* SYS_READ */
610 if (result
== (int)fileio_info
->param_3
)
611 arm
->semihosting_result
= 0;
613 arm
->semihosting_result
= fileio_info
->param_3
;
616 case 0x0a: /* SYS_SEEK */
618 arm
->semihosting_result
= 0;
622 return post_result(target
);
626 * Initialize ARM semihosting support.
628 * @param target Pointer to the ARM target to initialize.
629 * @return An error status if there is a problem during initialization.
631 int arm_semihosting_init(struct target
*target
)
633 target
->fileio_info
= malloc(sizeof(*target
->fileio_info
));
634 if (target
->fileio_info
== NULL
) {
635 LOG_ERROR("out of memory");
639 target
->type
->get_gdb_fileio_info
= get_gdb_fileio_info
;
640 target
->type
->gdb_fileio_end
= gdb_fileio_end
;
646 * Checks for and processes an ARM semihosting request. This is meant
647 * to be called when the target is stopped due to a debug mode entry.
648 * If the value 0 is returned then there was nothing to process. A non-zero
649 * return value signifies that a request was processed and the target resumed,
650 * or an error was encountered, in which case the caller must return
653 * @param target Pointer to the ARM target to process. This target must
654 * not represent an ARMv6-M or ARMv7-M processor.
655 * @param retval Pointer to a location where the return code will be stored
656 * @return non-zero value if a request was processed or an error encountered
658 int arm_semihosting(struct target
*target
, int *retval
)
660 struct arm
*arm
= target_to_arm(target
);
661 struct armv7a_common
*armv7a
= target_to_armv7a(target
);
662 uint32_t pc
, lr
, spsr
;
665 if (!arm
->is_semihosting
)
668 if (is_arm7_9(target_to_arm7_9(target
)) ||
670 uint32_t vbar
= 0x00000000;
672 if (arm
->core_mode
!= ARM_MODE_SVC
)
675 if (is_armv7a(armv7a
)) {
676 struct arm_dpm
*dpm
= armv7a
->arm
.dpm
;
678 *retval
= dpm
->prepare(dpm
);
679 if (*retval
== ERROR_OK
) {
680 *retval
= dpm
->instr_read_data_r0(dpm
,
681 ARMV4_5_MRC(15, 0, 0, 12, 0, 0),
686 if (*retval
!= ERROR_OK
)
693 /* Check for PC == 0x00000008 or 0xffff0008: Supervisor Call vector. */
695 pc
= buf_get_u32(r
->value
, 0, 32);
696 if (pc
!= (vbar
+ 0x00000008) && pc
!= 0xffff0008)
699 r
= arm_reg_current(arm
, 14);
700 lr
= buf_get_u32(r
->value
, 0, 32);
702 /* Core-specific code should make sure SPSR is retrieved
703 * when the above checks pass...
705 if (!arm
->spsr
->valid
) {
706 LOG_ERROR("SPSR not valid!");
707 *retval
= ERROR_FAIL
;
711 spsr
= buf_get_u32(arm
->spsr
->value
, 0, 32);
713 /* check instruction that triggered this trap */
714 if (spsr
& (1 << 5)) {
715 /* was in Thumb (or ThumbEE) mode */
719 *retval
= target_read_memory(target
, lr
-2, 2, 1, insn_buf
);
720 if (*retval
!= ERROR_OK
)
722 insn
= target_buffer_get_u16(target
, insn_buf
);
727 } else if (spsr
& (1 << 24)) {
728 /* was in Jazelle mode */
731 /* was in ARM mode */
735 *retval
= target_read_memory(target
, lr
-4, 4, 1, insn_buf
);
736 if (*retval
!= ERROR_OK
)
738 insn
= target_buffer_get_u32(target
, insn_buf
);
741 if (insn
!= 0xEF123456)
744 } else if (is_armv7m(target_to_armv7m(target
))) {
747 if (target
->debug_reason
!= DBG_REASON_BREAKPOINT
)
751 pc
= buf_get_u32(r
->value
, 0, 32);
754 *retval
= target_read_u16(target
, pc
, &insn
);
755 if (*retval
!= ERROR_OK
)
762 LOG_ERROR("Unsupported semi-hosting Target");
766 /* Perform semihosting if we are not waiting on a fileio
767 * operation to complete.
769 if (!arm
->semihosting_hit_fileio
) {
770 *retval
= do_semihosting(target
);
771 if (*retval
!= ERROR_OK
) {
772 LOG_ERROR("Failed semihosting operation");
777 /* Post result to target if we are not waiting on a fileio
778 * operation to complete:
780 if (!arm
->semihosting_hit_fileio
) {
781 *retval
= post_result(target
);
782 if (*retval
!= ERROR_OK
) {
783 LOG_ERROR("Failed to post semihosting result");
787 *retval
= target_resume(target
, 1, 0, 0, 0);
788 if (*retval
!= ERROR_OK
) {
789 LOG_ERROR("Failed to resume target");