semihosting: move semihosting_result_t from riscv.h to the semihosting_common.h
[openocd.git] / src / target / riscv / riscv_semihosting.c
index 1dd8e7791a5e5cc66ca75a298559fa9648d66870..c337a740d9de36ce934c77dff9acd50b8660a777 100644 (file)
@@ -44,7 +44,6 @@
 #include <helper/log.h>
 
 #include "target/target.h"
-#include "target/semihosting_common.h"
 #include "riscv.h"
 
 static int riscv_semihosting_setup(struct target *target, int enable);
@@ -67,23 +66,23 @@ void riscv_semihosting_init(struct target *target)
  * @param retval Pointer to a location where the return code will be stored
  * @return non-zero value if a request was processed or an error encountered
  */
-semihosting_result_t riscv_semihosting(struct target *target, int *retval)
+enum semihosting_result riscv_semihosting(struct target *target, int *retval)
 {
        struct semihosting *semihosting = target->semihosting;
        if (!semihosting) {
                LOG_DEBUG("   -> NONE (!semihosting)");
-               return SEMI_NONE;
+               return SEMIHOSTING_NONE;
        }
 
        if (!semihosting->is_active) {
                LOG_DEBUG("   -> NONE (!semihosting->is_active)");
-               return SEMI_NONE;
+               return SEMIHOSTING_NONE;
        }
 
        riscv_reg_t pc;
        int result = riscv_get_register(target, &pc, GDB_REGNO_PC);
        if (result != ERROR_OK)
-               return SEMI_ERROR;
+               return SEMIHOSTING_ERROR;
 
        uint8_t tmp_buf[12];
 
@@ -92,7 +91,7 @@ semihosting_result_t riscv_semihosting(struct target *target, int *retval)
                /* Instruction memories may not support arbitrary read size. Use any size that will work. */
                *retval = riscv_read_by_any_size(target, (pc - 4) + 4 * i, 4, tmp_buf + 4 * i);
                if (*retval != ERROR_OK)
-                       return SEMI_ERROR;
+                       return SEMIHOSTING_ERROR;
        }
 
        /*
@@ -111,7 +110,7 @@ semihosting_result_t riscv_semihosting(struct target *target, int *retval)
        if (pre != 0x01f01013 || ebreak != 0x00100073 || post != 0x40705013) {
                /* Not the magic sequence defining semihosting. */
                LOG_DEBUG("   -> NONE (no magic)");
-               return SEMI_NONE;
+               return SEMIHOSTING_NONE;
        }
 
        /*
@@ -126,13 +125,13 @@ semihosting_result_t riscv_semihosting(struct target *target, int *retval)
                result = riscv_get_register(target, &r0, GDB_REGNO_A0);
                if (result != ERROR_OK) {
                        LOG_DEBUG("   -> ERROR (couldn't read a0)");
-                       return SEMI_ERROR;
+                       return SEMIHOSTING_ERROR;
                }
 
                result = riscv_get_register(target, &r1, GDB_REGNO_A1);
                if (result != ERROR_OK) {
                        LOG_DEBUG("   -> ERROR (couldn't read a1)");
-                       return SEMI_ERROR;
+                       return SEMIHOSTING_ERROR;
                }
 
                semihosting->op = r0;
@@ -146,12 +145,12 @@ semihosting_result_t riscv_semihosting(struct target *target, int *retval)
                        *retval = semihosting_common(target);
                        if (*retval != ERROR_OK) {
                                LOG_ERROR("Failed semihosting operation (0x%02X)", semihosting->op);
-                               return SEMI_ERROR;
+                               return SEMIHOSTING_ERROR;
                        }
                } else {
                        /* Unknown operation number, not a semihosting call. */
                        LOG_DEBUG("   -> NONE (unknown operation number)");
-                       return SEMI_NONE;
+                       return SEMIHOSTING_NONE;
                }
        }
 
@@ -163,14 +162,14 @@ semihosting_result_t riscv_semihosting(struct target *target, int *retval)
                /* Resume right after the EBREAK 4 bytes instruction. */
                *retval = riscv_set_register(target, GDB_REGNO_PC, pc + 4);
                if (*retval != ERROR_OK)
-                       return SEMI_ERROR;
+                       return SEMIHOSTING_ERROR;
 
                LOG_DEBUG("   -> HANDLED");
-               return SEMI_HANDLED;
+               return SEMIHOSTING_HANDLED;
        }
 
        LOG_DEBUG("   -> WAITING");
-       return SEMI_WAITING;
+       return SEMIHOSTING_WAITING;
 }
 
 /* -------------------------------------------------------------------------

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)