OpenOCD
quark_d20xx.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /*
4  * Copyright(c) 2015-2016 Intel Corporation.
5  *
6  * Jessica Gomez (jessica.gomez.hernandez@intel.com)
7  * Ivan De Cesaris (ivan.de.cesaris@intel.com)
8  *
9  * Contact Information:
10  * Intel Corporation
11  */
12 
13 /*
14  * @file
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.
18  *
19  * Reference document:
20  * Intel Quark microcontroller D2000 Debug Operations (web search for doc num 333241)
21  */
22 
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
26 
27 #include <helper/log.h>
28 
29 #include "target.h"
30 #include "target_type.h"
31 #include "breakpoints.h"
32 #include "lakemont.h"
33 #include "x86_32_common.h"
34 
35 static int quark_d20xx_target_create(struct target *t, Jim_Interp *interp)
36 {
37  struct x86_32_common *x86_32 = calloc(1, sizeof(struct x86_32_common));
38  if (!x86_32) {
39  LOG_ERROR("%s out of memory", __func__);
40  return ERROR_FAIL;
41  }
43  lakemont_init_arch_info(t, x86_32);
44  x86_32->core_type = LMT3_5;
45  return ERROR_OK;
46 }
47 
48 static int quark_d20xx_init_target(struct command_context *cmd_ctx, struct target *t)
49 {
50  return lakemont_init_target(cmd_ctx, t);
51 }
52 
53 static int quark_d20xx_reset_deassert(struct target *t)
54 {
55  int retval;
56 
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
59  */
60  if (!check_not_halted(t)) {
62  if (retval != ERROR_OK) {
63  LOG_ERROR("%s core state update fail", __func__);
64  return retval;
65  }
66  /* resume target if reset mode is run */
67  if (!t->reset_halt) {
68  retval = lakemont_resume(t, 1, 0, 0, 0);
69  if (retval != ERROR_OK) {
70  LOG_ERROR("%s could not resume target", __func__);
71  return retval;
72  }
73  }
74  }
75 
76  return ERROR_OK;
77 }
78 
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,
91  /* common x86 code */
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,
104 };
int lakemont_init_target(struct command_context *cmd_ctx, struct target *t)
Definition: lakemont.c:825
int lakemont_arch_state(struct target *t)
Definition: lakemont.c:966
int lakemont_init_arch_info(struct target *t, struct x86_32_common *x86_32)
Definition: lakemont.c:833
int lakemont_poll(struct target *t)
Definition: lakemont.c:847
int lakemont_step(struct target *t, int current, target_addr_t address, int handle_breakpoints)
Definition: lakemont.c:1032
int lakemont_update_after_probemode_entry(struct target *t)
Definition: lakemont.c:569
int lakemont_reset_assert(struct target *t)
Definition: lakemont.c:1164
int lakemont_resume(struct target *t, int current, target_addr_t address, int handle_breakpoints, int debug_execution)
Definition: lakemont.c:991
bool check_not_halted(const struct target *t)
Definition: lakemont.c:206
int lakemont_halt(struct target *t)
Definition: lakemont.c:978
#define ERROR_FAIL
Definition: log.h:161
#define LOG_ERROR(expr ...)
Definition: log.h:123
#define ERROR_OK
Definition: log.h:155
struct target_type quark_d20xx_target
Definition: quark_d20xx.c:79
static int quark_d20xx_reset_deassert(struct target *t)
Definition: quark_d20xx.c:53
static int quark_d20xx_target_create(struct target *t, Jim_Interp *interp)
Definition: quark_d20xx.c:35
static int quark_d20xx_init_target(struct command_context *cmd_ctx, struct target *t)
Definition: quark_d20xx.c:48
This holds methods shared between all instances of a given target type.
Definition: target_type.h:26
const char * name
Name of this type of target.
Definition: target_type.h:31
Definition: target.h:120
bool reset_halt
Definition: target.h:149
enum x86_core_type core_type
const struct command_registration x86_32_command_handlers[]
int x86_32_common_add_watchpoint(struct target *t, struct watchpoint *wp)
int x86_32_common_read_memory(struct target *t, target_addr_t addr, uint32_t size, uint32_t count, uint8_t *buf)
int x86_32_common_init_arch_info(struct target *t, struct x86_32_common *x86_32)
Definition: x86_32_common.c:80
int x86_32_common_add_breakpoint(struct target *t, struct breakpoint *bp)
int x86_32_common_virt2phys(struct target *t, target_addr_t address, target_addr_t *physical)
int x86_32_common_write_memory(struct target *t, target_addr_t addr, uint32_t size, uint32_t count, const uint8_t *buf)
int x86_32_get_gdb_reg_list(struct target *t, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
Definition: x86_32_common.c:57
int x86_32_common_read_phys_mem(struct target *t, target_addr_t phys_address, uint32_t size, uint32_t count, uint8_t *buffer)
int x86_32_common_remove_watchpoint(struct target *t, struct watchpoint *wp)
int x86_32_common_mmu(struct target *t, int *enabled)
Definition: x86_32_common.c:99
int x86_32_common_write_phys_mem(struct target *t, target_addr_t phys_address, uint32_t size, uint32_t count, const uint8_t *buffer)
int x86_32_common_remove_breakpoint(struct target *t, struct breakpoint *bp)
@ LMT3_5