interface/jlink: Fix comment about serial number
[openocd.git] / src / target / quark_d20xx.c
blobf797214170c2a55abc0d0fe2b9a22beb70bc4c06
1 /*
2 * Copyright(c) 2015-2016 Intel Corporation.
4 * Jessica Gomez (jessica.gomez.hernandez@intel.com)
5 * Ivan De Cesaris (ivan.de.cesaris@intel.com)
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * Contact Information:
18 * Intel Corporation
22 * @file
23 * Debugger for Intel Quark D20xx
24 * The CPU TAP (Lakemont TAP) is used for software debug and the CLTAP is
25 * used for SoC level operations.
27 * Reference document:
28 * Intel Quark microcontroller D2000 Debug Operations (web search for doc num 333241)
31 #ifdef HAVE_CONFIG_H
32 #include "config.h"
33 #endif
35 #include <helper/log.h>
37 #include "target.h"
38 #include "target_type.h"
39 #include "breakpoints.h"
40 #include "lakemont.h"
41 #include "x86_32_common.h"
43 int quark_d20xx_target_create(struct target *t, Jim_Interp *interp)
45 struct x86_32_common *x86_32 = calloc(1, sizeof(struct x86_32_common));
46 if (x86_32 == NULL) {
47 LOG_ERROR("%s out of memory", __func__);
48 return ERROR_FAIL;
50 x86_32_common_init_arch_info(t, x86_32);
51 lakemont_init_arch_info(t, x86_32);
52 x86_32->core_type = LMT3_5;
53 return ERROR_OK;
56 int quark_d20xx_init_target(struct command_context *cmd_ctx, struct target *t)
58 return lakemont_init_target(cmd_ctx, t);
61 static int quark_d20xx_reset_deassert(struct target *t)
63 int retval;
65 /* Can't detect if a warm reset happened while halted but we can make the
66 * openocd and target state consistent here if in probe mode already
68 if (!check_not_halted(t)) {
69 retval = lakemont_update_after_probemode_entry(t);
70 if (retval != ERROR_OK) {
71 LOG_ERROR("%s core state update fail", __func__);
72 return retval;
74 /* resume target if reset mode is run */
75 if (!t->reset_halt) {
76 retval = lakemont_resume(t, 1, 0, 0, 0);
77 if (retval != ERROR_OK) {
78 LOG_ERROR("%s could not resume target", __func__);
79 return retval;
84 return ERROR_OK;
87 struct target_type quark_d20xx_target = {
88 .name = "quark_d20xx",
89 .target_create = quark_d20xx_target_create,
90 .init_target = quark_d20xx_init_target,
91 /* lakemont probemode specific code */
92 .poll = lakemont_poll,
93 .arch_state = lakemont_arch_state,
94 .halt = lakemont_halt,
95 .resume = lakemont_resume,
96 .step = lakemont_step,
97 .assert_reset = lakemont_reset_assert,
98 .deassert_reset = quark_d20xx_reset_deassert,
99 /* common x86 code */
100 .commands = x86_32_command_handlers,
101 .get_gdb_reg_list = x86_32_get_gdb_reg_list,
102 .read_memory = x86_32_common_read_memory,
103 .write_memory = x86_32_common_write_memory,
104 .add_breakpoint = x86_32_common_add_breakpoint,
105 .remove_breakpoint = x86_32_common_remove_breakpoint,
106 .add_watchpoint = x86_32_common_add_watchpoint,
107 .remove_watchpoint = x86_32_common_remove_watchpoint,
108 .virt2phys = x86_32_common_virt2phys,
109 .read_phys_memory = x86_32_common_read_phys_mem,
110 .write_phys_memory = x86_32_common_write_phys_mem,
111 .mmu = x86_32_common_mmu,