Skip to content

Commit

Permalink
RISC-V semihosting 2 of 3: Cleanup semihosting outcome prints
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
JanMatCodasip committed Jan 13, 2025
1 parent fbb102e commit 4af47de
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/target/riscv/riscv_semihosting.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ enum semihosting_result riscv_semihosting(struct target *target, int *retval)
assert(semihosting);

if (!semihosting->is_active) {
LOG_TARGET_DEBUG(target, " -> NONE (!semihosting->is_active)");
LOG_TARGET_DEBUG(target, "Semihosting outcome: NONE (semihosting not enabled)");
return SEMIHOSTING_NONE;
}

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

if (!sequence_found) {
LOG_TARGET_DEBUG(target, " -> NONE (no magic)");
LOG_TARGET_DEBUG(target, "Semihosting outcome: NONE (no magic sequence)");
return SEMIHOSTING_NONE;
}

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

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

Expand All @@ -160,11 +162,13 @@ enum semihosting_result riscv_semihosting(struct target *target, int *retval)
*retval = semihosting_common(target);
if (*retval != ERROR_OK) {
LOG_TARGET_ERROR(target, "Failed semihosting operation (0x%02X)", semihosting->op);
LOG_TARGET_DEBUG(target, "Semihosting outcome: ERROR (error during semihosting processing)");
return SEMIHOSTING_ERROR;
}
} else {
/* Unknown operation number, not a semihosting call. */
LOG_TARGET_ERROR(target, "Unknown semihosting operation requested (op = 0x%x)", semihosting->op);
LOG_TARGET_DEBUG(target, "Semihosting outcome: NONE (unknown semihosting opcode)");
return SEMIHOSTING_NONE;
}
}
Expand All @@ -179,11 +183,11 @@ enum semihosting_result riscv_semihosting(struct target *target, int *retval)
* operation to complete.
*/
if (semihosting->is_resumable && !semihosting->hit_fileio) {
LOG_TARGET_DEBUG(target, " -> HANDLED");
LOG_TARGET_DEBUG(target, "Semihosting outcome: HANDLED");
return SEMIHOSTING_HANDLED;
}

LOG_TARGET_DEBUG(target, " -> WAITING");
LOG_TARGET_DEBUG(target, "Semihosting outcome: WAITING");
return SEMIHOSTING_WAITING;
}

Expand Down

0 comments on commit 4af47de

Please sign in to comment.