./
Coverage:
low: ≥ 0%
medium: ≥ 50.0%
high: ≥ 80.0%
Lines:
11 / 11
100.0%
Branches:
12 / 12
100.0%
Functions:
1 / 1
100.0%

kfsw-platform/src/semihost.c
Line Branch Exec Source
1 #include <errno.h>
2 #include <zephyr/sys/atomic.h>
3 #include <kfsw/platform/semihost.h>
4
5 #include "semihost_internal.h"
6
7 static atomic_t writing;
8
9 96 int kfsw_semihost_write(const char *text, size_t size)
10 {
11 int result;
12 long unwritten;
13
14
6/6
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 84 times.
96 if ((text == NULL) || (size == 0U) || (size > KFSW_SEMIHOST_MAX_WRITE)) {
15 12 return -EINVAL;
16 }
17 84 result = kfsw_semihost_context();
18
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 68 times.
84 if (result != 0) {
19 16 return result;
20 }
21
2/2
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 44 times.
68 if (!atomic_cas(&writing, 0, 1)) {
22 24 return -EBUSY;
23 }
24 44 unwritten = kfsw_semihost_target_write(text, size);
25 44 atomic_clear(&writing);
26
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 20 times.
44 return unwritten == 0L ? 0 : -EIO;
27 }
28