1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright(c) 2015-2016 Intel Corporation.
6 * Jessica Gomez (jessica.gomez.hernandez@intel.com)
7 * Ivan De Cesaris (ivan.de.cesaris@intel.com)
15 * Debugger for Intel Quark D20xx
16 * The CPU TAP (Lakemont TAP) is used for software debug and the CLTAP is
17 * used for SoC level operations.
20 * Intel Quark microcontroller D2000 Debug Operations (web search for doc num 333241)
27 #include <helper/log.h>
30 #include "target_type.h"
31 #include "breakpoints.h"
33 #include "x86_32_common.h"
35 static int quark_d20xx_target_create(struct target
*t
, Jim_Interp
*interp
)
37 struct x86_32_common
*x86_32
= calloc(1, sizeof(struct x86_32_common
));
39 LOG_ERROR("%s out of memory", __func__
);
42 x86_32_common_init_arch_info(t
, x86_32
);
43 lakemont_init_arch_info(t
, x86_32
);
44 x86_32
->core_type
= LMT3_5
;
48 static int quark_d20xx_init_target(struct command_context
*cmd_ctx
, struct target
*t
)
50 return lakemont_init_target(cmd_ctx
, t
);
53 static int quark_d20xx_reset_deassert(struct target
*t
)
57 /* Can't detect if a warm reset happened while halted but we can make the
58 * openocd and target state consistent here if in probe mode already
60 if (!check_not_halted(t
)) {
61 retval
= lakemont_update_after_probemode_entry(t
);
62 if (retval
!= ERROR_OK
) {
63 LOG_ERROR("%s core state update fail", __func__
);
66 /* resume target if reset mode is run */
68 retval
= lakemont_resume(t
, 1, 0, 0, 0);
69 if (retval
!= ERROR_OK
) {
70 LOG_ERROR("%s could not resume target", __func__
);
79 struct target_type quark_d20xx_target
= {
80 .name
= "quark_d20xx",
81 .target_create
= quark_d20xx_target_create
,
82 .init_target
= quark_d20xx_init_target
,
83 /* lakemont probemode specific code */
84 .poll
= lakemont_poll
,
85 .arch_state
= lakemont_arch_state
,
86 .halt
= lakemont_halt
,
87 .resume
= lakemont_resume
,
88 .step
= lakemont_step
,
89 .assert_reset
= lakemont_reset_assert
,
90 .deassert_reset
= quark_d20xx_reset_deassert
,
92 .commands
= x86_32_command_handlers
,
93 .get_gdb_reg_list
= x86_32_get_gdb_reg_list
,
94 .read_memory
= x86_32_common_read_memory
,
95 .write_memory
= x86_32_common_write_memory
,
96 .add_breakpoint
= x86_32_common_add_breakpoint
,
97 .remove_breakpoint
= x86_32_common_remove_breakpoint
,
98 .add_watchpoint
= x86_32_common_add_watchpoint
,
99 .remove_watchpoint
= x86_32_common_remove_watchpoint
,
100 .virt2phys
= x86_32_common_virt2phys
,
101 .read_phys_memory
= x86_32_common_read_phys_mem
,
102 .write_phys_memory
= x86_32_common_write_phys_mem
,
103 .mmu
= x86_32_common_mmu
,