target/espressif: add semihosting support
[fw/openocd] / src / target / testee.c
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 /***************************************************************************
4  *   Copyright (C) 2009 Zachary T Welch <zw@superlucidity.net>             *
5  ***************************************************************************/
6
7 #ifdef HAVE_CONFIG_H
8 #include "config.h"
9 #endif
10
11 #include <helper/log.h>
12
13 #include "target.h"
14 #include "target_type.h"
15 #include "hello.h"
16
17 static const struct command_registration testee_command_handlers[] = {
18         {
19                 .name = "testee",
20                 .mode = COMMAND_ANY,
21                 .help = "testee target commands",
22                 .chain = hello_command_handlers,
23                 .usage = "",
24         },
25         COMMAND_REGISTRATION_DONE
26 };
27
28 static int testee_init(struct command_context *cmd_ctx, struct target *target)
29 {
30         return ERROR_OK;
31 }
32 static int testee_poll(struct target *target)
33 {
34         if ((target->state == TARGET_RUNNING) || (target->state == TARGET_DEBUG_RUNNING))
35                 target->state = TARGET_HALTED;
36         return ERROR_OK;
37 }
38 static int testee_halt(struct target *target)
39 {
40         target->state = TARGET_HALTED;
41         return ERROR_OK;
42 }
43 static int testee_reset_assert(struct target *target)
44 {
45         target->state = TARGET_RESET;
46         return ERROR_OK;
47 }
48 static int testee_reset_deassert(struct target *target)
49 {
50         target->state = TARGET_RUNNING;
51         return ERROR_OK;
52 }
53 struct target_type testee_target = {
54         .name = "testee",
55         .commands = testee_command_handlers,
56
57         .init_target = &testee_init,
58         .poll = &testee_poll,
59         .halt = &testee_halt,
60         .assert_reset = &testee_reset_assert,
61         .deassert_reset = &testee_reset_deassert,
62 };