Skip to content

Commit 4af47de

Browse files
committed
RISC-V semihosting 2 of 3: Cleanup semihosting outcome prints
Cleanup the debug prints denoting the semihosting outcome so that they are easier to understand when reading the OpenOCD's verbose (debug) log. Change-Id: Ibdef1b4474e47dd0a135d4696b3e53600c544eb8 Signed-off-by: Jan Matyas <[email protected]>
1 parent fbb102e commit 4af47de

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/target/riscv/riscv_semihosting.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ enum semihosting_result riscv_semihosting(struct target *target, int *retval)
106106
assert(semihosting);
107107

108108
if (!semihosting->is_active) {
109-
LOG_TARGET_DEBUG(target, " -> NONE (!semihosting->is_active)");
109+
LOG_TARGET_DEBUG(target, "Semihosting outcome: NONE (semihosting not enabled)");
110110
return SEMIHOSTING_NONE;
111111
}
112112

@@ -121,7 +121,7 @@ enum semihosting_result riscv_semihosting(struct target *target, int *retval)
121121
return SEMIHOSTING_ERROR;
122122

123123
if (!sequence_found) {
124-
LOG_TARGET_DEBUG(target, " -> NONE (no magic)");
124+
LOG_TARGET_DEBUG(target, "Semihosting outcome: NONE (no magic sequence)");
125125
return SEMIHOSTING_NONE;
126126
}
127127

@@ -140,12 +140,14 @@ enum semihosting_result riscv_semihosting(struct target *target, int *retval)
140140
result = riscv_reg_get(target, &r0, GDB_REGNO_A0);
141141
if (result != ERROR_OK) {
142142
LOG_TARGET_ERROR(target, "Could not read semihosting operation code (register a0)");
143+
LOG_TARGET_DEBUG(target, "Semihosting outcome: ERROR (failed to read a0)");
143144
return SEMIHOSTING_ERROR;
144145
}
145146

146147
result = riscv_reg_get(target, &r1, GDB_REGNO_A1);
147148
if (result != ERROR_OK) {
148149
LOG_TARGET_ERROR(target, "Could not read semihosting operation code (register a1)");
150+
LOG_TARGET_DEBUG(target, "Semihosting outcome: ERROR (failed to read a1)");
149151
return SEMIHOSTING_ERROR;
150152
}
151153

@@ -160,11 +162,13 @@ enum semihosting_result riscv_semihosting(struct target *target, int *retval)
160162
*retval = semihosting_common(target);
161163
if (*retval != ERROR_OK) {
162164
LOG_TARGET_ERROR(target, "Failed semihosting operation (0x%02X)", semihosting->op);
165+
LOG_TARGET_DEBUG(target, "Semihosting outcome: ERROR (error during semihosting processing)");
163166
return SEMIHOSTING_ERROR;
164167
}
165168
} else {
166169
/* Unknown operation number, not a semihosting call. */
167170
LOG_TARGET_ERROR(target, "Unknown semihosting operation requested (op = 0x%x)", semihosting->op);
171+
LOG_TARGET_DEBUG(target, "Semihosting outcome: NONE (unknown semihosting opcode)");
168172
return SEMIHOSTING_NONE;
169173
}
170174
}
@@ -179,11 +183,11 @@ enum semihosting_result riscv_semihosting(struct target *target, int *retval)
179183
* operation to complete.
180184
*/
181185
if (semihosting->is_resumable && !semihosting->hit_fileio) {
182-
LOG_TARGET_DEBUG(target, " -> HANDLED");
186+
LOG_TARGET_DEBUG(target, "Semihosting outcome: HANDLED");
183187
return SEMIHOSTING_HANDLED;
184188
}
185189

186-
LOG_TARGET_DEBUG(target, " -> WAITING");
190+
LOG_TARGET_DEBUG(target, "Semihosting outcome: WAITING");
187191
return SEMIHOSTING_WAITING;
188192
}
189193

0 commit comments

Comments
 (0)